Jump to content
Miliardsto

ControlClick instead MouseClick

Recommended Posts

Miliardsto

Hello I got this script works below and I want to do not move cursor on screen when action is performed.

Opt("MouseCoordMode", 1) ; cause it gets whole screen coords
     Local $x, $y
     Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0)
          If $search = 1 Then
             MouseMove($x, $y,0)
             MouseClick("right", $x, $y))
             MouseMove($xMiddle, $yMiddle,0)
             MouseClick("left", $xMiddle, $yMiddle)
          EndIf

I changed this above to this below and what happen is. It clicks right button and then left button but not move mouse to $x $y and then to $xMiddle $yMiddle.

Opt("MouseCoordMode", 1) ; cause it gets whole screen coords
     Local $x, $y
     Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0)
          If $search = 1 Then
             ControlClick("","",0,"secondary",1,$x,$y)
             ControlClick("","",0,"primary",1,$xMiddle,$yMiddle)
          EndIf

If needed I got handle in var $hwnd

Please tell me how parameters in ControlClick would like be

Share this post


Link to post
Share on other sites
JLogan3o13

@Miliardsto the whole point of ControlClick is to interact with the button without the need for the less-reliable MouseMove/MouseClick combo. It sounds as though it is working as you have it written, it clicks the buttons. If you need to move the mouse specifically to a position, you would still need to use the MouseMove line. But I would ask first why you need the mouse to be at that exact position.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Zedna

$x and $y are absolute Desktop's positions not relative to position of your control.

When you want to have full control of mouse you may use direct mouse API functions, look at my MouseClickFast & MouseMoveFast:

 

  • Like 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Lecdev
      By Lecdev
      Can anyone tell me the default parameter to input into, GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "")  to disable a previously set user defined function?
      help file example says empty string ("") which works for other events but doesnt seem to on mouse move.
      Ive attached some of my test code to select icon by clicking and click on screen where needed to create an icon the same or cancel by right clicking and then escape the window with the keyboard escape key. best solution i have come up with after a few hours of trying different things is to create a DoNothing() function
       
      any help would be appreciated.
      dummy2.au3
    • c1one
      By c1one
      Something simple enough, and I am sure it's an oversight, but I have not been able to track this down. The entire script is attached, but here is the point of failure.
      Note: I am getting the "Error: subscript used on non-accessible variable" but I thought the initial line of:
      AutoItSetOption('MouseCoordMode', 0)
      Should address that issue? 
      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      ; Install updates (minimized and updating for many minutes)
      ; Updates Not Installed Screen
         ; Wait for updates to complete
      WinWait("ProSeries Update")
         ; Wait just over 9 minutes to ensure popup is ready (test alternative to WinWait)
      Sleep(550000)
         ; Set focus on Product Licenses window
      WinActivate("ProSeries Update")
         ; Send Mouse Click to Install Now button
      MouseClick ( "left" [, 581, 362 [, clicks = 1 [, speed = 10]]] )
      ; end Installing Updates screen
      >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       
      Thanks for any insights!
      c1one
      ProSeries2017_No_Customer_Info.au3
    • Tats
      By Tats
      Hi everyone,
      I have a problem with ControlClick function. It doesn't work no matter how I tried all the possible combination of the parameters.
      Below is the scripts of possible parameter combination:
      ;ControlClick("title","text","controlID ","button","clicks","x","y") ;title= Title, Class, Handle ;controlID= Class, ClassNN, Instance ;Title here is empty when I check it with AutoIt Info ControlClick("", "", "[ScreenKeyboard::Button18]", "left", "1", "230","890") ControlClick("", "", "[CLASS:ScreenKeyboard::Button; INSTANCE:18]", "left", "1", "230","890") ControlClick("", "", "[INSTANCE:18]", "left", "1", "230","890") ;Title here is the Class of the window ControlClick("[ScreenKeyboard::SKFrame]", "", "[ScreenKeyboard::Button18]", "left", "1", "230","890") ControlClick("[ScreenKeyboard::SKFrame]", "", "[CLASS:ScreenKeyboard::Button; INSTANCE:18]", "left", "1", "230","890") ControlClick("[ScreenKeyboard::SKFrame]", "", "[INSTANCE:18]", "left", "1", "230","890") ;Title here is the Handle of the window ControlClick("[0x000907A0]", "", "[ScreenKeyboard::Button18]", "left", "1", "230","890") ControlClick("[0x000907A0]", "", "[CLASS:ScreenKeyboard::Button; INSTANCE:18]", "left", "1", "230","890") ControlClick("[0x000907A0]", "", "[INSTANCE:18]", "left", "1", "230","890") Am I coding it correctly?
      Thanks
    • MaximusCZ
      By MaximusCZ
      Hello, and apologies if this have been discussed before, but I googled and couldnt find anything relevant.
      I have a problem where I try to send a control clink into to a window. 
      Part of window I try to send clicks to looks like this . The black border is showing when I mouse over it Au3Info, I get following information:

      I am testing its interaction with code

      The result I get is that it makes control clicks trough first line, opens and closes menus, as expected.
      When It gets to second line, it does not click a single icon. I can tell that coords are correct as the dropdown menus (No view active) gets focused(altough not rolled out). Same behaviour happens if roughly 40<y<60, so I know I am hitting good height. You can look at how it behaves here: output.webm 
      Dropdown 1 focuses at around 8 sec mark, and 13 sec mark it changes to second dropdown, defocusing first one, seemingly not registering any clinks inbetween.
       
      Have you ever encountered similar behaviour? I need to click the Key button, first on second line, with controlclick (or any other way not hijacking the mouse). I cant trigger that button by keyboard and There is no other control having control over it.
      Help
       
    • Skysnake
      By Skysnake
      I need to automate a specific GUI from a legacy system written in C.
      The spy tool gives me this

      I use this code
      Local $swintit = WinGetTitle("[active]") ConsoleWrite("active Window " & $swintit & @CRLF) If $swintit = "FILES NOTES" Then ; If $swintit = "FILES NOTES" Then ; got Window, now atomate ConsoleWrite("got Window " & @CRLF) ; now focus, then click :) ;EditPaste ;ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(404, $GUI_Focus) ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(401, $GUI_Focus) ControlClick("FILES NOTES", "", 401, $acno) ; click okay EndIf ; If $swintit = "FILES NOTES" Then The idea is to paste the acno value into the edit box, then click an Okay button.
      I get a console write that the active Window is as expected, but my loop completes without ever writing anything into the GUI.
      I also tried the control ID as text "404" - same result
      What am I missing?
      Skysnake
       
×