Edit control not working 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

Edit control not working

Post by JKnight_xbt33 » 23 Apr 2021, 05:59

HI all,
I have a window with an edit control field that i want to send a number to. Why is it not clicking the edit control 111? You can see I've defined it in the script as hWnd4 .
1 not clicking.PNG
1 not clicking.PNG (310.51 KiB) Viewed 585 times

Code: Select all

setkeydelay , -1
DetectHiddenWindows On
DetectHiddenText On  
SetTitleMatchMode, 2 

winTitle := "Custom Filter - Occurrence List - Q-Pulse"
winTitle2 := "LaunchPad <Knight, James>"
winTitle3 := "_Customer Complaint - Occurrence Details - Q-Pulse"
winTitle4 := "_Customer Complaint - Incident Details - Q-Pulse"

winClass := "ahk_class WindowsForms10.Window.8.app.0.2eed1ca_r9_ad1"
editControl := "WindowsForms10.EDIT.app.0.2eed1ca_r9_ad"
                
hWnd1 := WinExist(winTitle) ; Get Custom Filter window hWnd
hWnd2 := WinExist(winTitle2) ; Get LaunchPad window hWnd
hWnd3 := WinExist(winTitle3) ; Get Complaint window hWnd
hWnd4 := WinExist(winTitle4) ; Get Incident window hWnd

ptrS := A_PtrSize ? "Ptr" : "UInt"

Loop, Read, \\private\Users\private\Documents\18-Customer complaint reports PDFs\New deliveries\4-batch no.txt
IDArr%A_Index%:= RegExReplace(A_LoopReadLine, "\D") 

While % IDArr%A_index%
{
winclose, Customer Complaint - Occurrence Details - Q-Pulse
winclose, Customer Complaint - Incident Details - Q-Pulse         
WinMinimizeAll
Sleep, 800

if (hWnd1) {
	if (hWnd2)
	DllCall("ShowWindow", ptrS, hWnd2, "Int", 6) ; Minimize LaunchPad window
	DllCall("ShowWindow", ptrS, hWnd1, "Int", 3) ; Maximize Custom Filter window
	Sleep, 50

	ControlClick, % editControl "11", % "ahk_id " hWnd1
	Sleep, 100
    Send, ^{end}
    Sleep, 100
    Send, ^+{home}
    Sleep, 100
	Send % "comp-" . IDArr%A_index%
	Sleep, 100
	Send {Enter}
	Sleep, 3000
	Loop 6
	{
		Send, ^{o}
		sleep, 1000
		IfWinActive, Details - Q-Pulse
			break
	}

winwait, _Customer Complaint - Incident Details - Q-Pulse
DllCall("ShowWindow", ptrS, hWnd4, "Int", 3) ; Maximize window	

ControlClick, % editControl "111", % "ahk_id " hWnd4
   Sleep, 100
    Send, ^{end}
    Sleep, 100
    Send, ^+{home}
    Sleep, 100
	Send % "250" 
	Sleep, 100
}
}
return
Appreciate your help
J

User avatar
mikeyww
Posts: 26894
Joined: 09 Sep 2014, 18:38

Re: Edit control not working

Post by mikeyww » 23 Apr 2021, 06:56

Since your script does not work, reduce it to a single line: the ControlClick. Provide all of the parameters directly on that line. See if you can get that working first.

You probably do not need this to paste some text. Try Control instead.

User avatar
boiler
Posts: 16933
Joined: 21 Dec 2014, 02:44

Re: Edit control not working

Post by boiler » 23 Apr 2021, 07:46

If it hasn't been able to interface with it at all yet, you might try running the script as administrator. Right-click on the script file in File Explorer and select "Run as administrator." If that works, then you can set up your script to automatically run itself as administrator. If Q-Pulse is running as an elevated process (as admin), then your script needs to be also.

just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Edit control not working

Post by just me » 23 Apr 2021, 10:00

Code: Select all

SetTitleMatchMode, 2 
...
winTitle4 := "_Customer Complaint - Incident Details - Q-Pulse"
...
hWnd4 := WinExist(winTitle4) ; Get Incident window hWnd
...
winclose, Customer Complaint - Incident Details - Q-Pulse         
...
winwait, _Customer Complaint - Incident Details - Q-Pulse
...
ControlClick, % editControl "111", % "ahk_id " hWnd4
Are you sure that hWnd4 is always targeting the right window?

