Samuel2021 Posted January 28, 2021 Posted January 28, 2021 (edited) Hello, i am new here. Tried many things, read already the "for..next help" but it was really short and couln't help me. Here is what i want to do, simplified: Hit Hotkey F11 for InputBox - Enter any Number -> this number will be the variable for looping the function Hit Hotkey ESC for Function - the Function shall be looped according to the InputBox now, my function will say: "Error: Variable used without being declared" Script as I have it now is below. the Variable is exactly the same, but he cannot find it. Func Input1() Local $test = InputBox("Move Mouse", "Number of Loops: ", "", "", -1, 130) HotKeySet("{ESC}", "Move_mouse") HotKeySet("{F11}", "Input1") HotKeySet("{F1}", "STOP") ; Hit F1 in case of emergency :) While 1 Sleep(10) WEnd Func Move_mouse() For $i = 1 To $test MouseMove(25, 80, 5) Sleep(50) MouseMove(545, 190, 5) Next EndFunc while 1 Sleep(50) WEnd Func STOP() Exit 0 EndFunc I hope you can understand what is wrong with this.. thanks for your help. Edited January 28, 2021 by Melba23 Added code tags
Moderators Melba23 Posted January 28, 2021 Moderators Posted January 28, 2021 Samuel2021, Welcome to the AutoIt forums. When you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation. You need to declare $test as a Global variable so all functions can use it - I suggest reading the Variables - using Global, Local, Static and ByRef tutorial in the Wiki to get more details. You also do not terminate the initial Input1 function. Take a look at this modified script which I think does what you wish: HotKeySet("{ESC}", "Move_mouse") HotKeySet("{F11}", "Input1") HotKeySet("{F1}", "STOP") ; Hit F1 in case of emergency :) Global $test While 1 Sleep(10) WEnd Func Input1() $test = InputBox("Move Mouse", "Number of Loops: ", "", "", -1, 130) EndFunc ;==>Input1 Func Move_mouse() For $i = 1 To $test ConsoleWrite($test & " - MouseMove 1" & @CRLF) ;MouseMove(25, 80, 5) Sleep(50) ConsoleWrite($test & " - MouseMove 2" & @CRLF) ;MouseMove(545, 190, 5) Next EndFunc ;==>Move_mouse Func STOP() Exit 0 EndFunc ;==>STOP Please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Samuel2021 Posted May 11, 2021 Author Posted May 11, 2021 Hello M23, thank you, I check out the Code tagging! Sorry I did not have notifications on to see your reply. For the Moment, i just did a loop of 300 but the script will unnecessarely do it's thing and maybe cause damage. Your suggestions makes great sense, will let you know once I got it worked! Thanks have a nice day! Samuel
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