Is there a way to get access to a window handle in windows using WSH, or WMI or similar? I just want to flag a window as always-on-top. Ideally I'd use windows script host for this.
(Should also be tagged as WSH).
To grab it with WSH, you can use the COM DLL found in this CodeProject article. Using this, you can then grab a window handle like so:
This is also very easy in PowerShell.
This grab's the window handle of the PowerShell process.
Although if your main goal is to make a window topmost, there are many programs for this such as DeskPins:
have a look at Eusing's Auto Window Manager. not only can you automatically keep all windows you specify always on top but you can also apply transparency effects from 0% (fully transparent) to 100% (solid).
Auto Window Manager is freeware.
I know it's a massive necro and pardon if it was solved already, but I've been struggling with it for some time now and here's a really simple solution I wrote:
Returns "0" if window wasn't found, or the window handle. If found more windows matching the $winTitle string it returns the $instance number (0 means first window, 1 second, etc.).