Hi all,
I have used ControlClick successfully many times before when I want to click the control I am referencing. However I am having trouble getting my head around clicking buttons that I can't reference directly.
For a program I use at work, I need to click on a series of buttons whose locations always remain the same but whose instance numbers change depending on how many assets there are that day. However, one button is always a constant instance number.
Now, using MouseMove I can get the mouse to move to each of these buttons by referencing the known constant instance.
;Find the known button position
$buttonpos = ControlGetPos("", "", "[CLASS:QWidget; INSTANCE:22]")
;Move the mouse to button 1
MouseMove($buttonpos[0] + 20, $buttonpos[1] -50)
Sleep(2000)
;Move the mouse to button 2
MouseMove($buttonpos[0] + 40, $buttonpos[1] -50)
Sleep(2000)
Now, I can use MouseClick to click these buttons but it actually moves the mouse, which I am trying to avoid. I know I can sample the mouse position and return the mouse fairly quickly, but it seems messy when I think I should be able to do what I want with ControlClick, which does not move the mouse. However, this code does not work:
;Click button 1
ControlClick("", "", "[CLASS:QWidget; INSTANCE:22]", "left", 1, 20, -50)
Sleep(2000)
;Click button 1
ControlClick("", "", "[CLASS:QWidget; INSTANCE:22]", "left", 1, 40, -50)
Sleep(2000)
Can anyone enlighten me as to why this does not work? Is there any debug or way I can set Windows to see where the ControlClick is actually clicking on the screen? Is there a better way to do this without moving the mouse?