What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] API Help.

[?] API Help.
Author: Message:
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. [?] API Help.
how do i check if a window is not focussed and if it's not focussed it will flash?
[quote]
Ultimatess6
: What a noob mod
06-25-2007 03:23 AM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [?] API Help.
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.

This post was edited on 06-25-2007 at 09:05 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-25-2007 03:49 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] API Help.
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.
06-25-2007 04:40 AM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [?] API Help.
err..

how do i use this:

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

is it used correctly?

This post was edited on 06-26-2007 at 12:06 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
06-25-2007 10:51 PM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] API Help.
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 ;
}

.jpg File Attachment: GetForegroundWindow_Function.jpg (50.08 KB)
This file has been downloaded 274 time(s).

This post was edited on 06-26-2007 at 11:01 AM by matty.
06-26-2007 01:17 AM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [?] API Help.
go Matty :banana:

thanks :) i understand it much clearer

This post was edited on 06-26-2007 at 02:34 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
06-26-2007 02:33 AM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [?] API Help.
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;
}

;)
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-27-2007 11:34 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] API Help.
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.
06-28-2007 07:08 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On