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 )
detecting when mouse is moving left/right and hold a key Topic is solved
-
- Posts: 3
- Joined: 20 Jul 2018, 15:22
Re: detecting when mouse is moving left/right and hold a key Topic is solved
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
-
- Posts: 3
- Joined: 20 Jul 2018, 15:22
Re: detecting when mouse is moving left/right and hold a key
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 itGEV wrote:TryCode: 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
-
- Posts: 3
- Joined: 20 Jul 2018, 15:22
Who is online
Users browsing this forum: filipemb and 310 guests