HurleyShanabarger Posted June 10, 2020 Share Posted June 10, 2020 If you need to check if a script in a3x format is running, the following function can be used: expandcollapse popup#Region Includes #include <WinAPIProc.au3> #EndRegion Includes #Region Main _Main() Func _Main() Local $boExists = _ProcessExists_A3X("Example.a3x") MsgBox(0, "A3X-Check", "Count: " & @extended & @TAB & $boExists) EndFunc ;==>_Main #EndRegion Main #Region Functions Func _ProcessExists_A3X($sProcess, $iReturn = 0) ;--------------------------------------------------------------------------------------------------------------- ; Get process list and create string containing process name & ID ;--------------------------------------------------------------------------------------------------------------- Local $aProcessList = ProcessList(), $sProcessList, $iProcess If @error Then Return SetError(0x01, "", False) For $iProcess = 1 To UBound($aProcessList) - 1 $sProcessList &= $aProcessList[$iProcess][0] & "|" & $aProcessList[$iProcess][1] & @CRLF Next ;--------------------------------------------------------------------------------------------------------------- ; Get window list ;--------------------------------------------------------------------------------------------------------------- Local $aWinList = WinList("[class:AutoIt v3]", "") If @error Then Return SetError(0x02, "", False) ; Loop trough all windows Local $iWindow Local $aCmdLine, $sCmdLine Local $iCount For $iWindow = 0 To UBound($aWinList) - 1 ; Get process belonging to windows $iProcess = WinGetProcess($aWinList[$iWindow][1]) If $iProcess < 0 Then ContinueLoop ; Find process name in list StringRegExpReplace($sProcessList, "(?ms).*\r\n([^\|]+)\|" & $iProcess & "\b.*", "$1", 0) If Not @extended Then ContinueLoop ; Get command line as it should contain filepath $sCmdLine = _WinAPI_GetProcessCommandLine($iProcess) $aCmdLine = StringRegExp($sCmdLine, ".*\Q" & $sProcess & "\E.*", 3) If @error Then ContinueLoop $iCount += 1 Next If $iCount Then Return SetExtended($iCount, True) Return SetError(0x03, 0, False) EndFunc ;==>_ProcessExists_A3X #EndRegion Functions dogisay and MarkIT 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now