quote:
Originally posted by roflmao456
err..
how do i use this:
code:
Interop.Call("user32","GetForegroundWindow",MyWnd.Handle)
is it used correctly?
Because you posted code and attempted it I will help you. However I am going to break down the MSDN article regarding this API Call.
We first look at the syntax itself:
quote:
Originally posted by http://msdn2.microsoft.com/en-us/library/ms633505.aspx
HWND GetForegroundWindow(VOID);
Now looking at the syntax we see that the function name is GetForegroundWindow and the parameters are VOID which means it does not accept any parameters. This is evident by the fact that there is no Parameters section in the documentation.
The next part we look at is the Return Value section
quote:
Originally posted by http://msdn2.microsoft.com/en-us/library/ms633505.aspx
Return Value
The return value is a handle to the foreground window. The foreground window can be NULL in certain circumstances, such as when a window is losing activation.
This shows that when you call the function the return value will be the handle of the foreground window.
With this all said the code you should be writing should call the function then compare it to the handle of the window.
If you are still confused here is the code. However I suggest trying to learn to understand this documentation from Microsoft as it helps and provides documentation on all of it's APIs.
code:
function CheckWindow(){
if (Interop.Call('user32', 'GetForegroundWindow') === pPlusWnd.Handle) {
return true;
} else { return false; }
}
Of course the code can always be shorted like this:
code:
function CheckWindow(){
return Interop.Call('user32', 'GetForegroundWindow') === pPlusWnd.Handle ? true : false ;
}