yousefsamy Posted June 24, 2014 Posted June 24, 2014 i try 2 codes : _guitooltip_settimedelay and _timer_settimer <== but i got no result here is my code #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiToolTip.au3> #include <Timers.au3> $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 161, 81) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) _Timer_SetTimer( MsgBox(0,"","") , $t * 1000 ) EndSwitch WEnd
mpower Posted June 24, 2014 Posted June 24, 2014 (edited) This might not be the best approach, but it works (i'm sure there are many ways of doing it - that's the magic of autoit): #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $timer, $tdiff, $t, $timeron = 0 ;add some global variables for ease of tracking $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 161, 81) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) $timeron = 1 ;set $timeron to 1 so that we can start checking timer elapsed time in the While loop below $timer = TimerInit() ;initiate a timer and assign to $timer variable EndSwitch If $timeron = 1 Then ;if $timeron is 1 then we can start checking the elapsed timer time $tdiff = TimerDiff($timer) ;$tdiff = time in milliseconds that has passed since we started our timer above using TimerInit() If $tdiff >= 2000 Then ;if the timer reaches 2000 milliseconds (2 seconds) or more then we pop up a message box - we can even report how much time has passed since we started the timer by adding $tdiff to the MsgBox MsgBox(0,'','Your text was: ' & $t & @CRLF & @CRLF & 'This message popped up after ' & Round($tdiff/1000, 2) & ' seconds.') ;pop up the message $timeron = 0 ;set $timeron to 0 so that we stop checking for timer until we start it again by clicking the button :) EndIf EndIf WEnd Edit: Whoops I didn't notice you wanted to get seconds value from the input, so here is a modified script that does that. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $timer, $tdiff, $t, $timeron = 0 ;add some global variables for ease of tracking $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Enter duration in seconds here", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 161, 81) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) $timeron = 1 ;set $timeron to 1 so that we can start checking timer elapsed time in the While loop below $timer = TimerInit() ;initiate a timer and assign to $timer variable EndSwitch If $timeron = 1 Then ;if $timeron is 1 then we can start checking the elapsed timer time $tdiff = TimerDiff($timer) ;$tdiff = time in milliseconds that has passed since we started our timer above using TimerInit() If $tdiff >= $t * 1000 Then ;if the timer reaches set time in seconds or more then we pop up a message box - we can even report how much time has passed since we started the timer by adding $tdiff to the MsgBox MsgBox(0,'','You set timer to: ' & $t & ' seconds.' & @CRLF & @CRLF & 'This message popped up after ' & Round($tdiff/1000, 0) & ' seconds.') ;pop up the message $timeron = 0 ;set $timeron to 0 so that we stop checking for timer until we start it again by clicking the button :) EndIf EndIf WEnd The difference between my script and the one posted below by somdcomputerguy is that with my script you can have other things happening at the same time. e.g. have another button that you can click and get a different message, whilst the timer is running (or not). See Example below: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $timer, $tdiff, $t, $timeron = 0 ;add some global variables for ease of tracking $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Enter duration in seconds here", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 100, 50) $Button2 = GUICtrlCreateButton("Button2", 80, 124, 100, 50) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) $timeron = 1 ;set $timeron to 1 so that we can start checking timer elapsed time in the While loop below $timer = TimerInit() ;initiate a timer and assign to $timer variable Case $Button2 If $timeron = 1 Then MsgBox(0,'','You pressed Button2 whilst time was ON') Else MsgBox(0,'','You pressed Button2 whilst time was OFF') EndIf EndSwitch If $timeron = 1 Then ;if $timeron is 1 then we can start checking the elapsed timer time $tdiff = TimerDiff($timer) ;$tdiff = time in milliseconds that has passed since we started our timer above using TimerInit() If $tdiff >= $t * 1000 Then ;if the timer reaches set time in seconds or more then we pop up a message box - we can even report how much time has passed since we started the timer by adding $tdiff to the MsgBox MsgBox(0,'','You set timer to: ' & $t & ' seconds.' & @CRLF & @CRLF & 'This message popped up after ' & Round($tdiff/1000, 0) & ' seconds.') ;pop up the message $timeron = 0 ;set $timeron to 0 so that we stop checking for timer until we start it again by clicking the button :) EndIf EndIf WEnd With somdcomputerguy's script even if you have a second button that pops up another message box it will only pop after the first message box is gone (i.e. each button's action will be queued and will fire only after the first one is done). I guess it all comes down to how you want to handle this for your particular application - I prefer to be able to execute concurrent action to provide a seamless user experience, but I can see where Sleep(x) can come in handy. Edited June 24, 2014 by mpower yousefsamy 1
Solution somdcomputerguy Posted June 24, 2014 Solution Posted June 24, 2014 Here is a modified version of the code you posted.#include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Enter # of seconds to wait..", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 161, 81) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) Sleep($t * 1000 ) MsgBox(0, $t, "This dialog popped up after " & $t & " seconds") EndSwitch WEnd yousefsamy 1 - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
yousefsamy Posted June 24, 2014 Author Posted June 24, 2014 Here is a modified version of the code you posted. #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Enter # of seconds to wait..", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 161, 81) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) Sleep($t * 1000 ) MsgBox(0, $t, "This dialog popped up after " & $t & " seconds") EndSwitch WEnd really bro i got this idea but cant use this code timer_settimer <=== ??
yousefsamy Posted June 24, 2014 Author Posted June 24, 2014 This might not be the best approach, but it works (i'm sure there are many ways of doing it - that's the magic of autoit): #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $timer, $tdiff, $t, $timeron = 0 ;add some global variables for ease of tracking $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 161, 81) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) $timeron = 1 ;set $timeron to 1 so that we can start checking timer elapsed time in the While loop below $timer = TimerInit() ;initiate a timer and assign to $timer variable EndSwitch If $timeron = 1 Then ;if $timeron is 1 then we can start checking the elapsed timer time $tdiff = TimerDiff($timer) ;$tdiff = time in milliseconds that has passed since we started our timer above using TimerInit() If $tdiff >= 2000 Then ;if the timer reaches 2000 milliseconds (2 seconds) or more then we pop up a message box - we can even report how much time has passed since we started the timer by adding $tdiff to the MsgBox MsgBox(0,'','Your text was: ' & $t & @CRLF & @CRLF & 'This message popped up after ' & Round($tdiff/1000, 2) & ' seconds.') ;pop up the message $timeron = 0 ;set $timeron to 0 so that we stop checking for timer until we start it again by clicking the button :) EndIf EndIf WEnd Edit: Whoops I didn't notice you wanted to get seconds value from the input, so here is a modified script that does that. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $timer, $tdiff, $t, $timeron = 0 ;add some global variables for ease of tracking $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Enter duration in seconds here", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 161, 81) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) $timeron = 1 ;set $timeron to 1 so that we can start checking timer elapsed time in the While loop below $timer = TimerInit() ;initiate a timer and assign to $timer variable EndSwitch If $timeron = 1 Then ;if $timeron is 1 then we can start checking the elapsed timer time $tdiff = TimerDiff($timer) ;$tdiff = time in milliseconds that has passed since we started our timer above using TimerInit() If $tdiff >= $t * 1000 Then ;if the timer reaches set time in seconds or more then we pop up a message box - we can even report how much time has passed since we started the timer by adding $tdiff to the MsgBox MsgBox(0,'','You set timer to: ' & $t & ' seconds.' & @CRLF & @CRLF & 'This message popped up after ' & Round($tdiff/1000, 0) & ' seconds.') ;pop up the message $timeron = 0 ;set $timeron to 0 so that we stop checking for timer until we start it again by clicking the button :) EndIf EndIf WEnd The difference between my script and the one posted below by somdcomputerguy is that with my script you can have other things happening at the same time. e.g. have another button that you can click and get a different message, whilst the timer is running (or not). See Example below: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $timer, $tdiff, $t, $timeron = 0 ;add some global variables for ease of tracking $Form1 = GUICreate("Form1", 355, 202, 192, 124) $Input1 = GUICtrlCreateInput("Enter duration in seconds here", 48, 16, 225, 21) $Button1 = GUICtrlCreateButton("Button1", 80, 64, 100, 50) $Button2 = GUICtrlCreateButton("Button2", 80, 124, 100, 50) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;Here i want to pop up my msg after the duration i want how !! $t = GUICtrlRead($Input1) $timeron = 1 ;set $timeron to 1 so that we can start checking timer elapsed time in the While loop below $timer = TimerInit() ;initiate a timer and assign to $timer variable Case $Button2 If $timeron = 1 Then MsgBox(0,'','You pressed Button2 whilst time was ON') Else MsgBox(0,'','You pressed Button2 whilst time was OFF') EndIf EndSwitch If $timeron = 1 Then ;if $timeron is 1 then we can start checking the elapsed timer time $tdiff = TimerDiff($timer) ;$tdiff = time in milliseconds that has passed since we started our timer above using TimerInit() If $tdiff >= $t * 1000 Then ;if the timer reaches set time in seconds or more then we pop up a message box - we can even report how much time has passed since we started the timer by adding $tdiff to the MsgBox MsgBox(0,'','You set timer to: ' & $t & ' seconds.' & @CRLF & @CRLF & 'This message popped up after ' & Round($tdiff/1000, 0) & ' seconds.') ;pop up the message $timeron = 0 ;set $timeron to 0 so that we stop checking for timer until we start it again by clicking the button :) EndIf EndIf WEnd With somdcomputerguy's script even if you have a second button that pops up another message box it will only pop after the first message box is gone (i.e. each button's action will be queued and will fire only after the first one is done). I guess it all comes down to how you want to handle this for your particular application - I prefer to be able to execute concurrent action to provide a seamless user experience, but I can see where Sleep(x) can come in handy. My Bro,, Thnx alot i want to be very simple in my codes ,, i think this is the right way in programming
Moderators Melba23 Posted June 24, 2014 Moderators Posted June 24, 2014 yousefsamy,When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - we know what we wrote and it just pads the thread unnecessarily. M23 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
Moderators Melba23 Posted June 24, 2014 Moderators Posted June 24, 2014 yousefsamy,Thanks. M23 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
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