Sign in to follow this  
Followers 0
tsolrm

Moving the mouse with arrow keys

13 posts in this topic

I don't Understand why does it move Up + Left and Up + Right but not Down + Left or Down + Right? help please

#Include <Misc.au3>


While 1
    $Mouse = MouseGetPos ()
    Select
    Case _IsPressed ("28") And _IsPressed ("25") 
        MsgBox (0, "Test", "Works")
        Call ("DownandLeft")
    Case _IsPressed ("28") And _IsPressed ("27") 
        MsgBox (0, "Test", "Works")
        Call ("DownandRight")
    Case _IsPressed ("26") And _IsPressed ("25") 
        Call ("UpandLeft")
    Case _IsPressed ("26") And _IsPressed ("27") 
        Call ("UpandRight")
    Case _IsPressed ("28")
        Call ("Down")
    Case _IsPressed ("26") 
        Call ("Up")
    Case _IsPressed ("25") 
        Call ("Left")
    Case _IsPressed ("27") 
        Call ("Right")
    EndSelect
    
WEnd

Func Down()
    $Mouse [1] = $Mouse [1] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Up()
    $Mouse [1] = $Mouse [1] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Left()
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Right()
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandLeft ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandRight ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandLeft ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandRight ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Share this post


Link to post
Share on other sites



you forgot

$dll = DllOpen("user32.dll")

at the top of your script, and you need to add ,$dll to each of your _IsPressed calls

Case _IsPressed ("28",$dll) And _IsPressed ("25",$dll)


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

It didn't make any difference, still doesn't move down + left or down + right :)

#Include <Misc.au3>

$dll = DllOpen("user32.dll")
While 1
    $Mouse = MouseGetPos ()
    Select
    Case _IsPressed ("28", $dll) And _IsPressed ("25", $dll)
        MsgBox (0, "Test", "Works")
        Call ("DownandLeft")
    Case _IsPressed ("28", $dll) And _IsPressed ("27", $dll) 
        MsgBox (0, "Test", "Works")
        Call ("DownandRight")
    Case _IsPressed ("26", $dll) And _IsPressed ("25", $dll) 
        Call ("UpandLeft")
    Case _IsPressed ("26", $dll) And _IsPressed ("27", $dll) 
        Call ("UpandRight")
    Case _IsPressed ("28", $dll)
        Call ("Down")
    Case _IsPressed ("26", $dll) 
        Call ("Up")
    Case _IsPressed ("25", $dll) 
        Call ("Left")
    Case _IsPressed ("27", $dll) 
        Call ("Right")
    EndSelect
    
WEnd

Func Down()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Up()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Left()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Right()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandLeft ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandRight ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandLeft ()
    $Mouse = MouseGetPos ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandRight ()
    $Mouse = MouseGetPos ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Share this post


Link to post
Share on other sites

Works fine on my machine (XP 32 bit)

do you have 64 bit? If so, try adding also adding

#AutoIt3Wrapper_UseX64=n

to the top.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Works fine on my machine (XP 32 bit)

do you have 64 bit? If so, try adding also adding

#AutoIt3Wrapper_UseX64=n

to the top.

Yeah, Windows 7 x64

You mean like this? If so then again didn't make any difference(

#Include <Misc.au3>
#AutoIt3Wrapper_UseX64=n

$dll = DllOpen("user32.dll")
While 1
    $Mouse = MouseGetPos ()
    Select
    Case _IsPressed ("28", $dll) And _IsPressed ("25", $dll)
        MsgBox (0, "Test", "Works")
        Call ("DownandLeft")
    Case _IsPressed ("28", $dll) And _IsPressed ("27", $dll) 
        MsgBox (0, "Test", "Works")
        Call ("DownandRight")
    Case _IsPressed ("26", $dll) And _IsPressed ("25", $dll) 
        Call ("UpandLeft")
    Case _IsPressed ("26", $dll) And _IsPressed ("27", $dll) 
        Call ("UpandRight")
    Case _IsPressed ("28", $dll)
        Call ("Down")
    Case _IsPressed ("26", $dll) 
        Call ("Up")
    Case _IsPressed ("25", $dll) 
        Call ("Left")
    Case _IsPressed ("27", $dll) 
        Call ("Right")
    EndSelect
    
WEnd

Func Down()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Up()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Left()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Right()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandLeft ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandRight ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandLeft ()
    $Mouse = MouseGetPos ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandRight ()
    $Mouse = MouseGetPos ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Test ()
    MsgBox (0, "Test", "Works!")
EndFunc

Share this post


Link to post
Share on other sites

Yeah, Windows 7 x64

You mean like this? If so then again didn't make any difference(

