Page 5 of 5

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

Posted: 14 Apr 2017, 18:54
by phasermaniac
Do you think ahkhid can help?
https://autohotkey.com/board/topic/5357 ... -glovepie/
This guy seems that did something similar and says:
I have been successfully getting raw HID input (which must then be parsed) from my wacom cintiq with the AHKHID library

<!-- m -->http://www.autohotke... ... ght=ahkhid<!-- m -->

There are some test apps that you can use to capture your tablet's HID I/O messages. I also use BlockInput to block the tablet driver from adjusting the mouse, and use Autohotkey to handle the mouse movement instead

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

Posted: 29 Apr 2017, 11:05
by evilC
It would certainly be worth speaking to the interception guys, I dunno if Interception can do what you want, but they probably would.
AHKHID is going to be of no use at the moment, it uses the same technique as MouseDelta (Reading via RawInput API)
Our stumbling block is with blocking / intercepting.

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

Posted: 19 May 2017, 15:24
by bestguest
Hi,

Thank you for making these scripts! I want to implement your sniper-mode script but I am completely new to ahk....I was searching around for a way to change my DPI since my mouse has no driver or buttons to switch it and came accross your thread.
So I downloaded the LIBRARY, the first code in the first post and saved it as "MouseDelta.ahk" and then downloaded sniper-mode into same folder. Ran sniper-mode as administrator but when I press F12 the mouse sensitivity doesnt change.
What am I doing wrong?
If you could help out a noob in need :) I would be very grateful!
Also, how can I tweak the script to, make the mouse move faster instead of slower, at 600 DPI instead from default 400dpi while holding a button?

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

Posted: 03 Jun 2017, 11:57
by evilC
For anyone interested, I managed to implement MouseDelta as a C# DLL - see here

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

Posted: 18 Nov 2017, 20:51
by masheen
evilC wrote:For anyone interested, I managed to implement MouseDelta as a C# DLL - see here
Can i to simulate this delta using PostMessage?

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

Posted: 27 Mar 2018, 03:13
by brutus_skywalker
Helgef wrote: Someone asked for a mouse recorder in the ask for help section, so I tried to make a simple one.
My idea was, to save the delta info, eg, dx,dy, and then playback is simply MouseMove,dx,dy,0,R.
I realised quite quickly, that if you have any mouse acceleration or sensitivity settings on the mouse, the delta info doesn't match the mouse cursor, this is of course as (should be) expected, I felt stupid.
However, when I disabled these settings, to verify that my mouse recorder worked, in principle at least, I found that still some delta info seemed to be lost.
....
Sup dude, did you by any chance complete this mouse recorder, by all indications i'm guessing the code in that post was relating to an implementation as a UCR plugin.

I was wondering if you could post an abstraction of sorts that allows something like this, i only ask because you might have already done it, just as plugin for UCR:

Code: Select all

MouseDelta_start()   ;starts recording mouse delta to global deltaX & deltaY, concatenating all movements to one global variable pair
MouseDelta_stop()    ;stops recording, such that the movement pair recorded above can be used to replay that mouse delta movement.

MouseMove3D(){		;rough but gets the idea across, i hope.
Global
;recreate mouse delta movement, handy in games where coordinate based movement is effectively useless, this should allow moving the mouse in 3D space - i think - when paired with mouse delta data.

;move mouse single units movement, as massive jumps per deltaX 'distance' seamingly results in movement jumps that result in inconsistent movement,especially if deltaX exceeds the dimensions of the monitor.
Loop, deltaX
	{
	If A_Index = deltaX
		Break
	DllCall("mouse_event", "UInt", 0x01, "UInt", 1, "UInt", 0)
	}
Loop, deltaY
	{
	If A_Index = deltaY
		Break
	DllCall("mouse_event", "UInt", 0x01, "UInt", 0, "UInt", 1)
	}
}

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

Posted: 27 Mar 2018, 04:05
by Helgef
Hello, maybe I have something, I do not recall, I will check later. Please send me a pm in a few days if I forget.

Cheers.

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

Posted: 05 Jun 2018, 15:09
by carlitototo
Hello Hello !
First post here, and kind of a noob to ahk, otherwise wuldn't be asking this selly question ! ! !

How do we use this librairy ?! Like, I can't figure out how to properly do something with it !

