The following worked here. If your script is in a different directory, it will fail. Finding out is easy: open the script's window. This does not require admin privileges, so test without it.
Learning the value returned by
WinExist does not require any
If statement.
Code: Select all
#Requires AutoHotkey v2.0
F1:: {
DetectHiddenWindows True
MsgBox WinExist(A_Desktop '\closeme.ahk ahk_class AutoHotkey')
}
F2:: { ; Get list of running scripts
DetectHiddenWindows True
out := ''
n := 0
For hWnd in WinGetList('ahk_class AutoHotkey')
If !InStr(title := WinGetTitle(hWnd), '\launcher.ahk') {
out .= RegExReplace(title, ' - AutoHotkey v.+') '`n`n'
n++
}
MsgBox Trim(out, '`n'), 'Running scripts (N=' n ')', 'Iconi'
}