Shoutbox

[?] API Help. - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] API Help. (/showthread.php?tid=75610)

[?] API Help. by roflmao456 on 06-25-2007 at 03:23 AM

how do i check if a window is not focussed and if it's not focussed it will flash?


RE: [?] API Help. by CookieRevised on 06-25-2007 at 03:49 AM

Search the msdn library for "focus window" and "flash window".

(you can also start by searching the script forums, as both APIs are already several times used and talked about).

;)

sorry for not giving you a straitstraight answer, but... well you know... The msdn libary is the first thing to search in cases like this, and the search is very strait forward and easy. The above searches will give you the answer in seconds/minutes with a bit of reading.


RE: [?] API Help. by matty on 06-25-2007 at 04:40 AM

quote:
Originally posted by roflmao456
how do i check if a window is not focussed and if it's not focussed it will flash?
Look at the API calls for

GetForegroundWindow and FlashWindow or FlashWindowEx.
RE: [?] API Help. by roflmao456 on 06-25-2007 at 10:51 PM

err..

how do i use this:

code:
Interop.Call("user32","GetForegroundWindow",MyWnd.Handle)

is it used correctly?
RE: [?] API Help. by matty on 06-26-2007 at 01:17 AM

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.

[Image: attachment.php?pid=831103]

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

RE: [?] API Help. by roflmao456 on 06-26-2007 at 02:33 AM

go Matty :banana:

thanks :) i understand it much clearer


RE: [?] API Help. by CookieRevised on 06-27-2007 at 11:34 PM

quote:
Of course the code can always be shorted like this:
code:
function CheckWindow(){
        return Interop.Call('user32', 'GetForegroundWindow') === pPlusWnd.Handle ? true : false ;
}

The expression used in the tenary check already returns true or false, therefore no need for putting it into a tenary check in the first place. (and parameter pPlusWnd is missing)

=>>>>
code:
function CheckWindow(pPlusWnd){
        return Interop.Call('user32', 'GetForegroundWindow') === pPlusWnd.Handle;
}

;)
RE: [?] API Help. by matty on 06-28-2007 at 07:08 PM

quote:
Originally posted by CookieRevised
The expression used in the tenary check already returns true or false, therefore no need for putting it into a tenary check in the first place. (and parameter pPlusWnd is missing)

=>>>>
code:
function CheckWindow(pPlusWnd){
        return Interop.Call('user32', 'GetForegroundWindow') === pPlusWnd.Handle;
}

;)
Good point I thought this was something you were going to add when I saw you had posted in the thread.

I was assuming he had already declared pPlusWnd else where that is why it wasn't passed as a parameter.

I hope roflmao456 can figure out the other ones on his own tho.