Page 1 of 1

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

Posted: 06 Apr 2018, 07:21
by arochon
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

}


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

Posted: 06 Apr 2018, 09:58
by Larry Yang
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

}

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

Posted: 06 Apr 2018, 10:14
by noname
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

}

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

Posted: 06 Apr 2018, 10:46
by arochon
Thank you so much! I appreciate the help noname