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:
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 277 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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[?] API Help. - by roflmao456 on 06-25-2007 at 03:23 AM
RE: [?] API Help. - by CookieRevised on 06-25-2007 at 03:49 AM
RE: [?] API Help. - by matty on 06-25-2007 at 04:40 AM
RE: [?] API Help. - by roflmao456 on 06-25-2007 at 10:51 PM
RE: [?] API Help. - by matty on 06-26-2007 at 01:17 AM
RE: [?] API Help. - by roflmao456 on 06-26-2007 at 02:33 AM
RE: [?] API Help. - by CookieRevised on 06-27-2007 at 11:34 PM
RE: [?] API Help. - by matty on 06-28-2007 at 07:08 PM


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