MouseMove Not Working When Over Certain Window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
john68
Posts: 11
Joined: 09 Nov 2015, 15:38

MouseMove Not Working When Over Certain Window

12 Oct 2019, 20:11

When my mouse pointer is over the Window I would to work with, commands such as MouseMove and MouseClick do not work. I have another program running simultaneously with my AHK script that is somehow interfering with these (and probably other) commands.

My AHK hotkeys DO trigger the functions in my script, but these commands are ignored. If I add, for example, "msgbox, running the function", the dialogue box appears. In the script below, I activate the given window (that is underneath the pointer)...then if I add "WinGetActiveTitle", this works as well (I can use msgbox, %Title% to confirm this)

MouseGetPos gets the correct Window %id% as shown by Window Spy, but Window Spy does not provide the Window's class (it's blank).

If I am over a different Window (i.e. Notepad), the function executes correctly.

What might be preventing MouseMove/MouseClick from working?

Code: Select all

MyFunction()
{
	CoordMode, Pixel, Relative
	CoordMode, Mouse, Relative
	
	MouseGetPos, tx, ty, id, control
	WinActivate, ahk_id %id%
	
	sleep, 70
	MouseMove, 305, 461  ; only added in hopes that it helped
	sleep, 70
	MouseClick, left, 305, 461
			
	CoordMode, Mouse, Screen
	CoordMode, Pixel, Screen
	return
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: MouseMove Not Working When Over Certain Window

12 Oct 2019, 20:33

You might try running your script as admin. If that doesn't work, the program may be doing something to purposely ignore virtual mouse actions, especially if it's a game.
john68
Posts: 11
Joined: 09 Nov 2015, 15:38

Re: MouseMove Not Working When Over Certain Window

12 Oct 2019, 20:47

Wow, a thousand-and-one thanks, it worked! I can't tell you how much you've helped. I've been wrestling with this problem for about 18 hours now, posting on three different software forums.

The answer was a simple (and perhaps obvious) one, but I would not have though of it. (I've been working heavily with computers since 1978 and still don't think of these things!)

ThanX again!
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: MouseMove Not Working When Over Certain Window

12 Oct 2019, 20:54

You're welcome. You have me beat by a couple years. :D I got my first computer (an Atari 800) in 1980.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: MouseMove Not Working When Over Certain Window

13 Oct 2019, 01:27

I would suggest carefully considering the implications of running the script as administrator, and also reading the UAC FAQ.
john68
Posts: 11
Joined: 09 Nov 2015, 15:38

Re: MouseMove Not Working When Over Certain Window

14 Oct 2019, 02:58

lexikos wrote:
13 Oct 2019, 01:27
I would suggest carefully considering the implications of running the script as administrator, and also reading the UAC FAQ.
This is a script I wrote myself. I'm not worried about my script being hijacked.
john68
Posts: 11
Joined: 09 Nov 2015, 15:38

Re: MouseMove Not Working When Over Certain Window

14 Oct 2019, 03:02

boiler wrote:
12 Oct 2019, 20:54
You're welcome. You have me beat by a couple years. :D I got my first computer (an Atari 800) in 1980.
Haha, I began working on my teacher's TRS-80 in 1978 and got a "Bally" computer (with Bally Basic!) in 1980 and graduated to an Atari 400 in 1982, followed quickly by an Atari 800. 8KB RAM and cassette storage was incredible!
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: MouseMove Not Working When Over Certain Window

15 Oct 2019, 03:06

john68 wrote:
14 Oct 2019, 02:58
This is a script I wrote myself. I'm not worried about my script being hijacked.
Hijacked? :?

I was referring to the side-effects of running as administrator that are mentioned in the FAQ.
utap2001
Posts: 1
Joined: 22 Feb 2020, 08:41

Re: MouseMove Not Working When Over Certain Window

09 Oct 2020, 06:20

boiler wrote:
12 Oct 2019, 20:33
You might try running your script as admin. If that doesn't work, the program may be doing something to purposely ignore virtual mouse actions, especially if it's a game.
Really great information.
It helps a lot. :thumbup:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, supplementfacts and 200 guests