Sign in to follow this  
Followers 0
JotaPx

Adding hotkeys to start multiple timers

13 posts in this topic

Hi there!

Question, having this:

#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

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by JotaPx

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

give this a go (forgot the includes):

Dim $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 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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

jdelaney,

Swap the Dim for Global, as Dim is deprecated in AutoIt. It works, but that's only for backwards compatibility.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#6 ·  Posted (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
EndFunc
edit: make that three posts.. Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

 

give this a go (forgot the includes):

Dim $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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Good luck with your project!


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

JotaPx,

Just for completeness here is my version:

#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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

oops, thanks guinness...basically just took his script, and didn't swap out much but the basics to make a working version

No problem.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

JotaPx,

Just for completeness here is my version:

#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!!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0