youtuber Posted April 22, 2021 Share Posted April 22, 2021 I run my program simultaneously with PureBasic and this causes an error The mutex code I used for PureBasic LockStr$ = "Pro.exe" If CreateMutex_(0,1,LockStr$)=0 Or GetLastError_()<>0 : Beep_(3000,100) MessageRequester("Already working", LockStr$+ " Already working....") End EndIf my autoit codes expandcollapse popup#include <WinAPI.au3> Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") If UBound(ProcessList(@ScriptName)) > 2 Then MsgBox(16, "Already running", @ScriptName & @CRLF & _ " The program is already running!!!..", 2) Exit 0 EndIf Local $Array[5] = [1, 2, 3, 4, 5] While 1 Local $StackVariable1 = "" Sleep(100) For $i = 0 To UBound($Array) - 1 $iRandom1 = Random(0, $Array[$i], 1) If StringInStr($iRandom1, "3") Then $StackVariable1 &= $iRandom1 & @CRLF ConsoleWrite("$StackVariable1 : " & $StackVariable1 & @CRLF) EndIf Next While 2 Local $StackVariable2 = "" Sleep(200) For $i2 = 0 To UBound($Array) - 1 $iRandom2 = Random(0, $Array[$i2], 1) If StringInStr($iRandom2, "4") Then $StackVariable2 &= $iRandom2 & @CRLF ConsoleWrite("$StackVariable2 : " & $StackVariable2 & @CRLF) EndIf Next If $StackVariable1 <> $StackVariable2 Then If Not $StackVariable2 = "" Then _WinAPI_MessageBeep(5) Sleep(2000) TrayTip("$StackVariable2", $StackVariable2, 30, 1) Sleep(2000) ExitLoop EndIf EndIf WEnd WEnd Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc https://prnt.sc/11tr9nm Func _winapi_openmutex($smutex, $iaccess = $mutex_all_access, $binherit = False) Local $aret = DllCall("kernel32.dll", "handle", "OpenMutexW", "dword", $iaccess, "bool", $binherit, "wstr", $smutex) If @error Then Return SetError(@error, @extended, 0) Return $aret[0] ; Line 13188 EndFunc 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