Reputation: 1
I run a batch file as part of Windows XP startup which executes continuously until Windows closes. It calls a VBScript file, which executes SendKeys "+{ESC}"
(Shift+Esc). This gets picked up by 4t Tray Minimiser to send the CMD window to the system tray. Most times it works, but occasionally the CMD window stays visible.
Upon searching, various posts seem to suggest the .VBS file is losing focus or it's a timing problem. Some suggest AppActivate
but I can't work out how to achieve what I want. Even the examples given for AppActivate
seem like a lot of work.
Upvotes: 0
Views: 2942
Reputation: 200523
Did you check the documentation? It's actually rather straightforward. You call AppActivate
with the title (or part of the title) of the window you want to bring to the foreground, then run SendKeys
to send keystrokes to the foreground window.
Set sh = CreateObject("WScript.Shell")
sh.AppActivate "window title"
sh.SendKeys "+{Esc}"
Upvotes: 1