mouse/touch click??

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pootler
Posts: 9
Joined: 19 Jan 2018, 17:18

mouse/touch click??

19 Jan 2018, 17:37

HI
New to the forums :-)
I wonder if any of you great people out there can help me with a problem.
I am trying to get a hotkey that will simulate a mouse click .
I can do this on the normal desktop, but when I open the program i will be using, it won't click the area of the window that is in focus??
I have tried ''IfWinActive', but I am not sure what info I need to identify the program in focus, and also where this line goes in the script?

Any help would be appreciated

pootler :D
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: mouse/touch click??

20 Jan 2018, 16:54

Try:

Code: Select all

#If WinActive("ahk_exe notepad.exe")
Q::Click, 100, 100
Replace notepad.exe with the executable name of the program that you're using and the numbers with the coordinates that you want to click at.
pootler
Posts: 9
Joined: 19 Jan 2018, 17:18

Re: mouse/touch click??

20 Jan 2018, 19:55

Thanks very much for the reply.
That doesnt seem to work :-(
To try and eliminate things, I set up a very simple hotkey script to simulate a mouse click,
I then opened several programs, manually placed the mouse over various controls , and ran the hotkey.
Most of the programs ( and apps) reacted correctly, as if I had clicked the mouse in the program.
However, when I open the specific program I use ( it is called 'Centrafuse', and is a carpc program), and do the same thing, the program does not react?
Do I somehow need to identify the program, or title a bit more clearly??

Thanks

pootler
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: mouse/touch click??

20 Jan 2018, 20:03

Is this program run with administrator privileges? Your script would also need to be run with admin permissions. (Right click the script, select "Run as Administrator".)
pootler
Posts: 9
Joined: 19 Jan 2018, 17:18

Re: mouse/touch click??

22 Jan 2018, 07:21

No The prog does not have privileges, BUT i ran the script with it, and success!
NOw for some reason with multiple presses of the script the mouse seems to move sometimes?
I guess I need to find someway of locking it to the control window?

I don't quite understand how to assign a window title and such,
I guess just experiment?

Many Thanks

Keith
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: mouse/touch click??

22 Jan 2018, 14:12

You might be interested in Window Spy which can be accessed by right-clicking the tray icon (by the system clock) of a running script.

The only way that I imagine the mouse moving, if you're doing only Click commands in AHK, is if the window itself is moving as a result of being clicked. Would be odd behavior and I can't say I've witnessed such a thing before except for clicking on the Minimize/Maximize buttons on a program. You might be able to circumvent that issue by using CoordMode, Mouse, Absolute.
pootler
Posts: 9
Joined: 19 Jan 2018, 17:18

Re: mouse/touch click??

22 Jan 2018, 17:11

HI,

Thanks very much for your help so far.
I have posted another thread with this next problem as it seemed a bit off topic from the original subject,
Let me explain though.
I am using an mce remote to control this software.
From the pictures you can see , when I use this software at its opening screen, then my script ( Media_Next:: Click, 745,50 ) clicks the correct part of the screen
i.e the 'next track/previous track' buttons.
Everything works fine- until I then call up one of the programs, e.g DigiRx ( a DAB radio program )
When thatprogram embeds into the centre part of the screen, as you can see, the mouse moves down onto ( what I am guessing) is the 'active' window.
Same when i click the 'Music' program. ( haven't got nav sorted yet :-) )
NO amount of further script running will get the mouse back, UNLESS I select the opening screen again.
I think that things go wrong when the focus falls to the windows that are embedded?

How can I make sure the mouse clicks at the same point ( focused or not) every time?
Many Thanks

pootler
Attachments
centrafuse 3.PNG
opening music program
centrafuse 3.PNG (63.29 KiB) Viewed 2412 times
centrafuse2.PNG
opening DAB program
centrafuse2.PNG (67.09 KiB) Viewed 2412 times
centrafuse1.PNG
opening screen
centrafuse1.PNG (54.94 KiB) Viewed 2412 times
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: mouse/touch click??

22 Jan 2018, 17:33

I'm not sure, hopefully someone familiar with the app can help you. It looks like a simple GUI designed/skinned to look fancy, so you might look at using Window Spy to identify a Control Value for the Next/Previous controls to use in the command ControlClick. (This would not move the normal mouse cursor, but trick the program into thinking you clicked on the button.)

Otherwise, run some testing with both Window Spy reporting the Window Position in each of those scenarios (opening screen / DAB / music programs) and also trying to use the WinGetPos command on the original window ("mce remote"? or "centrafuse"?)
pootler
Posts: 9
Joined: 19 Jan 2018, 17:18

Re: mouse/touch click??

23 Jan 2018, 14:47

O.K,
I have found a possible kludge method of working >-)
If I click OUTSIDE of the program window, and then rerun the script, the mouse clicks back in the correct position.
How do I send two consecutive mouse clicks to two different destinations with one key stroke?
Can that be done with AHK?

Many THanks

Pootler
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: mouse/touch click??

23 Jan 2018, 22:45

You'd need to make your hotkey multiline, such as:

Code: Select all

q::
Click, 100, 100
Click, 200, 100
return
You may need to put a Sleep between the clicks.

As a bonus, you may be interested in using WinSet to set the window to be AlwaysOnTop, then you can click on another window without worrying about your program being hidden. You may also find it better to use WinActivate to activate a different program instead of clicking outside of your remote control/media player program, so that you don't actually cause an action in the other program, like navigating to a different website or clicking the "Self Destruct Computer" button.
pootler
Posts: 9
Joined: 19 Jan 2018, 17:18

Re: mouse/touch click??

24 Jan 2018, 08:06

Many Thanks for all your help.

Only fine tuning required now.

Have a great day

Pootler :D
pootler
Posts: 9
Joined: 19 Jan 2018, 17:18

Re: mouse/touch click??

25 Jan 2018, 19:14

HI,

Just thought I'd let you know, with the help of this forum I found a more elegant solution.

i.e. CoordMode, Mouse, Screen
Click, 1200, 70

- ignores any active windows, and clicks in the same position every time!

Cheers

Pootler

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat and 250 guests