#Include <Misc.au3>
#AutoIt3Wrapper_UseX64=n

$dll = DllOpen("user32.dll")
While 1
    $Mouse = MouseGetPos ()
    Select
    Case _IsPressed ("28", $dll) And _IsPressed ("25", $dll)
        MsgBox (0, "Test", "Works")
        Call ("DownandLeft")
    Case _IsPressed ("28", $dll) And _IsPressed ("27", $dll) 
        MsgBox (0, "Test", "Works")
        Call ("DownandRight")
    Case _IsPressed ("26", $dll) And _IsPressed ("25", $dll) 
        Call ("UpandLeft")
    Case _IsPressed ("26", $dll) And _IsPressed ("27", $dll) 
        Call ("UpandRight")
    Case _IsPressed ("28", $dll)
        Call ("Down")
    Case _IsPressed ("26", $dll) 
        Call ("Up")
    Case _IsPressed ("25", $dll) 
        Call ("Left")
    Case _IsPressed ("27", $dll) 
        Call ("Right")
    EndSelect
    
WEnd

Func Down()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Up()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Left()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Right()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandLeft ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandRight ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandLeft ()
    $Mouse = MouseGetPos ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandRight ()
    $Mouse = MouseGetPos ()
    ;MsgBox (0, "Test", "Works")
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Test ()
    MsgBox (0, "Test", "Works!")
EndFunc

i tried it on my xp 32 bit and it works like this... the problem must be the OS compatibility :S

Share this post


Link to post
Share on other sites

I use _IsPressed in another program I am writing on my 64 bit and it works. When testing through logmein I do get the popup saying "Works!" but the mouse does not move. I don't know if it is the script or if it is logmein.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

I use _IsPressed in another program I am writing on my 64 bit and it works. When testing through logmein I do get the popup saying "Works!" but the mouse does not move. I don't know if it is the script or if it is logmein.

actually it does move, but it will move of just 1 pixel since there is the msgbox, if you change the code like this :

#Include <Misc.au3>
#AutoIt3Wrapper_UseX64=n

$dll = DllOpen("user32.dll")
While 1
    $Mouse = MouseGetPos ()
    Select
    Case _IsPressed ("28", $dll) And _IsPressed ("25", $dll)
        Call ("DownandLeft")
    Case _IsPressed ("28", $dll) And _IsPressed ("27", $dll) 
        Call ("DownandRight")
    Case _IsPressed ("26", $dll) And _IsPressed ("25", $dll) 
        Call ("UpandLeft")
    Case _IsPressed ("26", $dll) And _IsPressed ("27", $dll) 
        Call ("UpandRight")
    Case _IsPressed ("28", $dll)
        Call ("Down")
    Case _IsPressed ("26", $dll) 
        Call ("Up")
    Case _IsPressed ("25", $dll) 
        Call ("Left")
    Case _IsPressed ("27", $dll) 
        Call ("Right")
    EndSelect
    
WEnd

Func Down()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Up()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Left()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Right()
    $Mouse = MouseGetPos ()
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandLeft ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func UpandRight ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] - 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandLeft ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] - 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func DownandRight ()
    $Mouse = MouseGetPos ()
    $Mouse [1] = $Mouse [1] + 1
    $Mouse [0] = $Mouse [0] + 1
    MouseMove($Mouse [0], $Mouse [1], 1)
EndFunc

Func Test ()
    MsgBox (0, "Test", "Works!")
EndFunc

it shoulds work propelly

Share this post


Link to post
Share on other sites

Also, Call("Function") is not necessary, Function() will suffice.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Thanks! It works!

Another question

When I press the arrow keys and i'm in opera or any other browser, the page starts moving around (as it would when you are pressing arrow keys)

Is there any way to avoid this?

Share this post


Link to post
Share on other sites

Thanks! It works!

Another question

When I press the arrow keys and i'm in opera or any other browser, the page starts moving around (as it would when you are pressing arrow keys)

Is there any way to avoid this?

dunno about a way for this solution it self, but why don't you change the "hotkeys" instead of the arrows you chose something different that do not interfer with the browser ( wasd peraps if you are not in a input field)

else you could try to play with active window ( if the active window is not the browser but a window created by the script, arrows will move the cursor but not the browser window)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Maby HotKey can help you

Edit the hotkeys to suit your need.

For the hotkey combinations, look in the help file for command Send() under Remarks, HotKeySet() and Send() use the same key combination format.

Edit:

Dono if will it work with 2 button pressed for arrow key, with one it should work like a charm.

Newer the less with hotkey you can block that key in some empty func so that you can use it in _IsPressed and not to effect your page

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

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