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

[Help] Enumerate all windows.
Author: Message:
Emblem
New Member
*

Avatar

Posts: 7
32 / Male / Flag
Joined: Jan 2007
O.P. [Help] Enumerate all windows.
Is there any way to enumerate all open windows and store the titles of each window?

I know it involves api calls and I'm horrible with them so any help is appreciated ><

Thanks! XD
The ninja coder.
04-12-2009 01:17 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Help] Enumerate all windows.
js code:
var oWindows = {}

function __enum () {
    Interop.Call('user32', 'EnumWindows', Interop.GetCallbackPtr('EnumWindowsProc'), 0);
    for (var oWindow in oWindows) {
        Debug.Trace(oWindow+' : '+oWindows[oWindow]);
    }
}

function EnumWindowsProc(hWnd, lParam) {
    oWindows[hWnd] = GetWindowTitle(hWnd);
    return true;
}

function GetWindowTitle(hWnd) {
    var l = Interop.Alocate('user32', 'GetWindowTextLengthW', hWnd);
    var s = Interop.Allocate(l*2+2)
    Interop.Call('user32', 'GetWindowTextW', hWnd, s, l);
    return s.ReadString(0);
}
04-12-2009 01:26 AM
Profile E-Mail PM Find Quote Report
Emblem
New Member
*

Avatar

Posts: 7
32 / Male / Flag
Joined: Jan 2007
O.P. RE: [Help] Enumerate all windows.
Thank you! Your now my favorite person :P
The ninja coder.
04-12-2009 01:27 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Help] Enumerate all windows.
Not a problem its what we are here for.

This post was edited on 04-12-2009 at 01:33 AM by matty.
04-12-2009 01:33 AM
Profile E-Mail PM Find Quote Report
Emblem
New Member
*

Avatar

Posts: 7
32 / Male / Flag
Joined: Jan 2007
O.P. RE: [Help] Enumerate all windows.
Hmm.
It gave me an error about procedure not being defined on the line:
js code:
var l = Interop.Alocate('user32', 'GetWindowTextLengthW', hWnd);
I fixed that, it's actully:
js code:
var l = Interop.Call('user32', 'GetWindowTextLengthW', hWnd);

Just posting this for anyone else that wants to use this post as a reference.
The ninja coder.
04-12-2009 01:38 AM
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