Jump to content

Recommended Posts

Posted

Cant Figure Out If This Is Possible, Stop script if Mouse Match/Exceeds Y coordinates

I have a script that moves slowly to the right horizantly after a given action is performed and if the mouse coordinates reaches the Y coordinates or passes it I would like the script to stop

Ive been searching but not sure if its not possible or im not thinking outside the box enough or if I just havent hit the right keywords to find the info to help me solve this so here helping for some help to point me in the right direction.

Some info you might need to know to help me some more, the action is taking place inside a chrome browser the Y coordinates is the edge of the browser (or 20 pixels before doesnt matter here)

 

 

 

Posted (edited)
2 hours ago, Jos said:

Yeap... the current script would show what you are doing. ;)

Jos

$a = MouseGetPos()
          MouseClick($MOUSE_CLICK_RIGHT,  $a[0] , $a[1], 1)
          Sleep(4000)
          MouseClick($MOUSE_CLICK_LEFT,  $a[0] + 20, $a[1] +20, 1)
          Sleep(4000)
            MouseMove($a[0] , $a[1], 0)
            Sleep(4000)
            MouseMove($a[0] +80 , $a[1], 0)

 

Im getting the mouse coordinates from where I want to start (where I leave the mouse) and It does an action and moves right x amount and repeats and what Im trying to implement next is when it hits end of the page to stop which I cant figure out how to even attack that. 

 

 

Edited by JuanLopez
Posted

Try this:

Local $mousePos = MouseGetPos()
Local $maxX = REPLACE_WITH_MAX_X_VALUE
For $x = $mousePos[0] To $maxX Step 80
    MouseClick($MOUSE_CLICK_RIGHT, $x, $mousePos[1], 1)
    Sleep(4000)
    MouseClick($MOUSE_CLICK_LEFT, $x + 20, $mousePos[1] + 20, 1)
    Sleep(4000)
Next

And, if you don't know where the max X will be (because maybe your window might move), you can use:

; WinGetPos returns a 4x array, where 
;  [0] = the X of the upper-left corner of the window
;  [1] = the Y of the upper-left corner of the window
;  [2] = the width of the window
;  [3] = the height of the window
Local $windowRect = WinGetPos("INSERT_TITLE_OF_WINDOW_HERE")
Local $maxX = $windowRect[0] + $windowRect[2]

 

Posted
16 minutes ago, jplumb said:

Try this:

Local $mousePos = MouseGetPos()
Local $maxX = REPLACE_WITH_MAX_X_VALUE
For $x = $mousePos[0] To $maxX Step 80
    MouseClick($MOUSE_CLICK_RIGHT, $x, $mousePos[1], 1)
    Sleep(4000)
    MouseClick($MOUSE_CLICK_LEFT, $x + 20, $mousePos[1] + 20, 1)
    Sleep(4000)
Next

And, if you don't know where the max X will be (because maybe your window might move), you can use:

; WinGetPos returns a 4x array, where 
;  [0] = the X of the upper-left corner of the window
;  [1] = the Y of the upper-left corner of the window
;  [2] = the width of the window
;  [3] = the height of the window
Local $windowRect = WinGetPos("INSERT_TITLE_OF_WINDOW_HERE")
Local $maxX = $windowRect[0] + $windowRect[2]

 

Thanks that worked perfectly, and easy to understand, big props I appreciate your help. 

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
  • Recently Browsing   0 members

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