Solved

perform an action when window has changed.

Posted on 2004-10-06
2
207 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now