MouseGetPos

Ask gaming related questions (AHK v1.1 and older)
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: MouseGetPos

04 Jan 2018, 11:15

Is it a first person shooter?

In an FPS, if a target is visible on the screen at pixel coordinates 100, 200, then moving the mouse CURSOR to 100, 200 WILL NOT aim at that target.
FPS shooters simply do not work that way - the position of the CURSOR is irrelevant, the SIGNALS that came from the mouse are what is important.

In order for this to work, you would need to do it over multiple frames of the game.
Where is the target? Top right of screen.
Move mouse up and right some.
Repeat - where is target now? Right of screen.
Move mouse right some, repeat.

If you turned off pointer acceleration (In the game and in your mouse software, the windows setting is again irrelevant) and had high-precision timers, you MIGHT be able to aim at a predictable coordinate with just pre-calculated input, but I highly doubt you could get it accurate enough, plus it would be totally reliant on screen resolution and DPI settings - if you changed either, it would break.
User avatar
blueeyiz702
Posts: 20
Joined: 12 Dec 2017, 20:12
Location: Las Vegas, Nevada
Contact:

Re: MouseGetPos

20 Jan 2018, 19:41

evilC wrote:Is it a first person shooter?

In an FPS, if a target is visible on the screen at pixel coordinates 100, 200, then moving the mouse CURSOR to 100, 200 WILL NOT aim at that target.
FPS shooters simply do not work that way - the position of the CURSOR is irrelevant, the SIGNALS that came from the mouse are what is important.

In order for this to work, you would need to do it over multiple frames of the game.
Where is the target? Top right of screen.
Move mouse up and right some.
Repeat - where is target now? Right of screen.
Move mouse right some, repeat.

If you turned off pointer acceleration (In the game and in your mouse software, the windows setting is again irrelevant) and had high-precision timers, you MIGHT be able to aim at a predictable coordinate with just pre-calculated input, but I highly doubt you could get it accurate enough, plus it would be totally reliant on screen resolution and DPI settings - if you changed either, it would break.
so its going difficult to hit a certain place in game,and yes fps,black squad.
User avatar
blueeyiz702
Posts: 20
Joined: 12 Dec 2017, 20:12
Location: Las Vegas, Nevada
Contact:

Re: MouseGetPos

20 Jan 2018, 19:44

@evilC, your UCR program,how would i map movements from black squad to xbox 360 wireless controller?
i tried and could not get it to work at all,im new so i need some help. thanks.
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: MouseGetPos

21 Jan 2018, 03:43

what's the game?
User avatar
blueeyiz702
Posts: 20
Joined: 12 Dec 2017, 20:12
Location: Las Vegas, Nevada
Contact:

Re: MouseGetPos

23 Jan 2018, 21:28

icuurd12b42 wrote:what's the game?
Black Squad
GreatGazoo
Posts: 69
Joined: 28 Dec 2017, 02:53

Re: MouseGetPos

23 Jan 2018, 22:37

this is black squad (pretty fun sometimes) https://www.youtube.com/watch?v=RKnzHSboWJc
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: MouseGetPos

24 Jan 2018, 03:59

blueeyiz702 wrote:@evilC, your UCR program,how would i map movements from black squad to xbox 360 wireless controller?
i tried and could not get it to work at all,im new so i need some help. thanks.
You mean you want to fake an xbox controller?
Did you read the big fat IMPORTANT in the first post of the UCR thread?
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: MouseGetPos

24 Jan 2018, 04:39

Those kinds of games have 2 possible means of moving the reticule...
1) they constantly set the mouse to the center of the screen every step and see how far from the center of the screen you moved the mouse. and they derive from that a rotation of the camera
2) they read the mouse directly from the hardware and check against the old position and derive from that a rotation of the camera...


if the implementation is 1) then this code should work for you

Code: Select all

