What is the best way to have a %variable% auto update text and progress bar in GUI

Get help with using AutoHotkey and its commands and hotkeys
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

What is the best way to have a %variable% auto update text and progress bar in GUI

06 Apr 2018, 07:21

How do I loop or GUI control %timesaved% to auto update on the GUI? Would also like to make the progress bar move up according to %timesaved% ? I have spent quite a bit of time playing with looping and have not had any luck.

Code: Select all

Gui, Add, Picture, x2 y-1 w550 h200 , %a_temp%/image.png
Gui, Add, Button, x132 y105 w380 h30 , ON/OFF(F7)
Gui, Add, Button, x132 y136 w380 h30 , Language-Reference
Gui, Add, Button, x132 y167 w380 h30 , Forum/Suggest-Acronym
Gui, Add, Text, x2 y210 w550 h20 , Time Saved Since Application Startup : %timesaved%
Gui, Add, Progress, x2 y200 w550 h10 , 0
Gui, Show, x674 y381 h230 w552, New GUI Window
Return

GuiClose:
ExitApp


::lol::
sendinput, laugh out loud
timesaved += 1.5
return


::rofl::
sendinput, roll on floor laughing
timesaved += 2.3
return

timesaved := Round(timesaved)


F8::MsgBox,% FormatSeconds(timesaved)


ExitApp

FormatSeconds(NumberOfSeconds) 
{

 time = 20010101 ;1/1/2001

 time += NumberOfSeconds, seconds

 FormatTime, HHmmss, %time%, HH:mm:ss

 Return, HHmmss

}

Larry Yang

Re: What is the best way to have a %variable% auto update text and progress bar in GUI

06 Apr 2018, 09:58

arochon wrote:How do I loop or GUI control %timesaved% to auto update on the GUI? Would also like to make the progress bar move up according to %timesaved% ? I have spent quite a bit of time playing with looping and have not had any luck.

Code: Select all

Gui, Add, Picture, x2 y-1 w550 h200 , %a_temp%/image.png
Gui, Add, Button, x132 y105 w380 h30 , ON/OFF(F7)
Gui, Add, Button, x132 y136 w380 h30 , Language-Reference
Gui, Add, Button, x132 y167 w380 h30 , Forum/Suggest-Acronym
Gui, Add, Text, x2 y210 w550 h20 , Time Saved Since Application Startup : %timesaved%
Gui, Add, Progress, x2 y200 w550 h10 , 0
Gui, Show, x674 y381 h230 w552, New GUI Window
Return

GuiClose:
ExitApp


::lol::
sendinput, laugh out loud
timesaved += 1.5
return


::rofl::
sendinput, roll on floor laughing
timesaved += 2.3
return

timesaved := Round(timesaved)


F8::MsgBox,% FormatSeconds(timesaved)


ExitApp

FormatSeconds(NumberOfSeconds) 
{

 time = 20010101 ;1/1/2001

 time += NumberOfSeconds, seconds

 FormatTime, HHmmss, %time%, HH:mm:ss

 Return, HHmmss

}

try this

Code: Select all

Gui, Add, Picture, x2 y-1 w550 h200 , %a_temp%/image.png
Gui, Add, Button, x132 y105 w380 h30 , ON/OFF(F7)
Gui, Add, Button, x132 y136 w380 h30 , Language-Reference
Gui, Add, Button, x132 y167 w380 h30 , Forum/Suggest-Acronym
Gui, Add, Text, x2 y210 w550 h20 vtsavedpbar , Time Saved Since Application Startup : %timesaved%
Gui, Add, Progress, x2 y200 w550 h10 , 0
Gui, Show, x674 y381 h230 w552, New GUI Window
Return

GuiClose:
ExitApp


::lol::
sendinput, laugh out loud
timesaved += 1.5
GuiControl,, tsavedpbar, Time Saved Since Application Startup : %timesaved%
return


::rofl::
sendinput, roll on floor laughing
timesaved += 2.3
GuiControl,, tsavedpbar, Time Saved Since Application Startup : %timesaved%
return

timesaved := Round(timesaved)


F8::MsgBox,% FormatSeconds(timesaved)


ExitApp

FormatSeconds(NumberOfSeconds) 
{

 time = 20010101 ;1/1/2001

 time += NumberOfSeconds, seconds

 FormatTime, HHmmss, %time%, HH:mm:ss

 Return, HHmmss

}
User avatar
noname
Posts: 509
Joined: 19 Nov 2013, 09:15

Re: What is the best way to have a %variable% auto update text and progress bar in GUI

06 Apr 2018, 10:14

You can use a settimer to update the GUI.

Code: Select all

Gui, Add, Picture, x2 y-1 w550 h200 , %a_temp%/image.png
Gui, Add, Button, x132 y105 w380 h30 , ON/OFF(F7)
Gui, Add, Button, x132 y136 w380 h30 , Language-Reference
Gui, Add, Button, x132 y167 w380 h30 , Forum/Suggest-Acronym
Gui, Add, Text, x2 y210 w550 h20 vmytext , Time Saved Since Application Startup : %timesaved%
Gui, Add, Progress, x2 y200 w550 h10 vMyProgress ,0
Gui, Show, x674 y381 h230 w552, New GUI Window
SetTimer, update,500
Return

update:
GuiControl, , MyText ,Time Saved Since Application Startup : %timesaved%
GuiControl,, MyProgress, %timesaved%
return

GuiClose:
ExitApp


::lol::
sendinput, laugh out loud
timesaved += 1.5
return


::rofl::
sendinput, roll on floor laughing
timesaved += 2.3
return

timesaved := Round(timesaved)


F8::MsgBox,% FormatSeconds(timesaved)


ExitApp

FormatSeconds(NumberOfSeconds) 
{

 time = 20010101 ;1/1/2001

 time += NumberOfSeconds, seconds

 FormatTime, HHmmss, %time%, HH:mm:ss

 Return, HHmmss

}
soundcloud.com/user-32706894

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], DataLife, diegobh00, gignu, MikeyG12, shawnway and 77 guests