You can use the SendKeys
method to send the Alt+F4 shortcut to the window you wish to close. This window must be active at the moment, so you also need to call AppActivate
right before SendKeys
.
Basically, you'll need something like this:
Set oShell = CreateObject("WScript.Shell")
oShell.AppActivate "Untitled - Notepad"
oShell.SendKeys "%{F4}"
You may want to add checks and small delays to make your script more foolproof:
Set oShell = CreateObject("WScript.Shell")
If oShell.AppActivate("Untitled - Notepad") Then
WScript.Sleep 500
oShell.SendKeys "%{F4}"
End If
Edit: (An answer to your comment/question about VBScript resources.)
I've compiled some links to VBScript websites and resource pages that I hope they will be helpful:
Learning
References
Other resources
As for VBScript resources in Russian, check out script-coding.info and Серый форум — there're lots of useful and interesting examples. Also, take a look at the this thread, which contains links to many VBScript resources, including those in Russian.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…