Class MouseDirect 
{
    MoveByXYVector(xAmount,yAmount, numrepeat)
    {
        loop, %numrepeat%
        {
            DllCall("mouse_event", "UInt", 0x0001, "Int", xAmount, "Int", yAmount, "UInt", 0, "UPtr", 0)    ; MOUSEEVENTF_MOVE = 0x0001
            sleep 16
        }
    }
    MoveInDirection(angle, amount, numrepeat)
    {
        xAmount := this.cosIt(angle) * amount
        yAmount := this.sinIt(angle) * amount
        this.MoveByXYVector(xAmount,yAmount, numrepeat)
    }
    cosIt(deg)
    {
        return, (cos(this.DegToRad(deg)))
    }
    sinIt(deg)
    {
        return, (-sin(this.DegToRad(deg)))
    }
    DegToRad(deg)
    {
        static pi := 3.14159265358979323846
        return, deg * pi / 180
    }
}
MouseDirect.MoveInDirection(270,100,2);
or
MouseDirect.MoveByXYVector(0,100,2);

move mouse down, twice by 100 each time

this would essentially move the mouse relative to it's current location, which is the center of the screen. the game should re-center
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: MouseGetPos

24 Jan 2018, 04:45

The mouse_event DllCall should work if the game uses the cursor position OR if it reads the mouse via RawInput, seeing as the cursor moves in response to mouse_event.
If you want to send smooth mouse movement in this way, you want faster firing timers than AHK can provide (AHK only goes down to ~10ms, whereas real mice send input at a rate more like 1-2ms), then you can use MicroTimer: https://autohotkey.com/boards/viewtopic.php?t=29957
icuurd12b42
Posts: 202
Joined: 14 Aug 2016, 04:08

Re: MouseGetPos

24 Jan 2018, 05:58

true, it should work in both cases I mention come to think of it.

I have experience mouse_event with a game that looked like it was reading the mouse via RawInput from the way it was acting but it turns out is was not the case... Either that or mouse_event does not work like I suspected...

I had to jump through hoops on that one
https://autohotkey.com/boards/viewtopic.php?f=5&t=42291
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: MouseGetPos

24 Jan 2018, 06:28

But I am still not 100% sure what blueeyiz702 wants - I do not know if he wants to use mouse or joystick as the physical input device.
It's a PC game, so I am guessing the game takes input from the mouse, so I am guessing he wants mouse as the output, but to play the game with a joypad in his hands, but who in their right mind would want to play a mouse-aim game with a joystick???
User avatar
blueeyiz702
Posts: 20
Joined: 12 Dec 2017, 20:12
Location: Las Vegas, Nevada
Contact:

Re: MouseGetPos

26 Jan 2018, 02:45

[quote="evilC"]But I am still not 100% sure what blueeyiz702 wants - I do not know if he wants to use mouse or joystick as the physical input device.
It's a PC game, so I am guessing the game takes input from the mouse, so I am guessing he wants mouse as the output, but to play the game with a joypad in his hands, but who in their right mind would want to play a mouse-aim game with a joystick???[/quote
im trying to map the A,W,S,D to left pad on Xbox controller and the shooting action to right trigger. i noticed some guys have a lean and shoot and its almost impossible to hit them on they move. i want to map the black sqaud game keys
to my controller. I need mouse to controller input,so i can use xbox controller instead of mouse.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: MouseGetPos

26 Jan 2018, 15:26

Ok so the input (The thing you actually use) is keyboard and mouse, and the output (The thing the game needs to see) is a virtual xbox controller?
And you also want to have it so that when you move the mouse, one of the virtual controller joysticks moves?
User avatar
blueeyiz702
Posts: 20
Joined: 12 Dec 2017, 20:12
Location: Las Vegas, Nevada
Contact:

Re: MouseGetPos

31 Jan 2018, 05:33

evilC wrote:
blueeyiz702 wrote:Recoil() ;Recoil
NM, just noticed this.
So the real reasons emerge. I'm out.

i did not write that,i have not been on till just now,wtf.
User avatar
blueeyiz702
Posts: 20
Joined: 12 Dec 2017, 20:12
Location: Las Vegas, Nevada
Contact:

Re: MouseGetPos

31 Jan 2018, 05:36

if i wanted no recoil, i would have said that. None of my guns recoil i have over 20,000 kills why i need that? Duh i want to map keys to my xbox controller i use with computer.
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: MouseGetPos

31 Jan 2018, 07:32

blueeyiz702 wrote:i did not write that,i have not been on till just now,wtf.
Seriously? You just lost all credibility.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 38 guests