Set focus onto a specific window using VBScript

2

Is there a way to set the focus onto a specific window using VBScript ?

Window name should be settable by something. (Not an additional program such as AutoIT or so)

(Windows 7 Pro)

eckhart

Posted 2016-06-06T07:34:50.670

Reputation: 881

1Yes it is possible, but please note, we're not a "please write me a script" kind of site. Can you share us your research, and we'll help you point out where things aren't working as expected. – LPChip – 2016-06-06T07:51:15.240

Answers

3

AppActivate method available in VBScript can do this

Example to focus on Notepad is below:

Dim ObjShell :Set ObjShell = CreateObject("Wscript.Shell")
ObjShell.AppActivate("Notepad")

You can also wrap this around an HTA application to set program on the fly.

pun

Posted 2016-06-06T07:34:50.670

Reputation: 5 311