Using mousemove as a hotkey

Get help with using AutoHotkey and its commands and hotkeys
Cinemaster
Posts: 31
Joined: 01 Jun 2017, 09:05
Facebook: Gene Beidl

Using mousemove as a hotkey

26 Aug 2017, 19:21

Is it possible to use mouse movements as a hotkey?

I'm trying to fix the y position of the mouse based on the value of a variable, but I don't want to press any modifier or other keys.

The idea is simple. I press a hotkey combo which saves the mouse's current y position and sets the FIX variable to 1. When I move the mouse, this triggers the 'mousemove' hotkey which first checks if FIX is 1. If it is, it moves the mouse to it's current x position but the fixed y position. If not, it returns and waits for the next mousemove. If I press the hotkey combo again, FIX is set = 0 and so no restriction occurs.

Can this be done?
obeeb
Posts: 140
Joined: 20 Feb 2014, 19:15

Re: Using mousemove as a hotkey

26 Aug 2017, 21:00

There is no "mousemove" hotkey but you can do something like the following:

Code: Select all

CoordMode, Mouse, Screen
SetBatchLines -1

#MaxThreadsPerHotkey 2
!1::
	fix := !fix
	MouseGetPos, , my
	while(fix) {
		MouseGetPos, mx
		MouseMove, mx, my
	}
return
#MaxThreadsPerHotkey
User avatar
Reloaded
Posts: 281
Joined: 25 Aug 2017, 08:48

Re: Using mousemove as a hotkey

27 Aug 2017, 08:12

jeah with this

MouseMove, +0, +0, 10, R

By the first "0" make "+" and Random number and the Mouse move right.

By the first "0" make "-" and Random number and the Mouse move left.

By the second "0" make "+" and Random number and the Mouse move down.

By the second "0" make "-" and Random number and the Mouse move Up.


If you want the Mouse move faster Make the "10" to "1" and the Mouse Move instant if you want the Mouse move slow let the "10"

Np :)
Cinemaster
Posts: 31
Joined: 01 Jun 2017, 09:05
Facebook: Gene Beidl

Re: Using mousemove as a hotkey

27 Aug 2017, 14:08

Hi Obeeb,

Thanks for the response. I think I see what you're doing there. When 'fix' is set, you stay in the loop and just adjust the mouse y position continuously. Then, when you hit the hotkey again, you reset 'fix' and both the first and second threads exit. Very clever.

It seems like this will eat up a lot of cycles. Is there no way to keep from looping continuously? I guess the lack of a 'mousemove' hotkey makes this the best solution.

Thanks again!

@Reloaded, I believe you misunderstood the question. I wasn't asking about how to use mousemove, but rather capturing the mouse move event when it happens from a user.
obeeb
Posts: 140
Joined: 20 Feb 2014, 19:15

Re: Using mousemove as a hotkey

27 Aug 2017, 14:26

Cinemaster wrote:It seems like this will eat up a lot of cycles. Is there no way to keep from looping continuously?
You can add Sleep to the loop or use SetTimer instead of looping. This will make the mouse move in a more jittery way, depending on what you want you can play with it and see what results you will get.

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot] and 36 guests