Click on painted 'buttons' AND NOT moving cursor

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bazkeys
Posts: 98
Joined: 20 Jan 2021, 21:58

Click on painted 'buttons' AND NOT moving cursor

02 Aug 2021, 02:45

I have a third party app that paints buttons on a window, the 'buttons' (not really buttons) it paints are clickable and can bring up information. I've been struggling trying to code a hotkey to click them, but these buttons are not available as controls, so I have to use click, %x%, %y%, which of course sends the mouse cursor to those coordinates, as controlsend, controlclick or anything else I've tried (and I've tried just about everything) to click on the painted button without the pointer having to move to the location doesn't work. From what I've seen in Autohotkey documentation there is no way to send a click without moving the cursor unless it's to a control (or a named image), but before I totally give up the idea, thought I should ask here. Note: I don't want the cursor to move whatsoever, clicking and moving back to the original coordinates wouldn't be a solution for instance.
User avatar
boiler
Posts: 16974
Joined: 21 Dec 2014, 02:44

Re: Click on painted 'buttons' AND NOT moving cursor

02 Aug 2021, 05:16

bazkeys wrote: From what I've seen in Autohotkey documentation there is no way to send a click without moving the cursor unless it's to a control (or a named image)
You can use ControlClick based on a location, not just a named control, so if that’s the reason you’ve dismissed it, you should try using it in that mode. And you can use ImageSearch or Gdip_ImageSearch to locate the button by searching for a small block of its color, especially if it’s like my app that works similar to what you described in which I specify the button colors.

bazkeys wrote: I don't want the cursor to move whatsoever, clicking and moving back to the original coordinates wouldn't be a solution for instance.
Is this because of the time it takes to move the mouse pointer back? Using 0 for the Speed parameter of MouseMove, it’s barely noticeable that the mouse pointer was moved.
bazkeys
Posts: 98
Joined: 20 Jan 2021, 21:58

Re: Click on painted 'buttons' AND NOT moving cursor

02 Aug 2021, 05:35

@boiler
Yeah, I tried the coordinates method and it doesn't work. I tried everything I could for months, including PostMessage etc.

I saw something about imagesearch before, but problem is the painted button GUI can vary. Anyway I'll take another look at that, but not confident of it working.

The problem I'm finding with mouse click is that it is not actually working 100% of the time in this case, anytime I got controlclick to work in other circumstances it's been 100% reliable at least.
User avatar
boiler
Posts: 16974
Joined: 21 Dec 2014, 02:44

Re: Click on painted 'buttons' AND NOT moving cursor

02 Aug 2021, 05:40

bazkeys wrote: The problem I'm finding with mouse click is that it is not actually working 100% of the time in this case
There are often ways to address this, such as using MouseMove to move the cursor to the location first, then clicking on it. Sometimes activating the window on which you’ll be clicking is necessary (you could then activate the window that was previously active again).
bazkeys
Posts: 98
Joined: 20 Jan 2021, 21:58

Re: Click on painted 'buttons' AND NOT moving cursor

02 Aug 2021, 05:52

@boiler
Thanks once again, I tried activating the window before and sometimes I think it helps, and other times I think it makes no difference, either way it still hasn't been 100% reliable.
I also tried various mouse moving and clicking options, nothing has been quite 100% successful. I will try out some further mouse move and click options, I didn't actually have the Mousemove speed set to 0, had that field blank, so perhaps that might make a difference. I probably won't get to look at this for another good few hours, but hopefully can get the mouse moving and clicking working, if it worked 100% then it would suffice.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Click on painted 'buttons' AND NOT moving cursor

02 Aug 2021, 10:22

It sounds like this may be an issue with the default click timing.

Try adding this to the top of your script and see if it helps.

Code: Select all

SetMouseDelay, 30
https://www.autohotkey.com/docs/commands/SetMouseDelay.htm
bazkeys
Posts: 98
Joined: 20 Jan 2021, 21:58

Re: Click on painted 'buttons' AND NOT moving cursor

03 Aug 2021, 02:07

@Hellbent

That change seems to be working,thanks very much. I need to see it for a bit longer, but looking positive :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Peiya, ShatterCoder and 307 guests