Code for function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
robjmartins
Posts: 5
Joined: 26 Jul 2018, 09:45

Code for function

26 Jul 2018, 10:11

Hello,

Could anyone help me with how to turn this code into function?
Grateful

Code: Select all

F9::
	
	tempo := 5
	
	Gui, janela: +AlwaysOnTop -SysMenu
	Gui, janela:Font, s20 bold, Arial
	Gui, janela:Add, Text, Center w90 h30 vTX, % FormatarTempo(tempo)
	Gui, janela:Show, x0 y0 NoActivate, Timer
	
	
	loop % tempo-1 
	{
		GuiControl, janela:, TX, % FormatarTempo(tempo--)
		Sleep, 1000
	}
	
	Gui, janela:Destroy
	
	return
	
	
	F10::
	ExitApp
	
	
	
	FormatarTempo(segundos) 
	{
		tempoFormat = 20000101
		tempoFormat += %segundos%, Seconds
		FormatTime, mmss, %tempoFormat%, mm:ss
		
		return mmss
	}
Attempt

Code: Select all

F9::

Visor(5)

F10::
ExitApp




FormatarTempo(segundos) 
{
	tempoFormat = 20000101
	tempoFormat += %segundos%, Seconds
	FormatTime, mmss, %tempoFormat%, mm:ss
	
	return mmss
}



Visor(tempo)
{
	Gui, janela: +AlwaysOnTop -SysMenu
	Gui, janela:Font, s20 bold, Arial
	Gui, janela:Add, Text, Center w90 h30, % FormatarTempo(tempo)
	Gui, janela:Show, x0 y0 NoActivate, Timer
	
	
	loop % tempo - 1 
	{
		GuiControl, Text, janela, % FormatarTempo(tempo--)
		Sleep, 1000
	}
	
	Gui, janela:Destroy
	
	return	
}
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: Code for function

26 Jul 2018, 14:33

Code: Select all

F9::Visor(5)

F10::
ExitApp




FormatarTempo(segundos) 
{
	tempoFormat = 20000101
	tempoFormat += %segundos%, Seconds
	FormatTime, mmss, %tempoFormat%, mm:ss
	
	return mmss
}



Visor(tempo)
{
	Gui, janela: +AlwaysOnTop -SysMenu
	Gui, janela:Font, s20 bold, Arial
	Gui, janela:Add, Text, Center w90 h30 vTX, % FormatarTempo(tempo) ;Old: Gui, janela:Add, Text, Center w90 h30, % FormatarTempo(tempo)
	Gui, janela:Show, x0 y0 NoActivate, Timer
	global TX ; New
	
	loop % tempo - 1 
	{
		GuiControl, janela:, TX, % FormatarTempo(tempo--) ;Old: GuiControl, Text, janela, % FormatarTempo(tempo--)
		Sleep, 1000
	}
	
	Gui, janela:Destroy
	
	return	
}
robjmartins
Posts: 5
Joined: 26 Jul 2018, 09:45

Re: Code for function

26 Jul 2018, 15:41

Thank you very much for the solution. :clap: :clap: :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], OrangeCat and 141 guests