Jump to content

Relative mouse movement


 Share

Recommended Posts

Lets cut to the chase:

Func _MouseMoveRelative ($iX, $iY)

Local Const $MOUSEEVENTF_MOVE = 0x01

DllCall ("user32.dll", "int", "mouse_event", _

"int", $MOUSEEVENTF_MOVE, _

"int", $iX, _

"int", $iY, _

"int", 0, _

"int", 0)

EndFunc

Works but the problem is that "Relative mouse motion is subject to the settings for mouse speed and acceleration level."

http://msdn.microsoft.com/en-us/library/ms646260(VS.85).aspx

So you say _MouseMoveRelative (100, 0) but it moves like 600

help...? :D

Link to comment
Share on other sites

Is there a reason to chose the hard way?

_MouseMoveRelative(300, 10)

Func _MouseMoveRelative ($iX, $iY)
    local $pos = MouseGetPos()
    MouseMove($pos[0] + $iX, $pos[1] + $iY,0)
EndFunc
Link to comment
Share on other sites

i can't try right not the simple way but the reason is that in most sooting games cursor is stuck in the middle and AutoIt as far as i know checks for a "current position" of the mouse to make sure mouse has reached the coordinates... and it never will (stuck in the middle)

btw

Func _MouseMoveRelative ($iX, $iY)
RegWrite("HKEY_CURRENT_USER\Control Panel\Mouse","MouseSpeed","REG_SZ",0)
RegWrite("HKEY_CURRENT_USER\Control Panel\Mouse","MouseSensitivity","REG_SZ",10)
    Local Const $MOUSEEVENTF_MOVE = 0x01
    DllCall ("user32.dll", "int", "mouse_event", _
                                "int", $MOUSEEVENTF_MOVE, _
                                "int", $iX, _
                                "int", $iY, _
                                "int", 0, _
                                "int", 0)
RegWrite("HKEY_CURRENT_USER\Control Panel\Mouse","MouseSpeed","REG_SZ",1)
RegWrite("HKEY_CURRENT_USER\Control Panel\Mouse","MouseSensitivity","REG_SZ",20)
EndFunc

reg is not helping :D

Link to comment
Share on other sites

Global Const $MOUSEEVENTF_MOVE = 0x01

Func _MouseMoveRelative($iX, $iY)

Local $dX = $iX*(65535.0/(@DesktopWidth-1))

Local $dY = $iY*(65535.0/(@DesktopHeight-1))

;.

;.

;.

EndFunc

i did try it but is it moving mouse to far

there is something about this...

"If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner."

Another this to consider: when mouse acceleration is off and mouse speed is 10 (0-20) it is working right moving the specified amount of pixels

Link to comment
Share on other sites

have to try that one 2... i think i did try it and is confirms placement of the cursor at the destination but i'll double check later.

but here is the thought:

Void MoveMouse(int x, int y)
{ 
  double fScreenWidth = GetSystemMetrics(SM_CXSCREEN) -1;
  double fScreenHeight = GetSystemMetrics(SM_CYSCREEN) -1;
  double fx = x*(65535.0f / fScreenWidth);
  double fy = y*(65535.0f / fScreenHeight);
  INPUT Input;
  Input.type = INPUT_MOUSE;
  Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
  Input.mi.dx = fx;
  Input.mi.dy = fy;
  SendInput(true, &Input, sizeof(INPUT));
}

what is the value of "MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE" to put for AutoIt?

i dono if the "0x01" is the right value for relative movement.

Link to comment
Share on other sites

