Maurice Posted August 26, 2007 Share Posted August 26, 2007 (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 endfuncError:MouseClick ( "left" , random( $first[1] , $second[1] ), random($first[2] , $second[2] ), 1 , 0)MouseClick ( "left" , random( ^ Variable used without being declared.MouseGetPos pageAs you can see I declared $first and $second in the $first = MouseGetPos() at the beginning.So why isn't it working? Edited August 26, 2007 by Maurice Link to comment Share on other sites More sharing options...
MHz Posted August 26, 2007 Share Posted August 26, 2007 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!) Link to comment Share on other sites More sharing options...
Maurice Posted August 26, 2007 Author Share Posted August 26, 2007 Thank you very much. Didn't know I had to declare variables if I want to have them global. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now