Read text from a field - ControlGetText

Get help with using AutoHotkey and its commands and hotkeys
Albireo
Posts: 309
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] [Download] GeSHi © Codebox Plus

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

Code: [Select all] [Download] GeSHi © Codebox Plus

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

Why?
BoBo
Posts: 1108
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] [Download] GeSHi © Codebox Plus

ControlGet, Edit1ID, Hwnd,, Edit1, %WinID%
ControlGetText, UserNo,, ahk_id %Edit1ID%
Not Tested.
Albireo
Posts: 309
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] [Download] GeSHi © Codebox Plus

ControlGet, Edit1ID, Hwnd,, Edit1, %WinID%
Edit1ID = ahk_id %Edit1ID%
ControlGetText, UserNo,, %Edit1ID%
User avatar
derz00
Posts: 213
Joined: 02 Feb 2016, 17:54

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] [Download] GeSHi © Codebox Plus

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



Just a random thought.
either stumped or stunned
Albireo
Posts: 309
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] [Download] GeSHi © Codebox Plus

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: 213
Joined: 02 Feb 2016, 17:54

Re: Read text from a field - ControlGetText

19 Jul 2017, 06:29

Duh yes. You need quotation marks. Please excuse my bold ignorance.
either stumped or stunned

Return to “Ask For Help”

Who is online

Users browsing this forum: KuroiLight, tmplinshi and 38 guests