Solved

Get Message WM_ACTIVATE External Process

Posted on 2009-04-07
9
1,121 Views
Last Modified: 2013-12-03
How i can get an event or windows messages in my application, when a external process's window is activate.
0
Comment
Question by:ISIGest
  • 3
  • 3
  • 3
9 Comments
 
LVL 86

Expert Comment

by:jkr
Comment Utility
You can do that using a WH_GETMESSAGE hook that filters for that mesage. See http://msdn.microsoft.com/en-us/library/ms997537.aspx ("Win32 Hooks") and http://www.swissdelphicenter.ch/torry/showcode.php?id=1212 for a Delphi example.
0
 
LVL 2

Expert Comment

by:mannujam
Comment Utility
WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus
0
 

Author Comment

by:ISIGest
Comment Utility
Thanks, but i need to hook "many" forms of a single external process...how i can do it?
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Well, as the above article explains - to set a global hook (i.e. one that is notified about every message sent to any window), implement the hook proc in a DLL and call 'SetWindowsHookEx()' with the DLL' module handle and a NULL thread ID. In pseudocode, that would be

HINSTANCE hInst = LoadLibrary("myhook.dll");

HOOKPROC pProc = GetProcAddress(hInst,"MyHook");

SetWindowsHookEx(WH_GETMESSAGE,pProc,hInst,0);
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Expert Comment

by:mannujam
Comment Utility
As JKR told you can get all MSg for the associated window and then you can refine the message from the message queue. BUT If SetWindowHookEx last parameter is 0 , it will be hooking the message for all of the windows currently running. If this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread.

So their you can put the thread id for your "single external process"

0
 

Author Comment

by:ISIGest
Comment Utility
Thanks a lot. I like it and i think that is my solution...can you post a simple program to do this?
0
 

Author Comment

by:ISIGest
Comment Utility
I've found a solution like this but in VB, can anyone help me to translate it to Delphi language:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21083100.html
0
 
LVL 2

Expert Comment

by:mannujam
Comment Utility
Not aware of delphi  :(
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
Comment Utility
Well, I posted a Delphi example already - see http://www.swissdelphicenter.ch/torry/showcode.php?id=1212
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

743 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

18 Experts available now in Live!

Get 1:1 Help Now