Solved

perform an action when window has changed.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using FastMM4... should I enable MMX option? 9 76
ddeman not working in activex 3 93
Convert Jpg /PNG To GIF 5 120
Controlled Assessment GCSE - desperate help needed 4 75
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

920 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

14 Experts available now in Live!

Get 1:1 Help Now