#define MOUSEEVENTF_MOVE        0x0001 /* mouse move */
#define MOUSEEVENTF_LEFTDOWN    0x0002 /* left button down */
#define MOUSEEVENTF_LEFTUP    0x0004 /* left button up */
#define MOUSEEVENTF_RIGHTDOWN   0x0008 /* right button down */
#define MOUSEEVENTF_RIGHTUP  0x0010 /* right button up */
#define MOUSEEVENTF_MIDDLEDOWN  0x0020 /* middle button down */
#define MOUSEEVENTF_MIDDLEUP    0x0040 /* middle button up */
#define MOUSEEVENTF_XDOWN      0x0080 /* x button down */
#define MOUSEEVENTF_XUP      0x0100 /* x button down */
#define MOUSEEVENTF_WHEEL      0x0800 /* wheel button rolled */
#define MOUSEEVENTF_VIRTUALDESK 0x4000 /* map to entire virtual desktop */
#define MOUSEEVENTF_ABSOLUTE    0x8000 /* absolute move */

If you want to preform also the movement but without the speed and acceleration issue you can registerLineDDA and process the new coordinates in the user-defined callback function. Search MSDN if you want.

Link to comment
Share on other sites

i don't quite understand "register LineDDA and process the new coordinates in the user-defined callback function"

isn't LineDDA used for drawing a line?

but here is another one for absolute movement:

Func _MouseMoveAbsolute ($iX, $iY)
Local $dX = $iX*(65535.0/(@DesktopWidth-1))
Local $dY = $iY*(65535.0/(@DesktopHeight-1))
Local Const $MOUSEEVENTF_MOVE = 0x01
Local Const $MOUSEEVENTF_ABSOLUTE = 0x8000
    DllCall ("user32.dll", "int", "mouse_event", _
                                "int", $MOUSEEVENTF_MOVE+$MOUSEEVENTF_ABSOLUTE, _
                                "int", $dX, _
                                "int", $dY, _
                                "int", 0, _
                                "int", 0)
EndFunc

wow very informative post indeed thx Authenticity. I'm off to sleep for now.

Edited by dexto
Link to comment
Share on other sites

It's a geometric construct. It's used to draw things, too, but its also useful when you're doing math on things involving points and lines (such as determining what point to move your cursor to.)

Another thing to consider when you're building an aimbot is this: if you can modify the skins of opponents, then pixel bots are far easier and superior. Set the skins (after backing them up) to uniform ugly color, like 0x00FF00 that doesn't show up inside the game, then make a script that reads the pixel at your current mouse position, then clicks (or fires) when it encounters 0x00FF00.

This method has some major advantages, one of them being natural mouse movement that is indistinguishable from that of a good player, so that when server admins read your logs, there's not a whole lot of suspiciously jerky movements that give you away. The disadvantage of course is that you have to modify the skins, which can be tedious to get right, and is very detectable if they do checksums on textures in memory, which you'll have to intercept and modify. If this is the case, achieving the realtime packet relay and editing is also possible in AutoIt. It's a lot more complex than just the aimbot, but it's still easier than c++.

The compromise is searching a small area around your cursor, the Helper bot. This combines the speed and natural movement of normal play with the little extra accuracy that you want. The aimbot proof of concept I linked you to has various examples of types as well.

Link to comment
Share on other sites

@JRowe

Thx

I already have "trigger bot" that works exactly the way to described. Now i am going to test move mouse function above to introduce a "lock on" to a target when such is hover over.. its more of a aim helper at this point but its fun :D

Link to comment
Share on other sites

just to sum up Mouse Movement functions:

Note: to make function faster use

$dll = DllOpen("user32.dll")

and pass $dll to the function.

Func _MouseMoveRelative ($iX, $iY, $dll="user32.dll")
    DllCall ($dll, "int", "mouse_event", _
                                "int", 0x01, _
                                "int", 4+(Abs($iX)/400), _
                                "int", 4+(Abs($iY)/400), _
                                "int", 0, _
                                "int", 0)
EndFunc

4+(Abs($iX)/400) is an approximation +-50px you might need to adjust this for your mouse setup.

(i have max acceleration and precision enabled in my control panel)

NOTE: when Acceleration is Default (=10) and Precition helper is disabled this function works perfect without adjusting X and Y.

