Loop Read not working on a specific field Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JKnight_xbt33
Posts: 135
Joined: 18 Sep 2019, 02:06

Loop Read not working on a specific field

11 Mar 2020, 10:22

Dear all,
I've used Loop read very successfully to read the numbers from text files.

For some reason when trying to read an edit field and trying to send this to notepad this isn't working.

Code: Select all

winTitle := "Customer Complaint - Occurrence Details - Q-Pulse"
winClass := "ahk_class WindowsForms10.Window.8.app.0.2eed1ca_r9_ad1"
editControl := " WindowsForms10.EDIT.app.0.2eed1ca_r9"

hWnd1 := WinExist(winTitle)
DllCall("ShowWindow", A_PtrSize ? "Ptr" : "UInt", hWnd1, "Int", 3) ; Maximize window

ControlClick, WindowsForms10.EDIT.app.0.2eed1ca_r9_ad114
sleep, 1000
Loop, Read, WindowsForms10.EDIT.app.0.2eed1ca_r9_ad114
%newcomplaint%:= RegExReplace(A_LoopReadLine, "\D")
sleep, 100
Run, Notepad.exe
sleep, 1000 
Send %newcomplaint%
Is there something I am missing here? I've circled in red the field where I am extracting the number
loop read2.PNG
loop read2.PNG (131.44 KiB) Viewed 452 times
User avatar
boiler
Posts: 17070
Joined: 21 Dec 2014, 02:44

Re: Loop Read not working on a specific field  Topic is solved

11 Mar 2020, 10:46

Loop, Read doesn't get text from a control. That's just for reading from text files. Use ControlGetText.

Also, read up on code blocks. Without them, the only statement getting executed each time through the loop following a Loop command is the one immediately after it.
JKnight_xbt33
Posts: 135
Joined: 18 Sep 2019, 02:06

Re: Loop Read not working on a specific field

12 Mar 2020, 04:42

Thanks for your response. ControlGetText did what I was looking for.....sort of.

It grabs the text from the field which is great. However I wanted to only grab the numerical portion of the text.

Overall though I can work with this for now, not a big deal.

Appreciate your simple answer and help
Best
J
:bravo:
User avatar
boiler
Posts: 17070
Joined: 21 Dec 2014, 02:44

Re: Loop Read not working on a specific field

12 Mar 2020, 05:56

Once you’ve gotten the text from the field, extracting the number from it is very easy. For example, if your variable containing the text from the field is Field, this will put the number part in the variable Num:

Code: Select all

RegExMatch(Field, "\d+”, Num)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, hiahkforum and 193 guests