The Firefox
is quite problematic in this respect.
Here is the best work out I was reach with VBScript
.
Firefox = """c:\path to\firefox.exe"""
Set oShell = CreateObject("WScript.Shell")
Set oFFox = oShell.Exec(Firefox)
WScript.Sleep 1000
oShell.AppActivate oFFox.ProcessID
WScript.Sleep 1000
oShell.SendKeys "% (n)" ' minimize (Alt+SpaceBar,n)
WScript.Sleep 10 * 1000 ' wait 10 seconds
'next AppActivate call need Full and Exact title
oShell.AppActivate "Mozilla Firefox Start Page - Mozilla Firefox"
WScript.Sleep 1000
'oShell.SendKeys "% (r)" ' restore (Alt+SpaceBar,r)
oShell.SendKeys "%{F4}" ' close (Alt+F4)
P.S. Actually, restore command is redundant (I comment out that line).
Note that I not use oShell.AppActivate oFFox.ProcessID
nor yet oFFox.Terminate
because after minimize process both not work for me, therefore I use the title for the AppActivate
and SendKeys
to close the application.