unable to enter text into edit field via script Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
drizzt
Posts: 31
Joined: 20 Apr 2018, 20:44

unable to enter text into edit field via script

26 Jun 2018, 19:09

I have the following simple GUI

Code: Select all

Gui, Add, Text,, enter your name:
Gui, Add, Edit, vName
Gui, Add, Text,, enter your city:
Gui, Add, Edit, vCity
Gui, Add, Text,,  enter your phone:
Gui, Add, Edit, vPhone
Gui, Show
return
Then I use this script to enter info into the first field but its not working

Code: Select all

m:: 
WinGet, mywindow, ID, A
MsgBox, % mywindow
mydata:= "afdas"
guicontrol, mywindow:,  Edit1, %mydata%   ;the first data is the variable name associated with the edit field. the second %data% is thwe text to put in the field.
return
:beer:
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: unable to enter text into edit field via script

26 Jun 2018, 19:49

Try without mywindow: here:

Code: Select all

guicontrol,,  Edit1, %mydata%
that seems to work when all code is in one script.
Last edited by wolf_II on 26 Jun 2018, 19:50, edited 1 time in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: unable to enter text into edit field via script

26 Jun 2018, 19:50

Try this. Cheers.

Code: Select all

GuiControl, % mywindow ":", Edit1, % mydata
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
drizzt
Posts: 31
Joined: 20 Apr 2018, 20:44

Re: unable to enter text into edit field via script

27 Jun 2018, 08:47

jeeswg wrote:Try this. Cheers.

Code: Select all

GuiControl, % mywindow ":", Edit1, % mydata

I tried this but still doesnt work.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: unable to enter text into edit field via script

27 Jun 2018, 09:28

Really? Maybe you already had a script open using the m hotkey.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
A_AhkUser
Posts: 1087
Joined: 06 Mar 2017, 16:18
GitHub: AAhkUser
Location: France

Re: unable to enter text into edit field via script  Topic is solved

27 Jun 2018, 14:15

Hi drizzt,

Assuming you worded with caution your problem - in particular:
Documentation wrote:Each script is a plain text file containing lines to be executed by the program (AutoHotkey.exe).
You might rather need to use ControlSetText instead - for example:

Code: Select all

ControlSetText, Edit1, % mydata, % "ahk_id " . mywindow
Actually, GuiXXX commands operate on windows objects created using the GUI command, within the limits of a given script.
drizzt
Posts: 31
Joined: 20 Apr 2018, 20:44

Re: unable to enter text into edit field via script

27 Jun 2018, 16:14

:bravo: Yes this did the trick!. thanks,

Return to “Ask For Help”

Who is online

Users browsing this forum: bjukrain, boiler, CarPiotr, coder_chick, DaveT1, hackkk745 and 48 guests