GuiControl not updating properly Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
clarkj03

GuiControl not updating properly

14 Nov 2015, 18:39

Help!

I am just trying to give users two ways to copy selected text into a GUI edit field.

----------------------------------------
The first way (the Gui Button) is working GREAT!

The second way (the hotkey) is not working.
----------------------------------------

It seems that EVERYTHING is working EXCEPT the GuiControl line at the end of the code when using the hotkey.

I can confirm that the MsgBox test line at the end of the code works just fine for both, so I know the data is getting through the code.

I also confirmed that the iniwrite command is working for both.

I've tried everything in my toolbox, which is why I'm asking for help.

Also, if I trade out the 'return' for a 'reload' at the bottom of the code, the edit field loads with the captured text, as it is loaded from an iniread at the beginning of the script. I can use this as a workaround, but I don't really want the gui window to flash.

The pertinent code from the script. (there is more to the GUI than this, but this is the part that I suspect matters)

Code: Select all

Gui, 33:Add, Button, x5 y50 w125 h25 +Left gfCopy1, C: Proc Name        ; The GuiControl updates the edit field properly with this
Gui, 33:Add, Edit, x135 y50 w165 h25 r1 gMySubroutine vdata1, %Data1%   ;  way of activating from the Gui Button.
Goto fCopy1                                                              ;  The 'Send !{esc}' is to return focus to the previously 
return                                                                   ;  active window after clicking the button in the gui
                                                                         ;  %data1% shows up in the MsgBox properly
																	 
																	 
^!1::          ;The GuiControl does not update the edit field at all with this
Goto SCopy1    ; way of activating from a hotkey.
return         ; I bypassed the 'Send !{esc}' because I'm copying highlighted text from the ACTIVE window.
               ; BUT %data1% shows up in the MsgBox properly

fCopy1:
Gui 33:Submit, Nohide
Send !{esc}

SCopy1:
clipboard = 
Send ^c
clipwait, 1
clipboard = %clipboard%
data1 = %clipboard%
IniWrite, %data1%, C:\quickcopydata.ini, Data, data1
GuiControl,, data1, %data1%
MsgBox Why didn't the GuiControl update the field? %data1%
return
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: GuiControl not updating properly

14 Nov 2015, 18:52

untestet:

Code: Select all

GuiControl, 33:, data1, %data1%
clarkj03

Re: GuiControl not updating properly

14 Nov 2015, 18:54

Thanks I'll give it a shot in a sec.

Why would one way work, and not the other way?

Just trying to learn for the future.
clarkj03

Re: GuiControl not updating properly

14 Nov 2015, 18:56

That worked GREAT!

Glad it was something that easy. I didn't see any documentation about GUI number labels in the GuiControl documentation.

Thank you kindly.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: GuiControl not updating properly  Topic is solved

14 Nov 2015, 19:02

see https://autohotkey.com/docs/commands/Gu ... tm#Remarks

You have to tell GuiControl which control you want to change.
There are three ways that I know of:

(1) Don't use any named GUIs. Then it will always find the right one.
(2) Use Gui, 33: Default before calling GuiControl,, data1, %data1% to set the default Gui.
(3) Use the name as demonstrated.

I hope that helps.
clarkj03

Re: GuiControl not updating properly

14 Nov 2015, 19:20

Yes. That was perfect. I'll always just include the 33: to make it work most consistently.

Thanks again.

Jeff
nichatr
Posts: 7
Joined: 17 May 2019, 01:43
Contact:

Re: GuiControl not updating properly

23 Mar 2020, 13:46

I was stuck with the same issue. Although the manual is referring to updating a gui's control other than the first, it doesn't have any example to state it clearly.
My code was

Code: Select all

GuiControl, , 3:myshortcutName, %shortcutName%  ; update the shortcut name
but the correct is

Code: Select all

GuiControl, 3:, myshortcutName, %shortcutName%  ; update the shortcut name
Thanks very much!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jameswrightesq, scriptor2016 and 267 guests