Game Mouse issue

Ask gaming related questions (AHK v1.1 and older)
Mightykiller
Posts: 57
Joined: 09 Oct 2017, 13:34

Game Mouse issue

17 Feb 2018, 15:22

I am made a pixel search script it works fine but when i try it in a game, it will move my mouse wrong, because the game moves my mouse cursor to the middle

Game Name: Black Squad

Code: Select all

IF NOT A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}


#SingleInstance Force

SetMouseDelay, -1
settitlematchmode, 2
coordmode, mouse, screen
coordmode, pixel, screen
SetKeyDelay,-1, 1
SetControlDelay, -1
SetWinDelay,-1
SetBatchLines,-1





The_Color:=0x7C563E
switch:=1
sx:=0
sy:=0
ex:=A_ScreenWidth
ey:=A_Screenheight





NumPad1::

      

    Stop:=0
    i:=0
    While Stop = 0
    {
     
     PixelSearch, AimX, AimY,sx,sy,ex,ey, The_Color,2,Fast RGB
     if !ErrorLevel
        {
            
            tx:=AimX + 5
            ty:=AimY + 5
            Click, %tx% %ty%
            


        }
     }       
    return



NumPad2::
    Mousegetpos,px,py
    PixelGetColor,The_Color,px,py,RGB
    Return
    
NumPad3::
    Stop:=1
    Return
Mightykiller
Posts: 57
Joined: 09 Oct 2017, 13:34

Re: Game Mouse issue

18 Feb 2018, 11:57

H e l p
User avatar
eventhorizon
Posts: 158
Joined: 27 Oct 2016, 14:22

Re: Game Mouse issue

18 Feb 2018, 16:23

A computer lets you make more mistakes faster than any invention in human history – with the possible exceptions of handguns and tequila.
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: Game Mouse issue

18 Feb 2018, 18:01

you cant move the mouse at a 2d location in a 3d game. you need to move the mouse relative in direction to the center of the screen or game window until the color is in the center... and there is no way to know by how much you would need to move the mouse to you would need to do this progressively

for example if center of the screen is 500,500 and you find something on the screen at 800,800, you would need to move the mouse relative by 300,300

if the color is at 200,200, you would need to move relative by -300,-300

MouveMouseRelative(dx,dy)
{
DllCall("mouse_event", "UInt", 0x0001, "Int", dx, "Int", dy, "UInt", 0, "UPtr", 0)
}

But again, because there is no way to know how much mouse movement is required to turn and aim, you would need to do this progressively, meaning you would need to search for the color and move until the color is in the center, in a timer or something... then you would shoot.

the other issue is mouse_event moves by Mikey units, not pixels... so 200 mickeys is not 200 pixels. but this could get you thinking of a solution
Mightykiller
Posts: 57
Joined: 09 Oct 2017, 13:34

Re: Game Mouse issue

18 Feb 2018, 21:11

I don't know how dllcall works but this is my script that i tried with your solution
my mouse did not even move now xd

Code: Select all

NumPad1::


    Stop:=0
    i:=0
    While Stop = 0
    {
     
     PixelSearch, AimX, AimY,sx,sy,ex,ey, The_Color,2,Fast RGB
     if !ErrorLevel
        {

            
            tx:=AimX + 2
            ty:=AimY + 2
            MouveMouseRelative(tx,ty)
{
DllCall("mouse_event", "UInt", The_Color, "Int", tx, "Int", ty, "UInt", 0, "UPtr", 0)
}


        }

     }       
    return



NumPad2::
    Mousegetpos,px,py
    PixelGetColor,The_Color,px,py,RGB
    Return
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: Game Mouse issue

24 Feb 2018, 18:19

tx... no dx, deviation x
dx = AimX-CenterX;
dy = AimY-CenterY;

so if you target x is 700 and your center game is 500, dx will be 200... move by 200 to the right

Why are you passing The Color as Movement type. movement type is 0x0001 by itself meaning move the mouse relative
https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 124 guests