kornholeking Posted June 21, 2022 Posted June 21, 2022 Hello, I hope this is a severe oversight on my part as I feel that I understand how to use the ControlClick function fairly decently, but for some reason when I am attempting to use the following lines the second ControlClick command below does not open the context menu within the application that I am attempting to right click within: WinActivate("Default") WinWaitActive("Default") ControlClick("Default", "", 1005, "primary", 1, 150, 10) ControlClick("Default", "", 1005, "secondary", 1, 150, 10) I am able to manually right click on the location in question within the application to bring up the context menu. I threw in the first ControlClick above to ensure that the function is finding the correct control ID and location by single (left) clicking which highlights an object within the application, so I can confirm that that first ControlClick is working. For grins, I opened up a blank Notepad to test the same lines above and was able to pull up the context menu. I also tried swapping my mouse buttons to see if that would make any impact and then I was able to primary (right) click but still unable to secondary (left) click to bring up the context menu within my application. As a workaround, I am using the MouseClick function which seems to work fine. However, I've noticed that the window of the application in question tends to move around upon launch (sometimes even offscreen) and the MouseClick function has gotten caught up when reaching the edge of the screen. WinActivate("Default") WinWaitActive("Default") Opt("MouseCoordMode", 2) MouseClick($MOUSE_CLICK_SECONDARY, 150, 45) All signs point to my application being the culprit here for some reason, but I was wondering if anyone else has come across this sort of a scenario or what other options might be available as I'd prefer to use the ControlClick function since MouseClick seems to run into the challenges I mentioned above.
ioa747 Posted June 21, 2022 Posted June 21, 2022 try to give some sleep time between Sleep(50) I know that I know nothing
ioa747 Posted June 21, 2022 Posted June 21, 2022 Alternatively try Send("{APPSKEY}") I know that I know nothing
kornholeking Posted June 21, 2022 Author Posted June 21, 2022 @ioa747Neither seem to have any impact. I can see the initial "primary" click, the pause from sleep, and then nothing. When I try without the first ControlClick (still keeping the pause), it just seems to not to anything after the window is activated. 🤷♀️
ioa747 Posted June 21, 2022 Posted June 21, 2022 Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) ; Send a mouse click to the edit control of Notepad using the handle returned by WinWait. ControlClick($hWnd, "", "Edit1") ; Add new data to the clipboard. ClipPut("A new string added to the clipboard.") Sleep(50) ControlClick($hWnd, "", "Edit1","secondary",1) Send("{DOWN 4}") Send("{ENTER}") Sleep(50) Send("{ENTER}") ; Alternatively try Send("{APPSKEY}") Sleep(3000) Send("{APPSKEY}") Send("{DOWN 4}") Send("{ENTER}") EndFunc ;==>Example I know that I know nothing
kornholeking Posted June 21, 2022 Author Posted June 21, 2022 @ioa747Just wanted to reiterate that I have tested the ControlClick "secondary" command and confirmed that it works in a notepad. Send("{APPSKEY}") also works in notepad. Neither option works in this particular app/window that I am currently working with, though.
ioa747 Posted June 21, 2022 Posted June 21, 2022 which application is that? I know that I know nothing
ioa747 Posted June 21, 2022 Posted June 21, 2022 it's that run in android Virtual Environment? I know that I know nothing
kornholeking Posted June 23, 2022 Author Posted June 23, 2022 No, it's a Windows application. Specifically, it's running on Windows 10.
ad777 Posted June 24, 2022 Posted June 24, 2022 @kornho.. Maybe the app resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick(). none
kornholeking Posted June 28, 2022 Author Posted June 28, 2022 @ad777Thanks for the input. If you take a look at the first snippet of code in my initial post, you can see that I did/do have WinActivate prior to the ControlClick function.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now