Solved

perform an action when window has changed.

Posted on 2004-10-06
2
213 Views
Last Modified: 2010-04-05
Hi!!


I am making a console application.
I want to perform an action when window has changed.
I've created timer.

This is a function for getting window caption maybe it can help you answerring my question.

GetWindowText(GetForegroundWindow , @buf[0], SizeOf(buf) - 1);
 writeln(buf);



Thank you
0
Comment
Question by:ssivagna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Expert Comment

by:calinutz
ID: 12241929
window has changed?
0
 
LVL 4

Accepted Solution

by:
Evarest earned 125 total points
ID: 12242218
Try this code:

program Project1;

uses
  SysUtils, Windows, Forms;

{$apptype console}

var
 OldCaption: string;
 WNDCaption: array[0..255] of char;
begin
  while true do
   begin
    GetWindowText(GetForeGroundWindow, @WNDCaption[0], sizeof(WNDCaption)-1);
    if OldCaption <> WNDCaption
     then WriteLn('New Window: '+WndCaption);
    OldCaption :=WNDCaption;
    sleep(10);
   end;
end.

This small program will continuously loop and add any new window to the console output (if the caption is different).

Regards,
Evarest
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question