Jump to content
Sign in to follow this  
Jack023

Check if mouse moved to left or right

Recommended Posts

Jack023

Hey all,

At the moment i'm learning autoit and i was wondering how i could see if my mouse move on the X to left or Right?

I use this to get the center of the screen.

$x = @DesktopWidth / 2
$y = @DesktopHeight / 2

Now i want, in a loop.

If mouse move to left side of the $x then 

else if mouse move to right side of the $x then

endif

Is this possible?

 

Share this post


Link to post
Share on other sites
Jack023

Alright

now got this:

$x = @DesktopWidth / 2
$y = @DesktopHeight / 2
$i = 0
Do
    Local $pos = MouseGetPos()
    if $pos[0] <> $x then
    MouseMove($x, $y)
    $i += 1
    EndIf
Until $i = 10

It do this:

If mouse is not in center, move it to center.

This is just simple, but i want like this:

If mouse left or mouse is right of center?

apart from each other

Share this post


Link to post
Share on other sites
BrewManNH

$pos[0] <  $x is to the left,$pos[0] >  $x is to the right. Wouldn't it have been easier to try this out for yourself rather than posting this, and then replying to yourself 35 minutes later?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Jack023

I know,

but still not fixed..

$x = @DesktopWidth / 2
$y = @DesktopHeight / 2
$i = 0
Do
    $x = @DesktopWidth / 2
    sleep(1000)
    Local $pos = MouseGetPos()
    if $pos[0] < $x then
        Do
            Send("{a down}")
        Until $pos[0] >$x


    ElseIf $pos[0] > $x Then
        While $pos[0] > $x
            Send("{d down}")
        WEnd
    $i += 1
    EndIf
Until $i = 10

Share this post


Link to post
Share on other sites
Jos

How does getting the mid screen point help determining wehther you are moving left or right?

You should save the last position and compare to that to determine which direction it moved.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Jack023

Well , i was trying it in a game of my friend to make my skills for autoit better. only it always aim on the center of the screen.

any fix for that?

Share this post


Link to post
Share on other sites
Jos

Well , i was trying it in a game of my friend to make my skills for autoit better. only it always aim on the center of the screen.

any fix for that?

Well, in that case start reading here before continuing your question.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.