detecting when mouse is moving left/right and hold a key Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
smash

detecting when mouse is moving left/right and hold a key

20 Jul 2018, 15:26

I am trying to write a script for a game, where when you are moving your mouse to the left, hold q, and while you are moving your mouse to the right hold e. it makes controls easier for the game I play
so if i'm dragging my mouse to the left it holds down q until I stop
I couldnt find any help on the forums so I came here
(keep in mind I have never wrote a single autohotkey script so don't expect me to know what i'm doing :lol:)
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: detecting when mouse is moving left/right and hold a key  Topic is solved

21 Jul 2018, 06:58

Try

Code: Select all

#NoEnv
#SingleInstance Force

toggle := "" ; Initialize variable

; Press F1 to enable/disable  mouse moving recognition
$F1::
	if toggle := !toggle ; Set variable to true/false
		SetTimer MouseGesture, 10
	else
		SetTimer MouseGesture, off
return

MouseGesture:
	mX1 := ""
	mX2 := ""
	mY1 := ""
	mY2 := ""
	MouseGetPos, mX1, mY1
	Sleep, 10
	MouseGetPos, mX2, mY2
	If (abs(mX2-mX1) < 10) and (abs(mY2-mY1) < 10)  ; mouse moving stopped
	{
		Send {q Up}
		Send {e Up}
		ToolTip
		return
	}
	else
	If (mY1 < (mX1-(mX2-mY2))) and !(mY1 < ((mX2+mY2)-mX1))
	{
		If (mX2 < mX1) 	; Gesture_L
		{
			ToolTip Gesture_L
			Send {q down}
		}
	}
	else
	If (mY2 < (mX2-(mX1-mY1))) and !(mY2 < ((mX1+mY1)-mX2))
	{
		If (mX2 > mX1) 	; Gesture_R
		{
			ToolTip Gesture_R
			Send {e down}
		}
	}
return
smashisnotugly
Posts: 3
Joined: 20 Jul 2018, 15:22

Re: detecting when mouse is moving left/right and hold a key

21 Jul 2018, 10:38

GEV wrote:Try

Code: Select all

#NoEnv
#SingleInstance Force

toggle := "" ; Initialize variable

; Press F1 to enable/disable  mouse moving recognition
$F1::
	if toggle := !toggle ; Set variable to true/false
		SetTimer MouseGesture, 10
	else
		SetTimer MouseGesture, off
return

MouseGesture:
	mX1 := ""
	mX2 := ""
	mY1 := ""
	mY2 := ""
	MouseGetPos, mX1, mY1
	Sleep, 10
	MouseGetPos, mX2, mY2
	If (abs(mX2-mX1) < 10) and (abs(mY2-mY1) < 10)  ; mouse moving stopped
	{
		Send {q Up}
		Send {e Up}
		ToolTip
		return
	}
	else
	If (mY1 < (mX1-(mX2-mY2))) and !(mY1 < ((mX2+mY2)-mX1))
	{
		If (mX2 < mX1) 	; Gesture_L
		{
			ToolTip Gesture_L
			Send {q down}
		}
	}
	else
	If (mY2 < (mX2-(mX1-mY1))) and !(mY2 < ((mX1+mY1)-mX2))
	{
		If (mX2 > mX1) 	; Gesture_R
		{
			ToolTip Gesture_R
			Send {e down}
		}
	}
return
thank you but, that spams the letter q and spams the letter e when moving mouse, i want it to hold the letter q and hold the letter e, not spam it. thanks for the help though i appreciate it :D :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, jameswrightesq and 289 guests