JKnight_xbt33
Posts: 135
Joined: 18 Sep 2019, 02:06

Re: Edit control not working  Topic is solved

Post by JKnight_xbt33 » 07 May 2021, 06:32

HI all,
What has worked for me is just simplifying the controlclick without relying on hWnd

- Control and controlsettext work, however when i close the window the text is not saved in the field. Therefore controlclicking the field and sending the string works since it prompts the window to ask if i want to save the added info.

-having the code all on one line also didn't help and in fact caused a parameter invalid error.

Here's the code section that is working now:

Code: Select all

ControlClick , WindowsForms10.EDIT.app.0.2eed1ca_r9_ad111, _Customer Complaint - Incident Details - Q-Pulse
Send, ^{end} 
Sleep, 100
Send, ^+{home}
Sleep, 100 
Send 250
sleep, 1000
Send !{f4}
sleep,1000
Send {enter}
sleep, 1000

User avatar
boiler
Posts: 16933
Joined: 21 Dec 2014, 02:44

Re: Edit control not working

Post by boiler » 07 May 2021, 07:11

JKnight_xbt33 wrote:
What has worked for me is just simplifying the controlclick without relying on hWnd
There’s really no reason that wouldn’t work if implemented properly. If this works:

Code: Select all

ControlClick , WindowsForms10.EDIT.app.0.2eed1ca_r9_ad111, _Customer Complaint - Incident Details - Q-Pulse
...then this also must work:

Code: Select all

ThisHwnd := WinExist("_Customer Complaint - Incident Details - Q-Pulse")
ControlClick , WindowsForms10.EDIT.app.0.2eed1ca_r9_ad111, % "ahk_id " ThisHwnd

JKnight_xbt33 wrote: -having the code all on one line also didn't help and in fact caused a parameter invalid error.
Do you mean by putting all the WinTitle elements (such as adding the ahk_class) on one line? That sounds like you separated the elements with commas causing them to be placed in subsequent parameters instead of all in the WinTitle parameter. They would be separated with spaces, which wouldn’t cause that error.

If you mean combining all the lines of code in the script you just posted onto one line, then yes, that is incorrect syntax and not expected to work.

JKnight_xbt33
Posts: 135
Joined: 18 Sep 2019, 02:06

Re: Edit control not working

Post by JKnight_xbt33 » 12 May 2021, 08:04

Thanks,
I don't know why it did work when i simplified but i have a hunch that making 2 variables may have caused a problem;

With my original code below I made the wintitle variable then put it into the hWnd variable

Code: Select all

winTitle4 := "_Customer Complaint - Incident Details - Q-Pulse"
hWnd4 := WinExist(winTitle4) ; Get Incident window hWnd
ControlClick, % editControl "111", % "ahk_id " hWnd4
whereas with your code, you put the wintitle directly into the hWnd variable.

Code: Select all

ThisHwnd := WinExist("_Customer Complaint - Incident Details - Q-Pulse")
ControlClick , WindowsForms10.EDIT.app.0.2eed1ca_r9_ad111, % "ahk_id " ThisHwnd
Perhaps that is what I need to do in future

appreciated
J

User avatar
boiler
Posts: 16933
Joined: 21 Dec 2014, 02:44

Re: Edit control not working

Post by boiler » 12 May 2021, 08:28

In the two versions of code you just posted, the difference is not due to the hwnd variables. They are identical in assigning the actual hwnd to hwnd4/ThisHwnd. What is different is the naming of the control Are you sure that the variable editControl contains exactly WindowsForms10.EDIT.app.0.2eed1ca_r9_ad? You can put this statement before the ControlClick line to check it:

Code: Select all

MsgBox, % "Control name is" . (editControl = "WindowsForms10.EDIT.app.0.2eed1ca_r9_ad" ? "" : " not") . " correct"

JKnight_xbt33
Posts: 135
Joined: 18 Sep 2019, 02:06

Re: Edit control not working

Post by JKnight_xbt33 » 25 May 2021, 11:56

HI boiler,
I've tested using your message box script and both of them gave the output saying Control name is correct.

So not sure what to make of it. Perhaps it is indeed the hWnd that causes a bug somehow.

I've also checked and the hWnd 4 and it matches with what i defined at the start of the script (wintitle4)

thanks
J

Post Reply

Return to “Ask for Help (v1)”