Using AutoIt 3, is there a way to pass additional arguments to the callback method in the _Timer_SetTimer
function?
Here's my use case (main loop) :
For $item In $items
_Timer_SetTimer(0, $timeOffset, "MyMethod")
Next
Callback method :
Func MyMethod($hWnd, $iMsg, $iTimerID, $iTime)
_Timer_KillTimer ( $hWnd, $iTimerID )
// Do something on $item
EndFunc
I tried using a Global
variable, but every single instance of MyMethod
then uses the last value. I did it this way :
Global $currentItem
For $item In $items
$currentItem = $item
_Timer_SetTimer(0, $timeOffset, "MyMethod")
Next
Func MyMethod($hWnd, $iMsg, $iTimerID, $iTime)
_Timer_KillTimer ( $hWnd, $iTimerID )
$item = $currentItem
// Do something on $item
EndFunc
So, am I doing it wrong or is there a way to pass argument directly? Thanks.