Sign in to follow this  
Followers 0
Oxin8

Moving the mouse in game window

24 posts in this topic

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.

Share this post


Link to post
Share on other sites



maybe

("MouseCoordMode", 0)

look for Autoit Options in help

8)


NEWHeader1.png

Share this post


Link to post
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.

Share this post


Link to post
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()

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Not sure exactly what it uses but it's possibly a software mouse emulation routine that's part of the main BF1942 program. As to how to get around this, sorry but I have no idea.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Would the MouseCoordMode function have any effect on the coords (rather than changing via DLL call)?

Share this post


Link to post
Share on other sites

Ah ok. Is your function now working correctly for BF1942 or is the mouse still moving a little erratically?

Share this post


Link to post
Share on other sites

So how are you calling it using other autoit funtions? Can you give an example?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Cool - look forward to seeing it.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

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

No mouse movement.


[center]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.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0