Read text from a field - ControlGetText

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Read text from a field - ControlGetText

17 Jul 2017, 07:24

I don't know what's different between this two commands, but only one work for me. (Windows 10)

Code: Select all

....
ControlGet Edit1ID, Hwnd,, Edit1, %WinID%
ControlGetText UserNo,, %Edit1ID%
(this doesn't work - but I think it's a better way)

Code: Select all

ControlGetText UserNo1, Edit1, %WinID%
(and this works for me!)

Why?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Read text from a field - ControlGetText

17 Jul 2017, 09:20

TBH, the one that works looks to me like the better way - because it works, right?! :)
To operate upon a control's HWND (window handle), leave the Control parameter blank and specify ahk_id %ControlHwnd% for the WinTitle parameter

Code: Select all

ControlGet, Edit1ID, Hwnd,, Edit1, %WinID%
ControlGetText, UserNo,, ahk_id %Edit1ID%
Not Tested.
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Read text from a field - ControlGetText

17 Jul 2017, 16:11

Thank you!
The solution you gave me works. (had forgotten "ahk_id")

But why this doesn't work?

Code: Select all

ControlGet, Edit1ID, Hwnd,, Edit1, %WinID%
Edit1ID = ahk_id %Edit1ID%
ControlGetText, UserNo,, %Edit1ID%
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Read text from a field - ControlGetText

17 Jul 2017, 16:50

Might be double referencing? Or maybe I don't understand variables correctly. Try this:

Code: Select all

ControlGet, Edit1ID, Hwnd,, Edit1, %WinID%
Edit1IDvar = ahk_id %Edit1ID%
ControlGetText, UserNo,, %Edit1IDvar%

Just a random thought.
try it and see
...
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Read text from a field - ControlGetText

19 Jul 2017, 05:05

Thanks!
My solution will be the following .:

Code: Select all

ControlGet, Edit1ID, Hwnd,, Edit1, %WinID%
Edit1ID := "ahk_id " %Edit1ID%
ControlGetText, UserNo,, %Edit1ID%
(The old variable value is overwritten by the new value)
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Read text from a field - ControlGetText

19 Jul 2017, 06:29

Duh yes. You need quotation marks. Please excuse my bold ignorance.
try it and see
...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, Google [Bot] and 385 guests