To explain the whole thing, I'm creating a bot for a game called trove to use multiple account at the same time on the same computer and reproduce the movement of the first game instance to the otherones, we got the key binded, works flawlessly, and even have an autolog, because loading 7 accounts is time consumming ( can't run more, computer can't handle it ! ). But since we need to bind the mouse movement, and this is the only option I found ( and probably the best ) How can I use it to send mouse movements to other instances ? I tried to test with the example above, but couldn't do anything, really a noob I guess ^^

Someone is up for help ?

Merci beaucoup :)

- Carlitototo

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

Posted: 11 Sep 2018, 08:27
by Ducky
Yeah, can we get some code that presses d when it moves to the right, and presses a for left? I am a total novice in programming too.

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

Posted: 11 Sep 2018, 11:57
by evilC
Ducky wrote:Yeah, can we get some code that presses d when it moves to the right, and presses a for left? I am a total novice in programming too.
This is exactly what Sample Script 2 does.

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

Posted: 11 Sep 2018, 11:58
by evilC
carlitototo wrote:Hello Hello !
First post here, and kind of a noob to ahk, otherwise wuldn't be asking this selly question ! ! !

How do we use this librairy ?! Like, I can't figure out how to properly do something with it !

To explain the whole thing, I'm creating a bot for a game called trove to use multiple account at the same time on the same computer and reproduce the movement of the first game instance to the otherones, we got the key binded, works flawlessly, and even have an autolog, because loading 7 accounts is time consumming ( can't run more, computer can't handle it ! ). But since we need to bind the mouse movement, and this is the only option I found ( and probably the best ) How can I use it to send mouse movements to other instances ? I tried to test with the example above, but couldn't do anything, really a noob I guess ^^

Someone is up for help ?

Merci beaucoup :)

- Carlitototo
This library is not for sending mouse movement, it is for responding to it

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

Posted: 18 May 2019, 18:45
by Scr1pter
Hey guys I need your help.

I downloaded this script (which leads to this thread):

Code: Select all

#SingleInstance force
;Mausgeschwindigkeit einstellen

;Call below to accelerate the mouse input. The first two parameters are the integer factors of artificial amplification added on top of the physical input.
;The first is for horizontal/x-axis movement, the second for vertical/y-axis movement.
;new MouseAccelerator(0, 1) ; ORIG
;new MouseAccelerator(0, 0.8) ; Neu
new MouseAccelerator(0, 0.7) ; Scheint am besten zu sein

