Jump to content

Recommended Posts

Posted (edited)

HotKeySet ( "{PAUSE}", "Pos_1" )
    ToolTip( "Place Mouse cursor on top left point and press PAUSE", @Desktopwidth / 2, 7, "", 0, 2)

func Pos_1()
    $first = MouseGetPos()
    HotKeySet ( "{PAUSE}", "Pos_2" )
    ToolTip( "Place Mouse cursor on bottom right point and press PAUSE", @Desktopwidth / 2, 7, "", 0, 2)
endfunc

func Pos_2()
    $second = MouseGetPos()
    HotKeySet ( "{PAUSE}", "Quit" )
    ToolTip( "Press PAUSE to quit", @Desktopwidth / 2, 7, "", 0, 2)
    Doing()
endfunc

func Quit()
    Exit
endfunc

sleep(2000)

Func Doing()
    while 1 
        MouseClick ( "left" , random( $first[1] , $second[1] ), random($first[2] , $second[2] ), 1 , 0)
        sleep(10)
    WEnd
endfunc

Error:

MouseClick ( "left" , random( $first[1] , $second[1] ), random($first[2] , $second[2] ), 1 , 0)

MouseClick ( "left" , random( ^ Variable used without being declared.

MouseGetPos page

As you can see I declared $first and $second in the $first = MouseGetPos() at the beginning.

So why isn't it working?

Edited by Maurice
Posted

The undeclared variables are of Local scope as the rules of Dim apply. You will need to declare them as Global to share between functions are pass as a function parameter.

Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)

:)

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...