by garry » 19 Mar 2023, 10:07
START/PAUSE/RESET
Code: Select all
;---
;- Modificar el texto de una GUI
;- https://www.autohotkey.com/boards/viewtopic.php?f=40&t=115182
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=95025
#NoEnv ;- Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ;- Enable warnings to assist with detecting common errors.
SendMode Input ;- Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ;- Ensures a consistent starting directory.
xx:=100,WA:=A_screenwidth,HA:=A_screenheight
Gui,2: -DPIScale
Gui,2:Color,Black,black
Gui,2:Font, s32 cYellow, Lucida Console
T2:=" TEXT 00:00:00"
x:=(WA*2)/xx,y:=(HA*2)/xx,w:=(WA*71)/xx,h:=(HA*10)/xx
Gui,2: add, Edit ,x%x% y%y% w%w% h%h% cRed vTText,%t2%
;-
x:=(WA*2)/xx,y:=(HA*14)/xx,w:=(WA*10)/xx,h:=(HA*3.5)/xx
Gui,2:Add, Button,x%x% y%y% w%w% h%h% vStart1 gStart,START
;-
x:=(WA*14)/xx,y:=(HA*14)/xx,w:=(WA*10)/xx,h:=(HA*3.5)/xx
Gui,2:Add, Button,x%x% y%y% w%w% h%h% vPause gPause,PAUSE
;-
x:=(WA*26)/xx,y:=(HA*14)/xx,w:=(WA*10)/xx,h:=(HA*3.5)/xx
Gui,2:Add, Button,x%x% y%y% w%w% h%h% gReset , RESET
;-
Gui,2:add,text,x0 y0 w0 h0 vT1
x:=(WA*10)/xx,y:=(HA*10)/xx,w:=(WA*75)/xx,h:=(HA*20)/xx
Gui, 2:Show, x%x% y%y% w%w% h%h%,TEST
GuiControl,2: Focus,T1
gosub,reset
return
;-----------------------------
2Guiescape:
2Guiclose:
Exitapp
;-----------------------------
;-------------------------------------
Stopwatch: ; Timed routine to advance the stopwatch time
If (++timers > 59)
timerm += 1, timers := "00"
If (timerm > 59)
timerh += 1, timerm := "00"
Gosub, Update
Return
;-------------------------------------
Pause: ; Pause or resume
GuiControlGet, stopped,, Pause
If (stopped = "Pause") { ; User clicked "Pause"
SetTimer, Stopwatch, Off
GuiControl,2:, Pause, Resume ; Button: Pause -> Resume
Gui,2: Color, FFFDCD ; Yellow
SoundBeep, 1000
Return
} Else GuiControl,2:, Pause, Pause ; Button: Resume -> Pause
;-----------------------------------
Start: ; Start the timer
SetTimer, Stopwatch, 1000
Gui,2: Color, E7FFEB ; Green
SoundBeep, 1500
Return
;----------------------------------
Reset: ; Reset the timer
timerh := timerm := timers := "00"
SetTimer, Stopwatch,off
SoundBeep, 1900
;----------------------------------
Update:
aa:=Format("{:02}:{:02}:{:02}",timerh, timerm, timers)
ab:=Format("{:02}{:02}{:02}",timerh, timerm, timers)
ac:=6,ad:=10
if ((ab>=ac) and (ab<=ad)) ;- if between 6-10 / if between ac-ad
{
T2:="Las rosas son rojas, las violetas son azules "
GuiControl,2:, TText,`n%t2% %aa%
}
else
{
T2:=" TEXT "
GuiControl,2:, TText,`n%t2% %aa%
}
Return
;----------------------------------
/*
aa:="00069"
ac:=ceil(aa)
if (ac<70)
msgbox,%ac% is smaller than 70
if (ac>=70)
msgbox,%ac% is = > than 70
return
*/
;==================================
START/PAUSE/RESET
[code];---
;- Modificar el texto de una GUI
;- https://www.autohotkey.com/boards/viewtopic.php?f=40&t=115182
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=95025
#NoEnv ;- Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ;- Enable warnings to assist with detecting common errors.
SendMode Input ;- Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ;- Ensures a consistent starting directory.
xx:=100,WA:=A_screenwidth,HA:=A_screenheight
Gui,2: -DPIScale
Gui,2:Color,Black,black
Gui,2:Font, s32 cYellow, Lucida Console
T2:=" TEXT 00:00:00"
x:=(WA*2)/xx,y:=(HA*2)/xx,w:=(WA*71)/xx,h:=(HA*10)/xx
Gui,2: add, Edit ,x%x% y%y% w%w% h%h% cRed vTText,%t2%
;-
x:=(WA*2)/xx,y:=(HA*14)/xx,w:=(WA*10)/xx,h:=(HA*3.5)/xx
Gui,2:Add, Button,x%x% y%y% w%w% h%h% vStart1 gStart,START
;-
x:=(WA*14)/xx,y:=(HA*14)/xx,w:=(WA*10)/xx,h:=(HA*3.5)/xx
Gui,2:Add, Button,x%x% y%y% w%w% h%h% vPause gPause,PAUSE
;-
x:=(WA*26)/xx,y:=(HA*14)/xx,w:=(WA*10)/xx,h:=(HA*3.5)/xx
Gui,2:Add, Button,x%x% y%y% w%w% h%h% gReset , RESET
;-
Gui,2:add,text,x0 y0 w0 h0 vT1
x:=(WA*10)/xx,y:=(HA*10)/xx,w:=(WA*75)/xx,h:=(HA*20)/xx
Gui, 2:Show, x%x% y%y% w%w% h%h%,TEST
GuiControl,2: Focus,T1
gosub,reset
return
;-----------------------------
2Guiescape:
2Guiclose:
Exitapp
;-----------------------------
;-------------------------------------
Stopwatch: ; Timed routine to advance the stopwatch time
If (++timers > 59)
timerm += 1, timers := "00"
If (timerm > 59)
timerh += 1, timerm := "00"
Gosub, Update
Return
;-------------------------------------
Pause: ; Pause or resume
GuiControlGet, stopped,, Pause
If (stopped = "Pause") { ; User clicked "Pause"
SetTimer, Stopwatch, Off
GuiControl,2:, Pause, Resume ; Button: Pause -> Resume
Gui,2: Color, FFFDCD ; Yellow
SoundBeep, 1000
Return
} Else GuiControl,2:, Pause, Pause ; Button: Resume -> Pause
;-----------------------------------
Start: ; Start the timer
SetTimer, Stopwatch, 1000
Gui,2: Color, E7FFEB ; Green
SoundBeep, 1500
Return
;----------------------------------
Reset: ; Reset the timer
timerh := timerm := timers := "00"
SetTimer, Stopwatch,off
SoundBeep, 1900
;----------------------------------
Update:
aa:=Format("{:02}:{:02}:{:02}",timerh, timerm, timers)
ab:=Format("{:02}{:02}{:02}",timerh, timerm, timers)
ac:=6,ad:=10
if ((ab>=ac) and (ab<=ad)) ;- if between 6-10 / if between ac-ad
{
T2:="Las rosas son rojas, las violetas son azules "
GuiControl,2:, TText,`n%t2% %aa%
}
else
{
T2:=" TEXT "
GuiControl,2:, TText,`n%t2% %aa%
}
Return
;----------------------------------
/*
aa:="00069"
ac:=ceil(aa)
if (ac<70)
msgbox,%ac% is smaller than 70
if (ac>=70)
msgbox,%ac% is = > than 70
return
*/
;==================================
[/code]