JotaPx Posted June 3, 2013 Share Posted June 3, 2013 Hi there! Question, having this: expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Dim $Timer1Active = 0, $Timer2Active = 0 Global $reference1 = 100, $reference2 = 100 AdlibRegister("AllTimers") GUICreate("Temporizadores", 990, 370) GUICtrlSetState(-1,$GUI_SHOW) ;TEMPORIZADOR 1 $Button_11 = GuiCtrlCreateButton("Start", 5, 70, 50, 20) $Button_12 = GuiCtrlCreateButton("Stop", 55, 70, 50, 20) $Label_1 = GuiCtrlCreateLabel("00", 5, 40, 100, 30, 0x1000) ;TEMPORIZADOR 2 $Button_21 = GuiCtrlCreateButton("Start", 115, 70, 50, 20) $Button_22 = GuiCtrlCreateButton("Stop", 165, 70, 50, 20) $Label_2 = GuiCtrlCreateLabel("00", 115, 40, 100, 30, 0x1000) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_11 $Timer1Active = 1 $timer1 = TimerInit() $reference1 = (60*(1)+0)*1000; segundos Case $msg = $Button_12 $Timer1Active = 0 GUICtrlSetData($Label_1, "00") Case $msg = $Button_21 $Timer2Active = 1 $timer2 = TimerInit() $reference2 = (60*(2)+0)*1000; segundos Case $msg = $Button_22 $Timer2Active = 0 GUICtrlSetData($Label_2, "00") Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func AllTimers() Local $Secs, $Mins, $Hour Local $Time1, $Time2 Local $sTime1 = $Time1, $sTime2 = $Time2 If $Timer1Active =1 Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) GUICtrlSetData($Label_1, $Secs) EndIf If $Timer2Active = 1 Then _TicksToTime(Int(TimerDiff($timer2)), $Hour, $Mins, $Secs) $Time2 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) GUICtrlSetData($Label_2, $Secs) EndIf EndFunc 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 4, 2013 Moderators Share Posted June 4, 2013 JotaPx,Bind your chosen HotKey to a function in which you run the same code as the existing buttons depending on the state of the timer. You could even get the buttons to run the same function and make it more compact. Give it a try and see how you get on. Come back if you want some more hints - but I am sure you will not need them. 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 Link to comment Share on other sites More sharing options...
JotaPx Posted June 4, 2013 Author Share Posted June 4, 2013 (edited) JotaPx, Bind your chosen HotKey to a function in which you run the same code as the existing buttons depending on the state of the timer. You could even get the buttons to run the same function and make it more compact. Give it a try and see how you get on. Come back if you want some more hints - but I am sure you will not need them. M23 Thanks for replying! i had made an attemtp in that direction, but a function didnt allow the other to iniciate untill its end. probably not doing it right. My solution was to create 3 executables (a bit rudimentar :/ ). One for the "interface", wich contained 2 functions that just call a run parameter to the other 2 executables (so it doesnt conflict with each other). not as clean as i wanted... but working best regards, thank you for your help once more Edited June 4, 2013 by JotaPx Link to comment Share on other sites More sharing options...
jdelaney Posted June 4, 2013 Share Posted June 4, 2013 (edited) give this a go (forgot the includes): expandcollapse popupDim $Timer1Active = 0, $Timer2Active = 0 Global $reference1 = 100, $reference2 = 100 GUICreate("Temporizadores", 990, 370) GUICtrlSetState(-1,$GUI_SHOW) ;TEMPORIZADOR 1 $Button_11 = GuiCtrlCreateButton("Start", 5, 70, 50, 20) $Button_12 = GuiCtrlCreateButton("Stop", 55, 70, 50, 20) $Label_1 = GuiCtrlCreateLabel("00", 5, 40, 100, 30, 0x1000) ;TEMPORIZADOR 2 $Button_21 = GuiCtrlCreateButton("Start", 115, 70, 50, 20) $Button_22 = GuiCtrlCreateButton("Stop", 165, 70, 50, 20) $Label_2 = GuiCtrlCreateLabel("00", 115, 40, 100, 30, 0x1000) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_11 $bTiming1 = True $Timer1Active = 1 $timer1 = TimerInit() $reference1 = (60*(1)+0)*1000; segundos Case $msg = $Button_12 $Timer1Active = 0 $bTiming1 = False GUICtrlSetData($Label_1, "00") Case $msg = $Button_21 $Timer2Active = 1 $timer2 = TimerInit() $reference2 = (60*(2)+0)*1000; segundos Case $msg = $Button_22 $Timer2Active = 0 GUICtrlSetData($Label_2, "00") Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop if $Timer1Active Then Timers($timer1, $Label_1) if $Timer2Active Then Timers($timer2, $Label_2) WEnd Func Timers($iTimer, $iLabel) Local $Secs, $Mins, $Hour Local $Time1, $Time2 Local $sTime1 = $Time1, $sTime2 = $Time2 _TicksToTime(Int(TimerDiff($iTimer)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If GUICtrlRead ($iLabel) <> $Time1 Then GUICtrlSetData($iLabel, $Time1) EndFunc Edited June 4, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
guinness Posted June 4, 2013 Share Posted June 4, 2013 (edited) jdelaney, Swap the Dim for Global, as Dim is deprecated in AutoIt. It works, but that's only for backwards compatibility. Edited June 4, 2013 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 4, 2013 Share Posted June 4, 2013 (edited) I was in the process of writing a code example for the HotKeySet thing that M23 posted (#2), and there has been at least two other posts made.. This one reason I don't post many examples, I'm a real slow typer.. Anyway, to go back to the HotKey thing, you can use several hotkeys to run the same function, in that function use the @HotKeyPressed macro to id which one sent it there. Like this:HotKeySet("{ESC}", "Terminate") HotKeySet("{F1}", "ShowMessage") HotKeySet("{F2}", "ShowMessage") ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func Terminate() Exit 0 EndFunc ;==>Terminate Func ShowMessage() Switch @HotKeyPressed Case "{F1}" MsgBox(4096, "", "F1 pressed") Case "{F2}" MsgBox(4096, "", "F2 pressed") EndSwitch EndFuncedit: make that three posts.. Edited June 4, 2013 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
JotaPx Posted June 4, 2013 Author Share Posted June 4, 2013 give this a go (forgot the includes): expandcollapse popupDim $Timer1Active = 0, $Timer2Active = 0 Global $reference1 = 100, $reference2 = 100 GUICreate("Temporizadores", 990, 370) GUICtrlSetState(-1,$GUI_SHOW) ;TEMPORIZADOR 1 $Button_11 = GuiCtrlCreateButton("Start", 5, 70, 50, 20) $Button_12 = GuiCtrlCreateButton("Stop", 55, 70, 50, 20) $Label_1 = GuiCtrlCreateLabel("00", 5, 40, 100, 30, 0x1000) ;TEMPORIZADOR 2 $Button_21 = GuiCtrlCreateButton("Start", 115, 70, 50, 20) $Button_22 = GuiCtrlCreateButton("Stop", 165, 70, 50, 20) $Label_2 = GuiCtrlCreateLabel("00", 115, 40, 100, 30, 0x1000) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_11 $bTiming1 = True $Timer1Active = 1 $timer1 = TimerInit() $reference1 = (60*(1)+0)*1000; segundos Case $msg = $Button_12 $Timer1Active = 0 $bTiming1 = False GUICtrlSetData($Label_1, "00") Case $msg = $Button_21 $Timer2Active = 1 $timer2 = TimerInit() $reference2 = (60*(2)+0)*1000; segundos Case $msg = $Button_22 $Timer2Active = 0 GUICtrlSetData($Label_2, "00") Case $msg = $GUI_EVENT_CLOSE EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop if $Timer1Active Then Timers($timer1, $Label_1) if $Timer2Active Then Timers($timer2, $Label_2) WEnd Func Timers($iTimer, $iLabel) Local $Secs, $Mins, $Hour Local $Time1, $Time2 Local $sTime1 = $Time1, $sTime2 = $Time2 _TicksToTime(Int(TimerDiff($iTimer)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If GUICtrlRead ($iLabel) <> $Time1 Then GUICtrlSetData($iLabel, $Time1) EndFunc much obliged for you reply, i do see that merge of the "ifs" in the function part, NICE ONE but part of my problem still persists that way. At least from my newbie point of view... ^^ if i was to implement and "hotkeyset" commands each would require a new function (to change each "$TimerXactive"). wont there be conflicts then? best regards Link to comment Share on other sites More sharing options...
JotaPx Posted June 4, 2013 Author Share Posted June 4, 2013 I was in the process of writing a code example for the HotKeySet thing that M23 posted (#2), and there has been at least two other posts made.. This one reason I don't post many examples, I'm a real slow typer.. Anyway, to go back to the HotKey thing, you can use several hotkeys to run the same function, in that function use the @HotKeyPressed macro to id which one sent it there. : 1st of all thanks for taking the time to post! that code opened my eyes a bit more, very usefull! gona give it a try along with the compact version jdelaney wrote, thanks Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 4, 2013 Share Posted June 4, 2013 Good luck with your project! - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
jdelaney Posted June 5, 2013 Share Posted June 5, 2013 oops, thanks guinness...basically just took his script, and didn't swap out much but the basics to make a working version IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted June 5, 2013 Moderators Solution Share Posted June 5, 2013 JotaPx, Just for completeness here is my version: expandcollapse popup#include <GUIConstants.au3> #include <StaticConstants.au3> #include <Date.au3> Global $Timer1Active = 0, $Timer2Active = 0 ; Do not use "Dim" Global $timer1, $timer2 ; These need to be Global now Global $reference1 = 100, $reference2 = 100 HotKeySet("^1", "_Timer_1") HotKeySet("^2", "_Timer_2") AdlibRegister("AllTimers") GUICreate("Temporizadores", 990, 370) ;GUICtrlSetState(-1, $GUI_SHOW) ; What was this for? ;TEMPORIZADOR 1 $Button_11 = GUICtrlCreateButton("Start", 5, 70, 50, 20) $Button_12 = GUICtrlCreateButton("Stop", 55, 70, 50, 20) $Label_1 = GUICtrlCreateLabel("00", 5, 40, 100, 30, $SS_SUNKEN) ; Do not use "magic numbers" ;TEMPORIZADOR 2 $Button_21 = GUICtrlCreateButton("Start", 115, 70, 50, 20) $Button_22 = GUICtrlCreateButton("Stop", 165, 70, 50, 20) $Label_2 = GUICtrlCreateLabel("00", 115, 40, 100, 30, $SS_SUNKEN) GUISetState() While 1 Switch GUIGetMsg() ; Switch is usually better for a GUIGetMsg loop Case $GUI_EVENT_CLOSE Exit Case $Button_11, $Button_12 _Timer_1() Case $Button_21, $Button_22 _Timer_2() EndSwitch WEnd Func _Timer_1() If $Timer1Active Then ; Timer 1 is running $Timer1Active = 0 GUICtrlSetData($Label_1, "00") Else $Timer1Active = 1 $timer1 = TimerInit() $reference1 = (60 * (1) + 0) * 1000; segundos EndIf EndFunc Func _Timer_2() If $Timer2Active Then ; Timer 1 is running $Timer2Active = 0 GUICtrlSetData($Label_2, "00") Else $Timer2Active = 1 $timer2 = TimerInit() $reference2 = (60 * (1) + 0) * 1000; segundos EndIf EndFunc Func AllTimers() Local $Secs, $Mins, $Hour Local $Time1, $Time2 Local $sTime1 = $Time1, $sTime2 = $Time2 If $Timer1Active = 1 Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) GUICtrlSetData($Label_1, $Secs) EndIf If $Timer2Active = 1 Then _TicksToTime(Int(TimerDiff($timer2)), $Hour, $Mins, $Secs) $Time2 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) GUICtrlSetData($Label_2, $Secs) EndIf EndFunc ;==>AllTimers Please ask if you have any questions. 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 Link to comment Share on other sites More sharing options...
guinness Posted June 5, 2013 Share Posted June 5, 2013 oops, thanks guinness...basically just took his script, and didn't swap out much but the basics to make a working version No problem. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JotaPx Posted June 5, 2013 Author Share Posted June 5, 2013 JotaPx, Just for completeness here is my version: expandcollapse popup#include <GUIConstants.au3> #include <StaticConstants.au3> #include <Date.au3> Global $Timer1Active = 0, $Timer2Active = 0 ; Do not use "Dim" Global $timer1, $timer2 ; These need to be Global now Global $reference1 = 100, $reference2 = 100 HotKeySet("^1", "_Timer_1") HotKeySet("^2", "_Timer_2") AdlibRegister("AllTimers") GUICreate("Temporizadores", 990, 370) ;GUICtrlSetState(-1, $GUI_SHOW) ; What was this for? ;TEMPORIZADOR 1 $Button_11 = GUICtrlCreateButton("Start", 5, 70, 50, 20) $Button_12 = GUICtrlCreateButton("Stop", 55, 70, 50, 20) $Label_1 = GUICtrlCreateLabel("00", 5, 40, 100, 30, $SS_SUNKEN) ; Do not use "magic numbers" ;TEMPORIZADOR 2 $Button_21 = GUICtrlCreateButton("Start", 115, 70, 50, 20) $Button_22 = GUICtrlCreateButton("Stop", 165, 70, 50, 20) $Label_2 = GUICtrlCreateLabel("00", 115, 40, 100, 30, $SS_SUNKEN) GUISetState() While 1 Switch GUIGetMsg() ; Switch is usually better for a GUIGetMsg loop Case $GUI_EVENT_CLOSE Exit Case $Button_11, $Button_12 _Timer_1() Case $Button_21, $Button_22 _Timer_2() EndSwitch WEnd Func _Timer_1() If $Timer1Active Then ; Timer 1 is running $Timer1Active = 0 GUICtrlSetData($Label_1, "00") Else $Timer1Active = 1 $timer1 = TimerInit() $reference1 = (60 * (1) + 0) * 1000; segundos EndIf EndFunc Func _Timer_2() If $Timer2Active Then ; Timer 1 is running $Timer2Active = 0 GUICtrlSetData($Label_2, "00") Else $Timer2Active = 1 $timer2 = TimerInit() $reference2 = (60 * (1) + 0) * 1000; segundos EndIf EndFunc Func AllTimers() Local $Secs, $Mins, $Hour Local $Time1, $Time2 Local $sTime1 = $Time1, $sTime2 = $Time2 If $Timer1Active = 1 Then _TicksToTime(Int(TimerDiff($timer1)), $Hour, $Mins, $Secs) $Time1 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) GUICtrlSetData($Label_1, $Secs) EndIf If $Timer2Active = 1 Then _TicksToTime(Int(TimerDiff($timer2)), $Hour, $Mins, $Secs) $Time2 = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) GUICtrlSetData($Label_2, $Secs) EndIf EndFunc ;==>AllTimers Please ask if you have any questions. M23 So great, thank you for taking your time and posting! ";GUICtrlSetState(-1, $GUI_SHOW) ; What was this for?" : leftovers from scripting attempts ^^ That prety much sums all the ideas/advises given in this topic. To all who contributed a big thank you!! 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