Monday 16 December 2019

batch - Set focus onto a specific window using VBScript


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)



Answer



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.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...