Jump to content

Moving the mouse in game window


Oxin8
 Share

Recommended Posts

So I'm trying to move the mouse in Battlefield 1942 and it's moving a lot more than it should be. By using:

$temp = MouseGetPos()
MouseMove($temp[0] + 1, $temp[1])

It moves the cursor about 100 pixels to the right. I tried adding a decimal with no result(probably because the function simply doesn't support it). I think my only solution is to simulate mouse movement more directly. I also tried using a modified _MouseClickPlus that I called _MouseMovePlus and that didn't seem to do anything.

Func _MouseMovePlus($Window, $X = "", $Y = "")
        Local $WM_MOUSEMOVE  =  0x0200
    Local $temp
    $temp = WinGetHandle( $Window )
    if @error=1 then msgbox(0,"ERROR","Window Not Found")
    DllCall("user32.dll", "int", "SendMessage", _
            "hwnd",  $temp, _
            "int",   $WM_MOUSEMOVE, _
            "int",   0, _
            "long",  _MakeLong($X, $Y))
EndFunc

Any thoughts, ideas, or anything else would be highly appreciated.

Link to comment
Share on other sites

It's been in there for awhile. So that's not it.

I play a MMORP and I use AutoIT in the game. Here is the heading of my code:

#include <GUIConstants.au3>

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",1)

[quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()

Link to comment
Share on other sites

I would hazard a guess and say that BF1942 doesn't use a hardware mouse so trying to emulate a mouse movement with AutoIt won't work.

Well then, what do you think it uses? I'm not a newb so I can handle the dll calls and such if that's what I need. Could someone point me in the right direction whether it be how Battlefield gets the input or ways of detecting how it gets the input and maybe a possible idea to simulate it?
Link to comment
Share on other sites

i'd look at downloading 'WinSpecter spy'... it may help u

--hope this helps

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

I ended up figuring it out on my own and made a much lower level mouse movement function. The X and Y coords are relative although this could be changed in the dll call (check "mouse_event" out on MSDN).

positive x moves right

positive y moves down

Func _MouseMovePlus($X = "", $Y = "")
        Local $MOUSEEVENTF_MOVE = 0x1
    DllCall("user32.dll", "none", "mouse_event", _
            "long",  $MOUSEEVENTF_MOVE, _
            "long",  $X, _
            "long",  $Y, _
            "long",  0, _
        "long",  0)
EndFunc

maybe someone else will find a use for this.

Link to comment
Share on other sites

well, it's all for a much larger script that i hope to put in scripts and scraps by the end of the night but the line of code i'm using it in is:

If abs($input[7]) > 4000 Or abs($input[8])>4000 Then _MouseMovePlus($input[7]/3000,-1*($input[8]/3000))

where $input[7] and $input[8] are both variables from joystick input that range from -32768 to 32767. so the line of code basically moves the mouse corresponding to the joystick movement.

Link to comment
Share on other sites

I don't think that would work for games that use mouse emulation. I'm still scratching my head as to how Oxin8 has got his joystick working in a game that uses mouse emulation by using a user32.dll call. My understanding (and correct me if I'm wrong here) is that the games that use mouse emulation don't use the screen coordinates at all so functions that require absolute X & Y coords like MouseMove will always fail. I believe they use the mouseball / optical 'clicks' and emulate the mouse movement based on that. This means you would require a program (or DLLCall) that is able to move the mouse based on 'clicks', not screen coords. I could be way off here, but that's how it seems to me.

Link to comment
Share on other sites

For the DllCall I used, I only made it move relative instead of using coords. There's some flags that I could use to take screen coords and add click and make it more similar to MouseClick() if I wanted to. I don't really understand it completely but the call doesn't move the cursor. From my understanding, what it does is inject the movement into the input stream coming from the mouse itself. _MouseClickPlus() is actually very different from the function I made as it sends the mouse movement and click messages to a certain handle.

PartyPooper: If you don't get it still you can always PM me. Or if you have AIM my screenname is Oxin8.

Link to comment
Share on other sites

  • Moderators

For the DllCall I used, I only made it move relative instead of using coords. There's some flags that I could use to take screen coords and add click and make it more similar to MouseClick() if I wanted to. I don't really understand it completely but the call doesn't move the cursor. From my understanding, what it does is inject the movement into the input stream coming from the mouse itself. _MouseClickPlus() is actually very different from the function I made as it sends the mouse movement and click messages to a certain handle.

PartyPooper: If you don't get it still you can always PM me. Or if you have AIM my screenname is Oxin8.

Take a look at larry's ClickInControl() UDF... : http://www.autoitscript.com/forum/index.ph...indpost&p=37526

No mouse movement.

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

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...