Page 1 of 1

Loop Read not working on a specific field

Posted: 11 Mar 2020, 10:22
by JKnight_xbt33
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"
editControl := ""

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

sleep, 1000
Loop, Read,
%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 297 times

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

Posted: 11 Mar 2020, 10:46
by boiler
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.

Re: Loop Read not working on a specific field

Posted: 12 Mar 2020, 04:42
by JKnight_xbt33
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

Re: Loop Read not working on a specific field

Posted: 12 Mar 2020, 05:56
by boiler
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)