GuiControl,(Blank) is not updating Text control with new Value Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
JoeWinograd
Posts: 1630
Joined: 10 Feb 2014, 20:00

GuiControl,(Blank) is not updating Text control with new Value

22 Aug 2020, 12:09

Hi Folks,

The GuiControl doc says this:
Leave SubCommand blank to put new contents into the control via Value.
For a Text/Button/GroupBox/StatusBar/Link control, it says this:
Specify for Value the control's new text.
Here's a small script that I think should work based on that doc, but it doesn't:

Code: Select all

Gui,New,AlwaysOnTop,Test
Gui,Add,Text,vCurrentTime,%A_Now%
Gui,Show,w200
SetTimer,Timer,1000
Return

Timer:
GuiControl,,CurrentTime,%A_Now%
Return

GuiClose:
GuiEscape:
ExitApp
The Gui,Show displays the initial time, but it doesn't update after that. I know that the Timer code is being reached, as a MsgBox % A_Now command after the Timer: label shows the new time.

Anyone know why the GuiControl,,CurrentTime,%A_Now% does not work? Thanks much, Joe
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
GitHub: AAhkUser
Location: France

Re: GuiControl,(Blank) is not updating Text control with new Value  Topic is solved

22 Aug 2020, 12:36

Hi Joe,
GUI, New wrote: Although the new window is set as the default for the current thread, non-GUI threads still default to GUI number 1.
(...)
If the GUI has no name and is not the default GUI, it must be identified by its HWND.

Code: Select all

Gui,1:New,AlwaysOnTop,Test
Gui,Add,Text,vCurrentTime,%A_Now%
Gui,Show,w200
SetTimer,Timer,1000
Return

Timer:
GuiControl,,CurrentTime,%A_Now%
; GuiControl, 1:,CurrentTime,%A_Now%
Return

GuiClose:
GuiEscape:
ExitApp
or:

Code: Select all

Gui,New,AlwaysOnTop,Test
Gui,+hwndGUIID
Gui,Add,Text,vCurrentTime,%A_Now%
Gui,Show,w200
SetTimer,Timer,1000
Return

Timer:
GuiControl,%GUIID%:,CurrentTime,%A_Now%
Return

GuiClose:
GuiEscape:
ExitApp
Cheers

A_AhkUser
my scripts
User avatar
JoeWinograd
Posts: 1630
Joined: 10 Feb 2014, 20:00

Re: GuiControl,(Blank) is not updating Text control with new Value

22 Aug 2020, 12:44

Perfect! Thank you, AhkUser, for both the code and the explanation...both very much appreciated! Regards, Joe

Return to “Ask For Help”

Who is online

Users browsing this forum: anv, Bing [Bot], DaveT1, Google [Bot], JoeWinograd, LakaiHigh, mikeyww, RayB, TheProdigyC2, TXShooter and 79 guests