I'm writing a little joke program in Autohotkey, and I want it to close specific applications if they're opened/already open. for example, for notepad, I tried:
Loop
{
WinWait,Untitled - Notepad
WinClose,Untitled - Notepad
}
This didn't work for me. neither did this:
#Persistent
SetTimer, ClosePopup, 50
return
ClosePopup:
WinClose, Untitled - Notepad
return
What am I doing wrong? When I open notepad, it stays open. I've tried this with other applications such as wordpad, sublime text, and taskmgr, to no avail. I'm sure this has been asked before, but the difference here is that I've already got code that should do the trick, but for some reason it isn't working.
答案 0 :(得分:0)
If Not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
Loop
{
WinClose, ahk_class Notepad
sleep 100
}