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