Func _MouseMoveAbsolute ($iX, $iY,$dll="user32.dll")
    DllCall ($dll, "int", "mouse_event", _
                "int", 0x8001, _
                                "int", $iX*(65535.0/(@DesktopWidth-1)), _
                                "int", $iY*(65535.0/(@DesktopHeight-1)), _
                                "int", 0, _
                                "int", 0)
EndFunc

Very interesting way of Absolute mouse movement.

Func _MouseMoveRelativeMimic($iX, $iY,$dll="user32.dll")
    $aPos = MouseGetPos()
    DllCall($dll, 'int', 'SetCursorPos',  'int', $aPos[0] + $iX, 'int', $aPos[1] + $iY)
EndFunc

Func _MouseMoveRelativeAU3 ($iX, $iY)
    local $pos = MouseGetPos()
    MouseMove($pos[0] + $iX, $pos[1] + $iY,0)
EndFunc

Thx everyone!

Link to comment
Share on other sites

So, I tested all the functions and the only one working properly for a shooting game (where screen moves cursor is always in one spot) is _MouseMoveRelative ($iX, $iY, $dll="user32.dll"). Well.. to say properly is to say that it is controllable but far from precipice.

Is there a way to disable mouse acceleration from AutoIt?

Edited by dexto
Link to comment
Share on other sites

There is an option to set or get the mouse speed and the two mouse threshold values:

Dim Const $SPIF_UPDATEINIFILE = 1
Dim Const $SPIF_SENDWININICHANGE = 2
Dim Const $SPI_GETMOUSE = 3
Dim Const $SPI_SETMOUSE = 4

Dim $tMouse = DllStructCreate('int;int;int')
Dim $aResult = DllCall('user32.dll', 'int', 'SystemParametersInfo', 'uint', $SPI_GETMOUSE, 'uint', 0, _
                       'ptr', DllStructGetPtr($tMouse), 'uint', 0)

If $aResult[0] Then 
    For $i = 1 To 3
        ConsoleWrite(DllStructGetData($tMouse, $i) & @TAB)
    Next
    ConsoleWrite(@LF)
EndIf

#cs
    DllStructSetData($tMouse, 1, 6)
    DllStructSetData(%tMouse, 2, 10)
    DllStructSetData($tMouse, 3, 1)
    
    $aResult = DllCall('user32.dll', 'int', 'SystemParametersInfo', 'uint', $SPI_SETMOUSE, 'uint', 0, _
                       'ptr', DllStructGetPtr($tMouse), 'uint', BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))
#ce
$tMouse = 0
Edited by Authenticity
Link to comment
Share on other sites

  • 3 months later...

There is an option to set or get the mouse speed and the two mouse threshold values:

Dim Const $SPIF_UPDATEINIFILE = 1
Dim Const $SPIF_SENDWININICHANGE = 2
Dim Const $SPI_GETMOUSE = 3
Dim Const $SPI_SETMOUSE = 4

Dim $tMouse = DllStructCreate('int;int;int')
Dim $aResult = DllCall('user32.dll', 'int', 'SystemParametersInfo', 'uint', $SPI_GETMOUSE, 'uint', 0, _
                       'ptr', DllStructGetPtr($tMouse), 'uint', 0)

If $aResult[0] Then 
    For $i = 1 To 3
        ConsoleWrite(DllStructGetData($tMouse, $i) & @TAB)
    Next
    ConsoleWrite(@LF)
EndIf

#cs
    DllStructSetData($tMouse, 1, 6)
    DllStructSetData(%tMouse, 2, 10)
    DllStructSetData($tMouse, 3, 1)
    
    $aResult = DllCall('user32.dll', 'int', 'SystemParametersInfo', 'uint', $SPI_SETMOUSE, 'uint', 0, _
                       'ptr', DllStructGetPtr($tMouse), 'uint', BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDWININICHANGE))
#ce
$tMouse = 0

That was what I finally anded up with, I changed the mouse speed and acceleration for the time of the game so that movement functions work properly.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...