John117 Posted March 14, 2009 Share Posted March 14, 2009 (edited) Hey, Im trying to learn how this works. What is wrong with what I have written here? #Include <Timers.au3> $hWnd = GUICreate("Window", 500, 700, Default, Default) GUISetState(@SW_SHOW) _Timer_SetTimer($hWnd, 3000, "somefunc", -1) While 1 Sleep(10) WEnd Func somefunc() Msgbox(0,"","Working") EndFunc Edited March 14, 2009 by Hatcheda Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 14, 2009 Moderators Share Posted March 14, 2009 Hatcheda,You need to add the parameters to the function - just like in GUIRegisterMsg:#Include <Timers.au3> $hWnd = GUICreate("Window", 500, 700, Default, Default) GUISetState(@SW_SHOW) _Timer_SetTimer($hWnd, 3000, "somefunc", -1) While 1 Sleep(10) WEnd Func somefunc($hWnd, $iMsg, $iwParam, $ilParam) Msgbox(0,"","Working") EndFuncM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
John117 Posted March 14, 2009 Author Share Posted March 14, 2009 Thank you! I can see how that would work now! :-) Link to comment Share on other sites More sharing options...
John117 Posted March 14, 2009 Author Share Posted March 14, 2009 ok, based on that, is there any info from the timer that could be used to identify it? Purpose being the function would be a switch and behave differently if a 3 second timer called it than a 6 second timer. #Include <Timers.au3> $hWnd = GUICreate("Window", 500, 700, Default, Default) GUISetState(@SW_SHOW) _Timer_SetTimer($hWnd, 3000, "somefunc", -1) _Timer_SetTimer($hWnd, 6000, "somefunc", -1) While 1 Sleep(10) WEnd Func somefunc($hWnd, $iMsg, $iwParam, $ilParam) Msgbox(0,"","Working") EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 14, 2009 Moderators Share Posted March 14, 2009 Hatcheda,From that same Help file that showed the need for parameters:_Timer_GetTimerID - Returns the Timer ID from $iwParamM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
John117 Posted March 14, 2009 Author Share Posted March 14, 2009 Sorry, was testing them all out. I was only up to $iMsg when I asked that #Include <Timers.au3> HotKeySet("{ESC}", "TerminateApp") $hWnd = GUICreate("Window", 500, 700, Default, Default) GUISetState(@SW_SHOW) _Timer_SetTimer($hWnd, 3000, "somefunc", -1) _Timer_SetTimer($hWnd, 6000, "somefunc", -1) While 1 Sleep(10) WEnd Func somefunc($hWnd, $iMsg, $iwParam, $ilParam) Msgbox(0,"","Working" & $iMsg & " " & $iwParam & " " & $ilParam) EndFunc Func TerminateApp() _Timer_KillAllTimers($hWnd) GUIDelete() Exit 0 EndFunc ;==>TerminateApp Link to comment Share on other sites More sharing options...
John117 Posted March 14, 2009 Author Share Posted March 14, 2009 Ok, Here ya go! Completed as demo -now I can use it in my scripts. #include <Timers.au3> HotKeySet("{ESC}", "TerminateApp") $hWnd = GUICreate("Window", 500, 700, Default, Default) GUISetState(@SW_SHOW) _Timer_SetTimer($hWnd, 3000, "somefunc", -1) _Timer_SetTimer($hWnd, 6000, "somefunc", -1) _Timer_SetTimer($hWnd, 9000, "somefunc", -1) While 1 Sleep(10) WEnd Func somefunc($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case 1001 MsgBox(0, "", "3Sec") Case 1002 MsgBox(0, "", "6Sec") Case 1003 MsgBox(0, "", "9Sec") EndSwitch EndFunc ;==>somefunc Func TerminateApp() _Timer_KillAllTimers($hWnd) GUIDelete() Exit 0 EndFunc ;==>TerminateApp Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 15, 2009 Moderators Share Posted March 15, 2009 Hatcheda,It would be even better if you were to save the ControlIDs of the timers and use those variables in the Switch: ;-)#include <Timers.au3> HotKeySet("{ESC}", "TerminateApp") $hWnd = GUICreate("Window", 500, 700, Default, Default) GUISetState(@SW_SHOW) $hTimer1 = _Timer_SetTimer($hWnd, 3000, "somefunc", -1) $hTimer2 = _Timer_SetTimer($hWnd, 6000, "somefunc", -1) $hTimer3 = _Timer_SetTimer($hWnd, 9000, "somefunc", -1) While 1 Sleep(10) WEnd Func somefunc($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $hTimer1 MsgBox(0, "", "3Sec") Case $hTimer2 MsgBox(0, "", "6Sec") Case $hTimer3 MsgBox(0, "", "9Sec") EndSwitch EndFunc ;==>somefunc Func TerminateApp() _Timer_KillAllTimers($hWnd) GUIDelete() Exit 0 EndFunc ;==>TerminateAppM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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