Axufuris Posted July 18, 2008 Share Posted July 18, 2008 I had a couple things i was wondering about. Number one: I am trying to disable GUI componants from the user using them depending on the situation. Now i did use "GUICtrlSetState($MYGUI_StopButton, "Disable")" but that doesn't seem to gray it out and keep the user from being able to press it. Is there a way to disable it the way delphi or VS disables buttons? Number 2: I am needing to put a simple timer in and was wondering if there was anytype of built in timer function in Autoit? And if not, can somebody help me out with it? Link to comment Share on other sites More sharing options...
youknowwho4eva Posted July 18, 2008 Share Posted July 18, 2008 I'm actually shocked this worked but I made this simple timer that waits for your system clock to change one minute, so its not actually a minute timer, its from what ever time its started till the minutes change. But you said simple :-D $timer = @MIN while 1 If @min = $timer + 1 Then MsgBox(0, "", "1 minute") Exit EndIf WEnd But here's one that will actually wait 1 minute $minutes = @MIN $seconds = @SEC while 1 If @min = $minutes + 1 and @sec = $seconds Then MsgBox(0, "", "1 minute") Exit EndIf WEnd Just tested the latter, I'm so proud of me self. Giggity Link to comment Share on other sites More sharing options...
Axufuris Posted July 18, 2008 Author Share Posted July 18, 2008 I'm actually shocked this worked but I made this simple timer that waits for your system clock to change one minute, so its not actually a minute timer, its from what ever time its started till the minutes change. But you said simple :-D $timer = @MIN while 1 If @min = $timer + 1 Then MsgBox(0, "", "1 minute") Exit EndIf WEnd But here's one that will actually wait 1 minute $minutes = @MIN $seconds = @SEC while 1 If @min = $minutes + 1 and @sec = $seconds Then MsgBox(0, "", "1 minute") Exit EndIf WEnd Just tested the latter, I'm so proud of me self. That is a very interesting way to do it, it does work though. And i needed it by mins anyways. I just needed to see if 1 min passed or 2 or 3 until i hit what i want then i stop it. So thanks. Now just got to see if anyone can awnser the second question muttley Link to comment Share on other sites More sharing options...
youknowwho4eva Posted July 18, 2008 Share Posted July 18, 2008 _GUICtrlToolbar_GetDisabledImageList Try looking up that in the help file, it looks promising. Giggity Link to comment Share on other sites More sharing options...
JFee Posted July 18, 2008 Share Posted July 18, 2008 Didn't quite see an answer to your first question. $GUI_DISABLE is what you should use in the guictrlsetstate line. Also, the TimerInit() and TimerDiff() functions are built in and work well. TimerInit starts the timer, and TimerDiff gets the time that has passed since you caled TimerInit Regards,Josh Link to comment Share on other sites More sharing options...
youknowwho4eva Posted July 18, 2008 Share Posted July 18, 2008 muttley way to sink my boat, lol, I'm still proud of myself for thinking that one up. and that sounds like it does what I made with a few subtractions. But now I know, and knowledge is power. Giggity Link to comment Share on other sites More sharing options...
Axufuris Posted July 18, 2008 Author Share Posted July 18, 2008 Didn't quite see an answer to your first question. $GUI_DISABLE is what you should use in the guictrlsetstate line.Also, the TimerInit() and TimerDiff() functions are built in and work well. TimerInit starts the timer, and TimerDiff gets the time that has passed since you caled TimerInitHey awesome thank you all. I appreciate it. I really am liking this language, Its a fun programing language to mess with. Link to comment Share on other sites More sharing options...
GaryFrost Posted July 18, 2008 Share Posted July 18, 2008 Another option, event fires off at timed intervals. #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <Timers.au3> Opt("MustDeclareVars", 1) Global $label _Example_CallBack() Func _Example_CallBack() Local $hGUI, $button, $iSecond = 1000, $numSeconds = 6 $hGUI = GUICreate("Timer Using CallBack Function", 400, 320) GUICtrlCreateLabel("Callback Function fired: ", 10, 10, 120) $label = GUICtrlCreateLabel("0", 125, 10, 20) $button = GUICtrlCreateButton("Exit", 10, 50, 90) _Timer_SetTimer($hGUI, $iSecond * $numSeconds, "_UpdatedLabel") ; create timer GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button ExitLoop EndSwitch WEnd ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @LF) GUIDelete() EndFunc ;==>_Example_CallBack ; call back function Func _UpdatedLabel($hWnd, $Msg, $iIDTimer, $dwTime) #forceref $hWnd, $Msg, $iIDtimer, $dwTime GUICtrlSetData($label, Int(GUICtrlRead($label)) + 1) EndFunc ;==>_UpdatedLabel SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
youknowwho4eva Posted July 18, 2008 Share Posted July 18, 2008 I'm suprised you didn't go with expandcollapse popup; *** Demo to show a timer window #include <GUIConstantsEx.au3> #include <Date.au3> Opt("TrayIconDebug", 1) Opt("MustDeclareVars", 1) Global $timer, $Secs, $Mins, $Hour, $Time _Main() Func _Main() ;Create GUI GUICreate("Timer", 120, 50) GUICtrlCreateLabel("00:00:00", 10, 10) GUISetState() ;Start timer $timer = TimerInit() AdlibEnable("Timer", 50) ; While 1 ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before") Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after") WEnd EndFunc ;==>_Main ; Func Timer() _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs) Local $sTime = $Time ; save current time to be able to test and avoid flicker.. $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time) EndFunc ;==>Timer from the help file Gary Giggity Link to comment Share on other sites More sharing options...
GaryFrost Posted July 18, 2008 Share Posted July 18, 2008 I'm suprised you didn't go with expandcollapse popup; *** Demo to show a timer window #include <GUIConstantsEx.au3> #include <Date.au3> Opt("TrayIconDebug", 1) Opt("MustDeclareVars", 1) Global $timer, $Secs, $Mins, $Hour, $Time _Main() Func _Main() ;Create GUI GUICreate("Timer", 120, 50) GUICtrlCreateLabel("00:00:00", 10, 10) GUISetState() ;Start timer $timer = TimerInit() AdlibEnable("Timer", 50) ; While 1 ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before") Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after") WEnd EndFunc ;==>_Main ; Func Timer() _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs) Local $sTime = $Time; save current time to be able to test and avoid flicker.. $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time) EndFunc ;==>Timer from the help file Gary Why would I want to go with AdLib when I can use Timers and have multiple timers if I need them. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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