Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1191
  • Last Modified:

Get Message WM_ACTIVATE External Process

How i can get an event or windows messages in my application, when a external process's window is activate.
0
ISIGest
Asked:
ISIGest
  • 3
  • 3
  • 3
1 Solution
 
jkrCommented:
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
 
mannujamCommented:
WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus
0
 
ISIGestAuthor Commented:
Thanks, but i need to hook "many" forms of a single external process...how i can do it?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jkrCommented:
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
 
mannujamCommented:
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
 
ISIGestAuthor Commented:
Thanks a lot. I like it and i think that is my solution...can you post a simple program to do this?
0
 
ISIGestAuthor Commented:
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
 
mannujamCommented:
Not aware of delphi  :(
0
 
jkrCommented:
Well, I posted a Delphi example already - see http://www.swissdelphicenter.ch/torry/showcode.php?id=1212
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now