Jump to content

Need help with mouse movement!


Recommended Posts

I want to make me a script that when i press a hotkey it will right click where my mouse is currently then move from the current mouse position so many pixels one way and so many the other and click again, but I can't figure out how to do this.

I don't want it to click in a set position on the screen, just a certain distance from where I started the script from.

Link to comment
Share on other sites

HotKeySet("h", "f")
Global $yourdistance[2] = [42, 42]
While 1
    Sleep(500)
WEnd

Func f()
    $a = MouseGetPos()
    MouseClick("left", $a[0], $a[1])
    Sleep(500)
    MouseClick("left", $a[0] + $yourdistance[0], $a[1] + $yourdistance[1],1,0)
EndFunc

Tysm for that, I tried to use your code to make it do what I want. I changed Global $yourdistance[2] = [42, 42] to Global $yourdistance[2] = [160, 35]

That got me the right mouse movement, but after that I need it to move again from where it just moved another [50, 20] and then left click then move back to the original position and start over in like a loop, would also like it to have a pause button.

Thought I could do it myself when I figured out how to move the mouse like you did but it seems that I cannot because I do not have a good enough understanding of scripting :idea:

Link to comment
Share on other sites

HotKeySet("{end}", "f")
HotKeySet("{Home}", "Terminate")

Global $yourdistance[2] = [160, 35]
Global $yourdistancee[2] = [210, 55]
While 1
    Sleep(500)
WEnd 
Func f()     

    $a = MouseGetPos()     
    MouseClick("right", $a[0], $a[1])     
    Sleep(500)     
    MouseClick("left", $a[0] + $yourdistance[0], $a[1] + $yourdistance[1],1,0) 
    MouseClick("left", $a[0] + $yourdistancee[0], $a[1] + $yourdistancee[1],1,0)
EndFunc

Func Terminate() 
    Exit 0 
EndFunc

That is what I came up with and I successfully got it to do what I want but I dont know how to make it go back to the original position after it is finished and loop untill I make it stop.

Any help would be greatly appreciated.

Link to comment
Share on other sites

just use another variable :idea:

HotKeySet("s", "go") ; start/pause the script with the key 's'
Global $flag = False, $flag2 = False
Global $coo[4] = [160, 35, 50, 20] ; array with x1, y1, x2, y2 coo
Global $loc ; starting loc
Global $ms = 250 ; mill.sec. between clicks, adjust it like you want

While 1
    If $flag == True Then
        If $flag2 == False Then
            $loc = MouseGetPos()
            $flag2 = True
        EndIf
        MouseClick("left", $loc[0], $loc[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0], $loc[1] + $coo[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0], $loc[1] + $coo[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0] + $coo[2], $loc[1] + $coo[1] + $coo[3], 1, 0)
    MouseMove($loc[0], $loc[1], 0)
    Else
        $flag2 = False
    EndIf
WEnd

Func go()
    $flag = Not $flag
EndFunc

edit: the mouse will come back to originary loc

Edited by simon387
Link to comment
Share on other sites

just use another variable :)

HotKeySet("s", "go") ; start/pause the script with the key 's'
Global $flag = False, $flag2 = False
Global $coo[4] = [160, 35, 50, 20] ; array with x1, y1, x2, y2 coo
Global $loc ; starting loc
Global $ms = 250 ; mill.sec. between clicks, adjust it like you want

While 1
    If $flag == True Then
        If $flag2 == False Then
            $loc = MouseGetPos()
            $flag2 = True
        EndIf
        MouseClick("left", $loc[0], $loc[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0], $loc[1] + $coo[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0], $loc[1] + $coo[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0] + $coo[2], $loc[1] + $coo[1] + $coo[3], 1, 0)
    MouseMove($loc[0], $loc[1], 0)
    Else
        $flag2 = False
    EndIf
WEnd

Func go()
    $flag = Not $flag
EndFunc

edit: the mouse will come back to originary loc

HotKeySet("{end}", "go") ; start/pause the script with the key 's'
HotKeySet("{home}", "Terminate")

Global $flag = False, $flag2 = False
Global $coo[4] = [160, 35, 50, 20] ; array with x1, y1, x2, y2 coo
Global $loc ; starting loc
Global $ms = 100 ; mill.sec. between clicks, adjust it like you want

While 1
    If $flag == True Then
        If $flag2 == False Then
            $loc = MouseGetPos()
            $flag2 = True
        EndIf
        MouseClick("right", $loc[0], $loc[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0], $loc[1] + $coo[1], 1, 0)
        Sleep($ms)
        MouseClick("left", $loc[0] + $coo[0] + $coo[2], $loc[1] + $coo[1] + $coo[3], 1, 0)
        Sleep($ms)
        MouseClick("right", $loc[0], $loc[1], 1, 0)
        
    Else
        $flag2 = False
    EndIf
WEnd

Func go()
    $flag = Not $flag
EndFunc

Func Terminate()
    Exit 0
EndFunc

Change just a little but it is working now, tysm for your help :idea:

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...