dexto Posted April 10, 2009 Posted April 10, 2009 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)EndFuncWorks 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).aspxSo you say _MouseMoveRelative (100, 0) but it moves like 600help...?
KaFu Posted April 10, 2009 Posted April 10, 2009 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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Authenticity Posted April 10, 2009 Posted April 10, 2009 Relative movement as well as absolute mouse coordinates are not calculated like that, by rather like this, from another site: Global Const $MOUSEEVENTF_MOVE = 0x01 Func _MouseMoveRelative($iX, $iY) Local $dX = $iX*(65535.0/(@DesktopWidth-1)) Local $dY = $iY*(65535.0/(@DesktopHeight-1)) ;. ;. ;. EndFunc
dexto Posted April 10, 2009 Author Posted April 10, 2009 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
dexto Posted April 10, 2009 Author Posted April 10, 2009 Quote Global Const $MOUSEEVENTF_MOVE = 0x01Func _MouseMoveRelative($iX, $iY) Local $dX = $iX*(65535.0/(@DesktopWidth-1)) Local $dY = $iY*(65535.0/(@DesktopHeight-1)) ;. ;. ;.EndFunci did try it but is it moving mouse to farthere 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
Authenticity Posted April 10, 2009 Posted April 10, 2009 So what about SetCursorPos? Func _MouseMoveRelative($iX, $iY) $aPos = MouseGetPos() DllCall('user32.dll', 'int', 'SetCursorPos', 'int', $aPos[0] + $iX, 'int', $aPos[1] + $iY) EndFunc
dexto Posted April 10, 2009 Author Posted April 10, 2009 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.
Authenticity Posted April 10, 2009 Posted April 10, 2009 #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.
dexto Posted April 10, 2009 Author Posted April 10, 2009 (edited) 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 April 10, 2009 by dexto
JRowe Posted April 10, 2009 Posted April 10, 2009 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. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center]
dexto Posted April 10, 2009 Author Posted April 10, 2009 @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
dexto Posted April 10, 2009 Author Posted April 10, 2009 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!
dexto Posted April 11, 2009 Author Posted April 11, 2009 (edited) 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 April 11, 2009 by dexto
Authenticity Posted April 11, 2009 Posted April 11, 2009 (edited) 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 April 11, 2009 by Authenticity
dexto Posted July 25, 2009 Author Posted July 25, 2009 On 4/11/2009 at 6:49 AM, 'Authenticity said: 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now