Trying to make advance SingleInstance force
Posted: 08 Feb 2018, 09:41
Hi All,
I have a same script in different folders, when i run scripts one by one, they all started running, even though they have same name.
i think it's because of the nature of #SingleInstance force, It cant close the previous script with the same name if it's in the different folder.
I try to do that with the below script i found but it's not working can anyone tell me what i'm doing wrong here.
I have a same script in different folders, when i run scripts one by one, they all started running, even though they have same name.
i think it's because of the nature of #SingleInstance force, It cant close the previous script with the same name if it's in the different folder.
I try to do that with the below script i found but it's not working can anyone tell me what i'm doing wrong here.
Code: Select all
#SingleInstance force
#Persistent
SetWorkingDir, %A_ScriptDir%
DetectHiddenWindows, On
SetTitleMatchMode, 2
WinGet, vWinList, List, \Test.ahk ahk_class AutoHotkey
Loop, % vWinList
{
hWnd := vWinList%A_Index%
;WinGetTitle, vWinTitle, % "ahk_id " hWnd
;WinGetClass, vWinClass, % "ahk_id " hWnd
;WinGet, vPID, PID, % "ahk_id " hWnd
if !(hWnd = A_ScriptHwnd)
WinClose, % "ahk_id " hWnd
}
Msgbox, running