Shoutbox

[Help] Enumerate all windows. - 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: [Help] Enumerate all windows. (/showthread.php?tid=90126)

[Help] Enumerate all windows. by Emblem on 04-12-2009 at 01:17 AM

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


RE: [Help] Enumerate all windows. by matty on 04-12-2009 at 01:26 AM

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


RE: [Help] Enumerate all windows. by Emblem on 04-12-2009 at 01:27 AM

Thank you! Your now my favorite person :P


RE: [Help] Enumerate all windows. by matty on 04-12-2009 at 01:33 AM

Not a problem its what we are here for.


RE: [Help] Enumerate all windows. by Emblem on 04-12-2009 at 01:38 AM

Hmm.
It gave me an error about procedure not being defined on the line:

Javascript code:
var l = Interop.Alocate('user32', 'GetWindowTextLengthW', hWnd);

I fixed that, it's actully:
Javascript code:
var l = Interop.Call('user32', 'GetWindowTextLengthW', hWnd);


Just posting this for anyone else that wants to use this post as a reference.