Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Adding hotkeys to start multiple timers

$
0
0

Hi there!

Question, having this:

AutoIt         
  1. #include <GUIConstants.au3>
  2. #include <Date.au3>
  3.  
  4.  
  5. Dim $Timer1Active = 0, $Timer2Active = 0
  6. Global $reference1 = 100, $reference2 = 100
  7.  
  8. AdlibRegister("AllTimers")
  9.  
  10. GUICreate("Temporizadores", 990, 370)
  11.  
  12. GUICtrlSetState(-1,$GUI_SHOW)
  13. ;TEMPORIZADOR 1
  14. $Button_11 = GuiCtrlCreateButton("Start", 5, 70, 50, 20)
  15. $Button_12 = GuiCtrlCreateButton("Stop", 55, 70, 50, 20)
  16. $Label_1 = GuiCtrlCreateLabel("00", 5, 40, 100, 30, 0x1000)
  17.  
  18. ;TEMPORIZADOR 2
  19. $Button_21 = GuiCtrlCreateButton("Start", 115, 70, 50, 20)
  20. $Button_22 = GuiCtrlCreateButton("Stop", 165, 70, 50, 20)
  21. $Label_2 = GuiCtrlCreateLabel("00", 115, 40, 100, 30, 0x1000)
  22.  
  23.  
  24.     $msg = GUIGetMsg()
  25.     Select
  26.         Case $msg = $Button_11
  27.             $Timer1Active = 1
  28.             $timer1 = TimerInit()
  29.             $reference1 = (60*(1)+0)*1000; segundos
  30.         Case $msg = $Button_12
  31.             $Timer1Active = 0
  32.             GUICtrlSetData($Label_1, "00")
  33.  
  34.         Case $msg = $Button_21
  35.             $Timer2Active = 1
  36.             $timer2 = TimerInit()
  37.             $reference2 = (60*(2)+0)*1000; segundos
  38.         Case $msg = $Button_22
  39.             $Timer2Active = 0
  40.             GUICtrlSetData($Label_2, "00")
  41.  
  42.         Case $msg = $GUI_EVENT_CLOSE
  43.     EndSelect
  44.     If $msg = $GUI_EVENT_CLOSE Then ExitLoop
  45.  
  46. Func AllTimers()
  47. Local $Secs, $Mins, $Hour
  48. Local $Time1, $Time2
  49. Local $sTime1 = $Time1, $sTime2 = $Time2
  50.    
  51.  If $Timer1Active =1 Then
  52.         _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs)
  53.         $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
  54.         GUICtrlSetData($Label_1, $Secs)
  55.     EndIf
  56.    
  57.     If $Timer2Active = 1 Then
  58.         _TicksToTime(Int(TimerDiff($timer2)), $Hour, $Mins, $Secs)
  59.         $Time2 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
  60.         GUICtrlSetData($Label_2, $Secs)
  61.     EndIf

how can i add say "F1" to start/reset-start clock 1 and "F2" to start/reset-start clock2

 

extensive code i know, sorry for that, a bit noob at this still.

helping around when i can tough


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>