Solved

perform an action when window has changed.

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 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