; Gets called when mouse moves or stops
; x and y are DELTA moves (Amount moved since last message), NOT coordinates.
MouseAcceleratorEvent(x := 0, y := 0, accelerationx := 2, accelerationy := 2)
{
  static MouseAcceleratorPaused
  if !(MouseAcceleratorPaused)
  {
    MouseAcceleratorPaused := true
    VarSetCapacity(MouseInput, 28, 0)
    NumPut(x * accelerationx, MouseInput, 4, "Int") ; dx
    NumPut(y * accelerationy, MouseInput, 8, "Int") ; dy
    NumPut(0x0001, MouseInput, 16, "UInt") ; MOUSEEVENTF_MOVE = 0x0001
    DllCall("SendInput", "UInt", 1, "UInt", &MouseInput, "Int", 28)
    Sleep, -1
    MouseAcceleratorPaused := false
  }
}
; ================================== LIBRARY ========================================
; Instantiate this class and pass it a func name or a Function Object
; The specified function will be called with the delta move for the X and Y axes
; Normally, there is no windows message "mouse stopped", so one is simulated.
; After 10ms of no mouse movement, the callback is called with 0 for X and Y
; https://autohotkey.com/boards/viewtopic.php?f=19&t=10159
Class MouseAccelerator 
{
  __New(accelerationx := 2, accelerationy := 2, callback := "MouseAcceleratorEvent")
  {
    static DevSize := 8 + A_PtrSize
    static RIDEV_INPUTSINK := 0x00000100

    this.TimeoutFn := this.TimeoutFunc.Bind(this)
    this.Callback := callback
    this.Accelerationx := accelerationx
    this.Accelerationy := accelerationy
    ; Register mouse for WM_INPUT messages.
    VarSetCapacity(RAWINPUTDEVICE, DevSize)
    NumPut(1, RAWINPUTDEVICE, 0, "UShort")
    NumPut(2, RAWINPUTDEVICE, 2, "UShort")
    NumPut(RIDEV_INPUTSINK, RAWINPUTDEVICE, 4, "Uint")
    ; WM_INPUT needs a hwnd to route to, so get the hwnd of the AHK Gui.
    ; It doesn't matter if the GUI is showing, it still exists
    Gui +hwndhwnd
    NumPut(hwnd, RAWINPUTDEVICE, 8, "Uint")

    this.RAWINPUTDEVICE := RAWINPUTDEVICE
    DllCall("RegisterRawInputDevices", "Ptr", &RAWINPUTDEVICE, "UInt", 1, "UInt", DevSize)
    fn := this.MouseMoved.Bind(this)
    OnMessage(0x00FF, fn)
  }
  __Delete()
  {
    static RIDEV_REMOVE := 0x00000001
    static DevSize := 8 + A_PtrSize
    RAWINPUTDEVICE := this.RAWINPUTDEVICE
    NumPut(RIDEV_REMOVE, RAWINPUTDEVICE, 4, "Uint")
    DllCall("RegisterRawInputDevices", "Ptr", &RAWINPUTDEVICE, "UInt", 1, "UInt", DevSize)
  }
  ; Called when the mouse moved.
  ; Messages tend to contain small (+/- 1) movements, and happen frequently (~20ms)
  MouseMoved(wParam, lParam)
  {
      ; RawInput statics
      static DeviceSize := 2 * A_PtrSize, iSize := 0, sz := 0, offsets := {x: (20 + A_PtrSize * 2), y: (24 + A_PtrSize * 2)}, uRawInput
      static axes := {x: 1, y: 2}

      ; Find size of rawinput data - only needs to be run the first time.
      if (!iSize)
      {
        r := DllCall("GetRawInputData", "UInt", lParam, "UInt", 0x10000003, "Ptr", 0, "UInt*", iSize, "UInt", 8 + (A_PtrSize * 2))
        VarSetCapacity(uRawInput, iSize)
      }
      sz := iSize ; param gets overwritten with # of bytes output, so preserve iSize
      ; Get RawInput data
      r := DllCall("GetRawInputData", "UInt", lParam, "UInt", 0x10000003, "Ptr", &uRawInput, "UInt*", sz, "UInt", 8 + (A_PtrSize * 2))
      x := NumGet(&uRawInput, offsets.x, "Int")
      y := NumGet(&uRawInput, offsets.y, "Int")
      this.Callback.(x, y, this.Accelerationx, this.Accelerationy)

      ; There is no message for "Stopped", so simulate one
      fn := this.TimeoutFn
      SetTimer, % fn, -10
  }
  TimeoutFunc()
  {
    this.Callback.(0, 0)
  }
}
From what I understood, this script makes it impossible to work with a simple MouseMove, x, y, 0.
For this reason I tried it with DLL calls, like: DllCall("mouse_event", "UInt", 0x8001, "UInt", 19318, "UInt", 648)
With some calculation it's possible to convert the x and y positions to the absolute values.

Code: Select all

F6::
MouseGetPos, x, y ; Retrieve current mouse position
xKonvertiertMaus := x * 26 ; convert current x mouse position
yKonvertiertMaus := y * 84 / 100 ; convert current y mouse position
SetFormat Float, 0.0 ; Remove digits after comma
WinGetPos, xStart, yStart, breite, höhe, A ; Retrieve x, y, width and height
xKonvertiert := xStart * 26 ; convert xstart position of window
yKonvertiert := yStart * 84 / 100 ; convert ystart position of window
xZiel := xKonvertiertMaus + xKonvertiert ; Calculate final xMouse position
yZiel := yKonvertiertMaus + yKonvertiert ; Calculate final yMouse position
Sleep, 1000
DllCall("mouse_event", "UInt", 0x8001, "UInt", xZiel, "UInt", yZiel) ; Move mouse cursor to its original position
return
However, in some cases the mouse cursor jumps to y0.
I just made some quick calculations, but it seemed to work.

Is it perhaps possible to pause the big script, which accelerates y?
Unfortunately, it unpauses itself as soon as I move the mouse cursor.
I tried to modify it but failed.

I basically want to continue using MouseMove, x, y, 0.
How can I solve the problems?

Thanks for any help!

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

Posted: 28 May 2019, 11:10
by evilC
DllCall("mouse_event"... is functionally identical to DllCall("SendInput" ...

NEITHER of them can move the mouse to a specific point on the screen, both of them move the mouse by a RELATIVE amount (eg "10 units left of the current position")

Also, neither of these move the mouse in PIXELS, they move the mouse in MICKEYS