perform an action when window has changed.

Posted on 2004-10-06
Last Modified: 2010-04-05

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);

Thank you
Question by:ssivagna
LVL 11

Expert Comment

ID: 12241929
window has changed?

Accepted Solution

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

program Project1;

  SysUtils, Windows, Forms;

{$apptype console}

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

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


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