I would like a script like this, i know this is possible i just don't know how to do it
I move my mouse to the right and it presses D
I move my mouse to the left and it presses A
Auto Strafe Script?
Auto Strafe Script?
Last edited by Vitze on 01 Nov 2015, 16:47, edited 1 time in total.
-
- Posts: 204
- Joined: 24 Jun 2015, 23:38
Re: Auto Strafe Script?
What have you tried so far?
Re: Auto Strafe Script?
You need to be more specific.
Do you want "absolute" mode or "relative" mode?
Absolute:
A point on your mouse mat is considered "center". If the mouse is to the right of it (even if it is not moving), then D will be held.
Relative:
If the mouse is currently moving right, hold D, else hold nothing.
AFAIK, neither of these are possible by reading the mouse position using regluar AHK commands (ie MouseGetPos)
This is because games do not read the *position* of the cursor, they read mouse "delta" (change in position) information.
If they read position instead of delta, mouse input would stop working when the (hidden) cursor hit the edge of the screen - ie you could not endlessly turn left or right). Absolute mode is much harder to implement than Relative.
What you probably need to achieve this is the windows RawInput API (ie user32.dll\GetRawInputData).
This is not a subject for the novice programmer.
You can find code that uses the DLL calls that you need to make here: https://github.com/evilC/RollMouse/blob ... lmouse.ahk
Do you want "absolute" mode or "relative" mode?
Absolute:
A point on your mouse mat is considered "center". If the mouse is to the right of it (even if it is not moving), then D will be held.
Relative:
If the mouse is currently moving right, hold D, else hold nothing.
AFAIK, neither of these are possible by reading the mouse position using regluar AHK commands (ie MouseGetPos)
This is because games do not read the *position* of the cursor, they read mouse "delta" (change in position) information.
If they read position instead of delta, mouse input would stop working when the (hidden) cursor hit the edge of the screen - ie you could not endlessly turn left or right). Absolute mode is much harder to implement than Relative.
What you probably need to achieve this is the windows RawInput API (ie user32.dll\GetRawInputData).
This is not a subject for the novice programmer.
You can find code that uses the DLL calls that you need to make here: https://github.com/evilC/RollMouse/blob ... lmouse.ahk
Re: Auto Strafe Script?
this code work as you wish.Vitze wrote:I would like a script like this, i know this is possible i just don't know how to do it
I move my mouse to the right and it presses D
I move my mouse to the left and it presses A
Code: Select all
while 1
{
MouseGetPos, x,y
diff := x - oldx
if (diff > 0)
{
send, D
oldx := x
}
else if (diff < 0)
{
send, A
oldx := x
}
}
return
Esc::
ExitApp
Last edited by GS SAHU on 05 Nov 2015, 10:48, edited 1 time in total.
Re: Auto Strafe Script?
This code will probably not work properly with games.GS SAHU wrote:this code work as you wish.Vitze wrote:I would like a script like this, i know this is possible i just don't know how to do it
I move my mouse to the right and it presses D
I move my mouse to the left and it presses A
Code: Select all
while 1 { MouseGetPos, x,y diff := y - oldy if (diff > 0) { send, D oldy := y } else if (diff < 0) { send, A oldy := y } } return Esc:: ExitApp
You will only be able to turn right until the mouse hits the right edge of the screen.
Many games also keep the mouse cursor in the center of the screen, so it may not work at all.
Re: Auto Strafe Script?
i don't know about game interface. sorry , for in code use y in place of x.evilC wrote:This code will probably not work properly with games.GS SAHU wrote:this code work as you wish.Vitze wrote:I would like a script like this, i know this is possible i just don't know how to do it
I move my mouse to the right and it presses D
I move my mouse to the left and it presses A
Code: Select all
while 1 { MouseGetPos, x,y diff := y - oldy if (diff > 0) { send, D oldy := y } else if (diff < 0) { send, A oldy := y } } return Esc:: ExitApp
You will only be able to turn right until the mouse hits the right edge of the screen.
Many games also keep the mouse cursor in the center of the screen, so it may not work at all.
Code: Select all
while 1
{
MouseGetPos, x,y
diff := x - oldx
if (diff > 0)
{
send, D
oldx := x
}
else if (diff < 0)
{
send, A
oldx := x
}
}
return
Esc::
ExitApp
Re: Auto Strafe Script?
Its not about game interface, its about the way a mouse works.
The script you posted only sends input when the mouse cursor changes position.
You are playing a racing game, and are taking a long right hand corner...
You move the mouse right, you start the turn, the mouse hits the right edge of the screen.
Doh! You cannot turn right any more.
So even in a best case scenario (Game does not mess with mouse cursor), this script cannot possibly work properly.
The script you posted only sends input when the mouse cursor changes position.
You are playing a racing game, and are taking a long right hand corner...
You move the mouse right, you start the turn, the mouse hits the right edge of the screen.
Doh! You cannot turn right any more.
So even in a best case scenario (Game does not mess with mouse cursor), this script cannot possibly work properly.
Re: Auto Strafe Script?
I took my existing mouse reading code (Uses the RawInput API) and packaged it into a library, with mouse -> keyboard as the sample code.
The link is here.
http://ahkscript.org/boards/viewtopic.php?f=19&t=10159
Take the sample script, and comment out the static KeyMap line for Arrow Keys and uncomment the line for WSAD.
If you wish only A and D to work (Not W and S), then use the following keymap line: static KeyMap := {l: "a", r: "d"} ; AD
Run the script, hitting F12 toggles on/off mapping of mouse to WSAD
The link is here.
http://ahkscript.org/boards/viewtopic.php?f=19&t=10159
Take the sample script, and comment out the static KeyMap line for Arrow Keys and uncomment the line for WSAD.
If you wish only A and D to work (Not W and S), then use the following keymap line: static KeyMap := {l: "a", r: "d"} ; AD
Run the script, hitting F12 toggles on/off mapping of mouse to WSAD
Who is online
Users browsing this forum: No registered users and 61 guests