Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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).

Regards,

share|improve this question
    
added WSH tag for ya –  John T Nov 24 '09 at 5:15
add comment

2 Answers

up vote 2 down vote accepted

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:

Set obj = CreateObject("APIWrapperCOM.APIWrapper")
winHandle = obj.FindWindow("test.txt - Notepad")

This is also very easy in PowerShell.

example:

(Get-Process powershell).MainWindowHandle

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:

alt text

share|improve this answer
    
Thanks John, but I'm ideally after a .VBS solution. We're a bit nervous about what we run on this particular machine and have other VBS files running as part of the system. –  Jotham Nov 24 '09 at 5:17
    
Ah well, I tried. Thought this might fall into the "or similar" category :P –  John T Nov 24 '09 at 5:19
    
added a WSH solution :) –  John T Nov 24 '09 at 5:23
add comment

I just want to flag a window as always-on-top.

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.