[Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Post gaming related scripts
User avatar
evilC
Posts: 3412
Joined: 27 Feb 2014, 12:30

[Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

05 Nov 2015, 16:22

MouseGetPos and other methods of retrieving mouse axis input are fundamentally flawed when it comes to games, because many games mess with the mouse cursor (Keep on moving it to middle of screen etc) or other limitations (eg when the cursor reaches the edge of the screen, you cannot generate any more input in that direction)

Games that do not operate by mouse cursor (eg FPS) generally read the mouse by "Delta" information - that is, the amount that it moved in each direction since the last update.

This library uses the RawInput API to read these Delta Move packets.

Note: If you wish to write scripts that send mouse movement at the kinds of rates that real mice operate at, see my LLMouse library.
================================== LIBRARY ========================================

Code: [Select all] [Expand] [Download] (MouseDelta.ahk)GeSHi © Codebox Plus



================================== SAMPLE SCRIPT 1 ========================================
A diagnostic utility to show you the input that comes from a mouse, in real-time

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



================================== SAMPLE SCRIPT 2 ========================================
An example of usage that can map mouse axes to WSAD or Arrow keys is included.
If you wish to map mouse to Joystick, see my cVJoyinterface library on GitHub (Link in Sig).
There is also a complete Mouse to Joystick script in the Oneswitch-Utilities repo.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



================================== SAMPLE SCRIPT 3 ========================================
How to implement a "Sniper Mode" with any mouse.
When sniper mode is OFF (Default), it multiplies mouse movement by the value you set in ScaleFactor.
When you turn it off, it stops amplifying movement.
You will likely need to turn the mouse sensitivity down in the game to compensate.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by evilC on 17 Jun 2017, 14:29, edited 5 times in total.
Too
Posts: 3
Joined: 10 Feb 2016, 07:23

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

10 Feb 2016, 12:14

I've been looking a script like this for very long time and the game i need it for is CS:S for BunnyHopping, if u want u can go to youtube and search for "css bhop" to see and understand what excatly what im looking for. So the problem is atm that when i jump and start strafing (moving mouse to the right and left constantly nonstop) i dont get the same speed as i get when im doing this manually. It feels like when i move my mouse to one direction it presses A or D only once or max few times but not holding it down constantly because when i do it manually for example run straight W down, then jump and turn 180 degrees right with D manually it turn around instantly and very sharply without loosing any speed and with the Script if i do the same the turn around doesnt go as sharp as it was manually and that because it feels that it doesnt hold the D down all the way trough the 180 turn. I was thinking that 1 solution would be if it was possible to make it like this: when the script detects the mouse moving right direction it holds down "D" EVEN if the movement is NOT constant BUT if u move the mouse even 1 pixel to the LEFT direction it will unpress the D and hold down A instead. And the same goes here. Hope u understand what i mean.

Not sure if that's even possible to do with script but thank you anyways, much appreciate it ^^
HelloThere

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

20 Feb 2016, 06:54

Hello,

I am not PRO in these things so please excuse my describtion.
I have very similar problem. I am playing game where all classic mouse clickers are blocked. It works only in Windows 7 but when I ALT+TAB to the game it stops immediately.

Could you please help me? I would be ok if the script would just nonstop click left mouse button. But no

Thank you very much.
User avatar
evilC
Posts: 3412
Joined: 27 Feb 2014, 12:30

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

20 Feb 2016, 10:08

This code is nothing to do with mouse clicks I am afraid, it is only to do with mouse movement.

I would be surprised if the game you are playing cannot see AHK's clicks. Try running the script as admin (Right click AHK file, Run As Admin) and try making AHK hold the mouse button down for longer (50ms is normally enough) as if AHK is holding the mouse button down for too short a time, many games do not recognize it.
HelloThere

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

20 Feb 2016, 11:40

Thanks for reply.

I am really big noob in programming. Could you show me how the script should be please?

Thank you very much!
HelloThere

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

20 Feb 2016, 12:37

Code: [Select all] [Download] GeSHi © Codebox Plus

F10::Click
Click Down ; Mouse button down
Sleep 50 ; xx ms delay
Click Up ; Mouse button up


It doesn't work. I tried sleep 30,50,100,1000
User avatar
evilC
Posts: 3412
Joined: 27 Feb 2014, 12:30

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

23 May 2016, 12:53

Try running the script as administrator (Right-click AHK file, run as admin)

If that doesn't work,add this line to the start of the script: SetKeyDelay,0,50
zeno

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

07 Jul 2016, 04:42

Hello, I'm very interested in this type of script and I tried this script in Fallout NV and Csgo but it didn't work :(
zeno

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

08 Jul 2016, 10:34

My bad, I read that it could map WSAD or Arrow keys to mouse axes while it does the opposite. I'm sorry. :crazy:
By the way have you ever made a keys to mouse axes script?
Tactical Shrimp
Posts: 31
Joined: 11 Nov 2015, 22:29

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

09 Jul 2016, 13:44

alright thank you for this however i am stumped i have a script with a gui and a dropdown and you select a line and a different mousemove script activates so my question is the mouse move script that i had worked in menus of the game and windows desktop however in the game itself it didn't work i have a new mousemove but this one cant go under 1 and 1 is way to fast for my DPI and sensitivity here it is

{code}
; v Left or Right (Negative or Positive)
DllCall("mouse_event", uint, 1, int, -1, int, 1, uint, 0, int, 0)
; ^ Up or Down (Negative or Positive)
{/code}
i labeled the values i know what do but i have no idea what the other ones do is there one in there that can change the speed if so please let me know well the thing about your code is that i cant make heads or tales of it im new to ahk but i do know c++ and this is wildly different for the most part
User avatar
SnowFlake
Posts: 363
Joined: 28 Apr 2015, 05:41
Google: floowsnaake
GitHub: floowsnaake
Contact:

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

10 Jul 2016, 09:36

"i have a script with a gui"

can you share the script?
Tactical Shrimp
Posts: 31
Joined: 11 Nov 2015, 22:29

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

10 Jul 2016, 12:59

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



there is my script i dont know why you need the whole thing but there it is
User avatar
evilC
Posts: 3412
Joined: 27 Feb 2014, 12:30

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

10 Jul 2016, 14:45

SendMode Input("mouse_event",uint,1,int,-1,int,1,uint,0,int,0)?
Shouldn't that be DllCall("mouse_event",uint,1,int,-1,int,1,uint,0,int,0)?
Tactical Shrimp
Posts: 31
Joined: 11 Nov 2015, 22:29

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

10 Jul 2016, 22:48

evilC wrote:SendMode Input("mouse_event",uint,1,int,-1,int,1,uint,0,int,0)?
Shouldn't that be DllCall("mouse_event",uint,1,int,-1,int,1,uint,0,int,0)?

yea it was that i dont know why that changed but that isnt the problem is there a way to make the speed of the mouse slower
User avatar
evilC
Posts: 3412
Joined: 27 Feb 2014, 12:30

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

11 Jul 2016, 08:35

No, a mouse_event of 1 unit is literally the smallest movement you can make with a mouse.
With moves of 1 unit, normally a single mouse_event would do next to nothing, you would have to execute lots (ie 100 or so) within a short timeframe (eg 1 every ms) to simulate normal mouse movement.
User avatar
evilC
Posts: 3412
Joined: 27 Feb 2014, 12:30

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

11 Jul 2016, 09:21

Yeah... It seems like he omitted a critical line from the code he posted...

This is what he was quoting, but he omitted the Loop statement.

Code: [Select all] [Download] GeSHi © Codebox Plus

$F2::
Loop, 3
; ↓ Left or Right (Negative or Positive)
DllCall("mouse_event", uint, 1, int, 2, int, 2, uint, 0, int, 0)
; ↑ Up or Down (Negative or Positive)
return

So I am guessing that 1 mouse_event is not too much, he just issued 3 with no delay between, which is a VERY quick movement.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests