Jump to content

_MouseMovePlus()


Oxin8
 Share

Recommended Posts

This is a function I made when I found the Battlefield 1984 didn't use the desktop cursor, rather it had it's own. There's no easy way to explain this but I'm gonna try. _MouseMovePlus() uses the "mouse_event", a low level mouse simulator. What's that mean? It means that whatever you pass to it, the computer treats it as though it came from the mouse. MOST PEOPLE WILL NEVER NEED THIS. I'm not gonna lie. If you're not looking for this, you probably won't use it. If, on the other hand, you're trying to bot in a game but a supposedly simple MouseMove() has a result of about 63 times more than what you expected, you came to the right place.

Here's the function:

Func _MouseMovePlus($X, $Y,$absolute = 0)
        Local $MOUSEEVENTF_MOVE = 1
    Local $MOUSEEVENTF_ABSOLUTE = 32768
    DllCall("user32.dll", "none", "mouse_event", _
            "long",  $MOUSEEVENTF_MOVE + ($absolute*$MOUSEEVENTF_ABSOLUTE), _
            "long",  $X, _
            "long",  $Y, _
            "long",  0, _
        "long",  0)
EndFunc

It takes an X and a Y and an option parameter. The $absolute parameter specifies when or not to use relative or absolute coords. Relative is the default. In relative mode, X and Y is the distance you want to move relative to the current mouse position. In absolute mode, X and Y are values from 0 to 65535 where (65535,65535) is the bottom right corner.

To use this the same way as MouseMove(), this is what you'd do:

_MouseMovePlus($X*(65535/@DesktopWidth), $Y*(65535/@DesktopHeight),1)

Here is the MSDN of the function.

Like I said, if you're not looking for this, you'll probably never use it. Feel free to ask questions about it if I didn't explain well enough.

***NOTE: I just got a nice wake up IM with someone needing help using this. I haven't been active on these forums in over a year due to school and the like but if you need help, just hit me up on AIM: Oxin8 and I'll be more than willing to help as long as you have a valid question and know what you're talking about. None of that "Can you make me an Aimbot for <insert game>?" crap.***

Edited by Oxin8
Link to comment
Share on other sites

no, i want to be able to use the mouse_event coords relatively. I only added the multiplication in my example to show that it's not the same i guess. Battlefield 1942 uses the mouse_event coords so when you use autoit's MouseMove(), the cursor moves about 60 times as far as you want it to. Understand now?

Link to comment
Share on other sites

  • 3 months later...
  • Moderators

Nice code i was wondering if you could help me with something?

How would you use the _MouseMovePlus() function to make the cursor move and click the left mouse button at a certain colour?

Look at PixelSearch() in the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 11 months later...
  • 4 months later...

Hi can you help me. I try to use your Script to go to some fix points into a game but i dont understand how to define a fix point ;)

Here my testscript but i always get an Error when i start it :P

Hope you can help me :)

Func _MouseMovePlus($X, $Y,$absolute = 0)

Local $MOUSEEVENTF_MOVE = 1

Local $MOUSEEVENTF_ABSOLUTE = 32768

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

"long", $MOUSEEVENTF_MOVE + ($absolute*$MOUSEEVENTF_ABSOLUTE), _

"long", $X, _

"long", $Y, _

"long", 0, _

"long", 0)

EndFunc

HotKeySet("{PAUSE}", "start")

HotKeySet("{ESC}", "quit")

Func start()

While 1

_MouseMovePlus($X*(65535/@DesktopWidth), $Y*(65535/@DesktopHeight),1)

Sleep(10)

WEnd

EndFunc

Func quit()

Exit 0

EndFunc

While 1

Sleep(10)

WEnd

Link to comment
Share on other sites

  • 2 weeks later...

hey there!

i built a little aimbot with this function...

CODE
HotKeySet("{f3}","stop")

HotKeySet("{f2}","pause")

HotKeySet("{f1}","start")

while 1

sleep(1)

WEnd

func start()

while 1

sleep(10)

$pos=pixelsearch(@DesktopWidth/2-200,@DesktopHeight/2-200,@DesktopWidth/2+200,@DesktopHeight/2+200,8355968,10)

if not @error then

_MouseMovePlus($pos[0]*(65535/@DesktopWidth), $pos[1]*(65535/@DesktopHeight),1)

EndIf

WEnd

EndFunc

func pause()

while 1

sleep(10)

WEnd

EndFunc

func stop()

Exit

EndFunc

Func _MouseMovePlus($X, $Y,$absolute = 0)

Local $MOUSEEVENTF_MOVE = 1

Local $MOUSEEVENTF_ABSOLUTE = 32768

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

"long", $MOUSEEVENTF_MOVE + ($absolute*$MOUSEEVENTF_ABSOLUTE), _

"long", $X, _

"long", $Y, _

"long", 0, _

"long", 0)

EndFunc

and i got a problem with it...

if it finds the color the mouse moves anywhere on my screen but not to the (red) pixel :) any ideas?

and sorry for my english...im as new to that as i am to autoit ;)

PS:nice work Oxin8!

Edited by brotwurst
Link to comment
Share on other sites

  • 11 months later...

Cheers for this, it works perfectly with the game freelancer. The only "problem" because mouse sensitivity can be configured within the game, moving 10 pixel from the code actually result 13 pixel move of the mouse cursor within the game. It is not a big problem anyway, I just need to divide all the coordinates by 1.3 and I get almost the exact result what I want.

Thanks for this again!

Link to comment
Share on other sites

  • 4 years later...

This one supposedly emulates another mouse level when MouseMove() doesn't works.

This is for a game, freelancer. Just got into AutoIt3 Today, and realized the mistake myself, thanks. Now I have problems with the coordinates.

Should I do this with the gaem at fullscreen, or run it at windowed mode. I am using the AutoITinfo tool in client mode, so the coordinates I get should work on fullscreen, right?

Also, second issue, the game is taking the coordinates in RELAtive mouse position. here what I got now: (note desktop res=Game res)

 

I use the infotool in that mode becuase it worked before, howeverm I don't know If I should use the coordmode on screen, or client. Suggestions? Remeber it is fullscreen,

Although I would change it to Windowed mode if it becomes easier.

-snip-

Edited by Jos
Link to comment
Share on other sites

Please read the forum rules especially in regards to game automation help requests.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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