Jump to content

Search the Community

Showing results for tags 'Timers'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 6 results

  1. We have here a working script (Found on this forum - someone said its best way to set timers) I want to set timers in my program cause AdLibRegister crashes, infinite loops etc. Its a working small program to test these timers below. #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Global $iMemo _Main() Func _Main() Global $hGUI Global $timerID1 = 1, $timerID2 = 2 Global $callBackFunc1, $callBackFunc2 Global $timerName1, $timerName2 $hGUI = GUICreate("My Timers", 400, 296) $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() setTimer($callBackFunc1, $timerName1, $timerID1, 1000, 'hello') setTimer($callBackFunc2, $timerName2, $timerID2, 2000, 'hello2') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd killTimer($timerName1, $callBackFunc1) killTimer($timerName2, $callBackFunc2) EndFunc ;==>_Main ; ================= MY FUNCS ============================ Func setTimer(ByRef $callBackFunc, ByRef $timerName, $timerID = 1, $time = 1000, $funcName = 'hello') $callBackFunc = DllCallbackRegister($funcName, "none", "hwnd;int;int;dword") $timerName = _WinAPI_SetTimer($hGUI, $timerID, $time, DllCallbackGetPtr($callBackFunc)) EndFunc Func killTimer($timerName, $callBackFunc) _WinAPI_KillTimer($hGUI, $timerName) DllCallbackFree($callBackFunc) EndFunc ; ============================================= ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func _WinAPI_KillTimer($hWnd, $iIDEvent) Local $iResult = DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int", $iIDEvent) If @error Then Return SetError(-1, -1, 0) Return $iResult[0] <> 0 EndFunc ;==>_WinAPI_KillTimer Func _WinAPI_SetTimer($hWnd, $iIDEvent, $iElapse, $pTimerFunc = 0) Local $iResult = DllCall("user32.dll", "int", "SetTimer", "hwnd", $hWnd, "int", $iIDEvent, "int", $iElapse, "ptr", $pTimerFunc) If @error Then Return SetError(-1, -1, 0) Return $iResult[0] EndFunc ;==>_WinAPI_SetTimer Func _TimerCallBackFunc($hWnd, $Msg, $iIDTimer, $dwTime) MemoWrite("Timer " & $iIDTimer & " Fired") For $i = 999 To 1 Step -1 ConsoleWrite($i & @CRLF) Next EndFunc ;==>_TimerCallBackFunc ; ============== Funs to call =============================== Func hello($hWnd, $nMsg, $iIDTimer, $dwTime) MemoWrite("Timer " & $iIDTimer & " Fired") For $i = 999 To 1 Step -1 ConsoleWrite($i & @CRLF) Next EndFunc ;==>_TimerCallBackFunc Func hello2($hWnd, $nMsg, $iIDTimer, $dwTime) MemoWrite("Timer " & $iIDTimer & " Fired") For $i = 999 To 1 Step -1 ConsoleWrite($i & @CRLF) Next EndFunc ;==>_TimerCallBackFunc And i wanted to apply these timers to my final program. I get error: error: doingThings() called by a previous line with 0 arg(s). Min = 4. First previous line calling this Func is 31. Func doingThings($hWnd, $nMsg, $iIDTimer, $dwTime) There are pieces of code below: There I replaced AdlibRegister by setTimer and calling it like in previous working program (just doingThings in last param in setTimer function) Func r_offOn_doingThings() If _Metro_CheckboxIsChecked($r_offOn_doingThings) Then _Metro_CheckboxUnCheck($r_offOn_doingThings) ;AdlibUnRegister("doingThings") killTimer($timerName1, $callBackFunc1) Else If _checkDeclared(True,False) == False Then ; check if is declared to run func (HP,TITLE,REGION)- core_funcs Else _Metro_CheckboxCheck($r_offOn_doingThings) setTimer($callBackFunc1, $timerName1, 1, 1600, "doingThings") ;AdlibRegister("doingsThings", 1800) EndIf EndIf EndFunc And function name with params looks like this Func doingThings($hWnd, $nMsg, $iIDTimer, $dwTime) EndFunc #include Timers.au3 #CS THere are globals vars: globalVariables/timers ByRef $callBackFunc: var ByRef $timerName: var $timerID = 1: var ID $time = 1000: how often call func $funcName: function to call #CE Global $timerID1 = 1, $timerID2 = 2 Global $callBackFunc1, $callBackFunc2 Global $timerName1, $timerName2 Func setTimer(ByRef $callBackFunc, ByRef $timerName, $timerID = 1, $time = 1000, $funcName = "doingThings") $callBackFunc = DllCallbackRegister($funcName, "none", "hwnd;int;int;dword") $timerName = _WinAPI_SetTimer($GUI, $timerID, $time, DllCallbackGetPtr($callBackFunc)) EndFunc Func killTimer($timerName, $callBackFunc) _WinAPI_KillTimer($GUI, $timerName) DllCallbackFree($callBackFunc) EndFunc Func _WinAPI_KillTimer($hWnd, $iIDEvent) Local $iResult = DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int", $iIDEvent) If @error Then Return SetError(-1, -1, 0) Return $iResult[0] <> 0 EndFunc ;==>_WinAPI_KillTimer Func _WinAPI_SetTimer($hWnd, $iIDEvent, $iElapse, $pTimerFunc = 0) Local $iResult = DllCall("user32.dll", "int", "SetTimer", "hwnd", $hWnd, "int", $iIDEvent, "int", $iElapse, "ptr", $pTimerFunc) If @error Then Return SetError(-1, -1, 0) Return $iResult[0] EndFunc ;==>_WinAPI_SetTimer Thats it. And why in first working program it does not say this function below is calling with 0 args but Min is 4? setTimer($callBackFunc1, $timerName1, 1, 1600, "doingThings") When I applied this code to my final program it wants 4 arguments in function call. I rode i cant pass parameters to the callback func . What I have to do. I tried something like this: Func doingThings($hWnd = Default, $nMsg = Default, $iIDTimer = Default, $dwTime = Default) but then function is not working dont know whats going on
  2. Is there any difference in timers and AdlibRegister ? in : performance usage reliability or any kind of difference I want use few timers at once so it will make difference. I have problem with timers and I saw AdlibRegister behaves similar like: wont stop crashing slowing program so much maybe is there any trick to make it better?
  3. Hello I got errors and timers not work if I use any obfuscator(stripper). All code and things work great after obfuscate but functions with timers dont. -### StripOnly/StripFunc Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by this Function. Here are scripts U can try use stripper then functions would not work https://www.autoitscript.com/autoit3/docs/libfunctions/_Timer_SetTimer.htm Here is written I believe something on this topic https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/Au3Stripper.html Could I do something with that? I got several functions with timers and I dont want use ignore these functions #Au3Stripper_Ignore_Funcs=
  4. I do my timers like this by clicking checkbox function is called and timer is set up. There is a trouble cause I got so many Timers, 20 like this below and I can see if they is launched 5 timers program starts freezing and often crashing. I know it takes memory but is is right way to do timers like that or what should i do? Case $checkerSS If GUICtrlRead($CheckerOne) = 1 Then $ss = _Timer_SetTimer($Form1,4000,"checkScreen") Else _Timer_KillTimer ($Form1,$ss) EndIf Case $checkerPos If GUICtrlRead($DiscAlert) = 1 Then $disc = _Timer_SetTimer($Form1,20000,"checkPosition") Else _Timer_KillTimer ($Form1,$disc) EndIf Case $checkerVars If GUICtrlRead($AlertPlayerPos) = 1 Then $ap = _Timer_SetTimer($Form1,15000,"checkVars") Else _Timer_KillTimer ($Form1,$ap) EndIf
  5. Here is my wrapper for SetTimer and KillTimer APIs. AutoIt already has its own, but I tried to make it as simple as I could. #include-once Global $g_avSimpleTimers = [[0, 0]] Func TimerSet($vFunction, $uInterval) Local $hFunction = DllCallbackRegister($vFunction, "none", "HWND;UINT;UINT_PTR;DWORD") If ($hFunction = 0) Then Return 0 Local $uTimerId = DllCall("user32.dll", "UINT_PTR", "SetTimer", _ "HWND", 0, _ "UINT_PTR", 0, _ "UINT", $uInterval, _ "ptr", DllCallbackGetPtr($hFunction))[0] If ($uTimerId = 0) Then DllCallbackFree($hFunction) Return 0 EndIf ReDim $g_avSimpleTimers[$g_avSimpleTimers[0][0] + 2][2] $g_avSimpleTimers[$g_avSimpleTimers[0][0] + 1][0] = $uTimerId $g_avSimpleTimers[$g_avSimpleTimers[0][0] + 1][1] = $hFunction $g_avSimpleTimers[0][0] += 1 Return $uTimerId EndFunc Func TimerUnset($uTimerId) If ($g_avSimpleTimers[0][0] = 0) Then Return False Local $iCount = $g_avSimpleTimers[0][0] For $i = 1 To $iCount + 1 If ($g_avSimpleTimers[$i][0] = $uTimerId) Then DllCall("user32.dll", "BOOL", "KillTimer", _ "HWND", 0, _ "UINT_PTR", $uTimerId) DllCallbackFree($g_avSimpleTimers[$i][1]) For $j = $i To $iCount - 1 $g_avSimpleTimers[$j][0] = $g_avSimpleTimers[$j + 1][0] $g_avSimpleTimers[$j][1] = $g_avSimpleTimers[$j + 1][1] Next $g_avSimpleTimers[0][0] = $iCount - 1 ReDim $g_avSimpleTimers[$iCount][2] Return True EndIf Next Return False EndFunc Example: #include "Simple Timers.au3" Global $t1 = TimerSet(Foo, 500) Global $t2 = TimerSet("Bar", 1000) MsgBox(0, "", "Check the console.") TimerUnset($t1) MsgBox(0, "", "Check the console again.") TimerUnset($t2) ;Not necessary if you are exiting the script Func Foo($a, $b, $c, $d) ConsoleWrite(">Foo" & @CRLF) EndFunc Func Bar($a, $b, $c, $d) ConsoleWrite("!Bar" & @CRLF) EndFunc Download both UDF and example:
  6. So I have some timers which I reset periodically, but my problem is that they don't wait for the functions before them to finish and in a strange way reset beforehand. -snip- timerinit doesnt wait the mouseclick and sleep functions to finish
×
×
  • Create New...