Sign in to follow this  
Followers 0
Nino

Locking Y Axis

10 posts in this topic

#1 ·  Posted (edited)

Can someone teach me how to lock the Y-axis so that you can only move left or right while holding down a key of somesort? :P I can't figure it out how I should begin attempting this, it's for a game(Counter Strike).

Many thanks,

Nino

Edited by Nino

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

You'll probably want to put MouseGetPos() in a loop, save it to a $var. Have an inner loop you can toggle on/off with a new MouseGetPos() in a $newvar. Then do something like, If $var[0] <> $newvar[0] Then MouseMove($var[0], $newvar[1], 0).

Edited by xcal

Share this post


Link to post
Share on other sites

When you say Y axis, do you mean the coordinates of the mouse?

Like the center of your screen, and from that point on you can't move up or down only left/right. Maybe desktop resolution plays a role in this?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Oh, I got what you wanted to do backwards. You could just reverse what I said above. If you wanted to lock it to the center of the screen, then look in to the @DesktopHeight macro and / that by 2 for the MouseMove() 's Y.

edit - it'd look something like this (related to my previous post): If $var[1] <> $newvar[1] Then MouseMove($newvar[0], @DesktopHeight / 2, 0)

Edited by xcal

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

HotKeySet("{HOME}", "Lock")



Func Lock()
    $var=0
    $newvar=0
   If $var[1] <> $newvar[1] Then MouseMove($newvar[0], @DesktopHeight / 2, 0) 
EndFunc

Thanks xcal! :P

EDIT: I suck at arrays.

Edited by Nino

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Not quite what I had in mind, but if you got it working for you, cool.

HotKeySet('{esc}', 'quit')
HotKeySet('{F2}', 'lockx')

$lockx = False

While 1
    While $lockx
        $pos = MouseGetPos()
        MouseMove($pos[0], @DesktopHeight / 2, 0)
    WEnd
    Sleep(50)
WEnd

Func lockx()
    $lockx = Not $lockx
EndFunc


Func quit()
    MsgBox(0, '', 'Exiting...', 1)
    Sleep(1000)
    Exit
EndFunc

;edit - just noticed I had old stuff in there... removed it.

Edited by xcal

Share this post


Link to post
Share on other sites

Thank you very much for the help xcal! :P

Just have one more question, for this to work in game(Counter Strike), would my desktop resolution have to be the same as my in-game resolution? It seems to have no effect when I am in game and I hit F2. I added a

WinWait("Counter Strike")
In the While/Wend and that also doesn't seem to have any effect.

Share this post


Link to post
Share on other sites

No clue... game prob has some kind of protection. I don't use autoit for games, so can't help you there.

Yes, VAC security will no doubt block any program while in in-game

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