iepurasul Posted April 1, 2018 Share Posted April 1, 2018 Hey guys i need a little help from you. I want every time when this script runs, to click randomly but is something wrong and i cannot figure it out what ClickRandomly();Call the ClickRandomly Function from within another part of the script Func ClickRandomly() Local $RandomNumber = Random(1,2,3,4,5,4,3,2,1) If $RandomNumber == 1 Then MouseClick("Left",592,173) EndIF If $RandomNumber == 2 Then MouseClick("Left",309,631) EndIF If $RandomNumber == 3 Then MouseClick("Left",350,691) EndIF If $RandomNumber == 4 Then MouseClick("Left",630,731) EndIF If $RandomNumber == 5 Then MouseClick("Left",1005,31) EndIF If $RandomNumber == 6 Then MouseClick("Left",1005,31) EndIF If $RandomNumber == 7 Then MouseClick("Left",1035,101) EndIF If $RandomNumber == 8 Then MouseClick("Left",1505,91) EndIF If $RandomNumber == 9 Then MouseClick("Left",1995,331) EndIf EndFunc I want to do the same to another script but with comments, for example : hey,hello,ciao,sayonara or another words if i want to add more Thank you very much for the help Link to comment Share on other sites More sharing options...
alienclone Posted April 1, 2018 Share Posted April 1, 2018 you would be able to troubleshoot your own code better if you were to check syntax in the full scite editor (ctrl+F5) it says Random() was called with the wrong number of arguments, the Function Reference for this function says there are only 3 optional parameters available, you have 9 in your code. fix that then check sytax again to see if there are further errors. If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
alienclone Posted April 1, 2018 Share Posted April 1, 2018 if you want TRUE RANDOM (read in the voice of Rick Sanchez) clicks anywhere on the desktop with only one line of code, try this out... MouseClick("left",Random(WinGetPos("Program Manager")[2]),Random(WinGetPos("Program Manager")[3])) If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
iepurasul Posted April 1, 2018 Author Share Posted April 1, 2018 3 hours ago, alienclone said: you would be able to troubleshoot your own code better if you were to check syntax in the full scite editor (ctrl+F5) it says Random() was called with the wrong number of arguments, the Function Reference for this function says there are only 3 optional parameters available, you have 9 in your code. fix that then check sytax again to see if there are further errors. Thanks for answer me If i press CRTL+F5 i get but i cannot troubleshooting myself error: Random() [built-in] called with wrong number of args. Local $RandomNumber = Random(1,2,3,4,5,4,3,2,1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ For the Function Reference i check the web page but i don't find any to help me. If the code have only 3 optional parameters available, then i need to change it to more than 3, for example 9 or maybe in the future if i want to add more, the 10th or 11th parameter Thank you Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 1, 2018 Moderators Share Posted April 1, 2018 iepurasul, You do not add the required random numbers as parameters - you let the function determine those. As explained in the Help file (you even linked to the page) all you need is the minimum and maximum values you want (and in your case setting the flag because you want integers): Random(1, 10, 1) Now you will get an integer from 1 to 10 each time you call the function. M23 iepurasul 1 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 Link to comment Share on other sites More sharing options...
iepurasul Posted April 1, 2018 Author Share Posted April 1, 2018 Thank you very much @Melba23 it's working. I insert to script test.au3 the random click code test2.au3 but it's telling me that is already use test2.au3"(3,21) : error: ClickRandomly() already defined. Func ClickRandomly() The script test.au3 is like this MouseClick("left",1061,618) sleep(1901) #include <test2.au3> sleep(1901) Send("{ENTER}") sleep(1901) #include <test2.au3> sleep(1901) Send("{ENTER}") sleep(1901) #include <test2.au3> sleep(1901) how i can include into the script test.au3 to get random click test2.au3 ? And thank you again for support Link to comment Share on other sites More sharing options...
Bowmore Posted April 1, 2018 Share Posted April 1, 2018 I think you would benefit from reading and watching some of the tutorials here https://www.autoitscript.com/wiki/Tutorials as you seem to lack some understanding of the basics required for programming with AutoIt. To get your script to work you need to change you script to something like this. expandcollapse popupMouseClick("left",1061,618) sleep(1901) ClickRandomly() sleep(1901) Send("{ENTER}") sleep(1901) ClickRandomly() sleep(1901) Send("{ENTER}") sleep(1901) ClickRandomly() sleep(1901) Func ClickRandomly() Local $RandomNumber = Random(1,9,1) If $RandomNumber == 1 Then MouseClick("Left",592,173) EndIF If $RandomNumber == 2 Then MouseClick("Left",309,631) EndIF If $RandomNumber == 3 Then MouseClick("Left",350,691) EndIF If $RandomNumber == 4 Then MouseClick("Left",630,731) EndIF If $RandomNumber == 5 Then MouseClick("Left",1005,31) EndIF If $RandomNumber == 6 Then MouseClick("Left",1005,31) EndIF If $RandomNumber == 7 Then MouseClick("Left",1035,101) EndIF If $RandomNumber == 8 Then MouseClick("Left",1505,91) EndIF If $RandomNumber == 9 Then MouseClick("Left",1995,331) EndIf EndFunc iepurasul 1 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
iepurasul Posted April 1, 2018 Author Share Posted April 1, 2018 Thank you very much #Bowmore Link to comment Share on other sites More sharing options...
iepurasul Posted April 2, 2018 Author Share Posted April 2, 2018 @Bowmore I try to include into the script Func SendRandomly() and Func ClickRandomly() but i get some error . Why ? test.au3"(5,15) : error: ClickRandomly(): undefined function. expandcollapse popupsleep(3901) WinActivate("New Text Document (2) - Notepad") sleep(1901) ClickRandomly() sleep(1901) MouseClick("left",1061,618) sleep(1901) SendRandomly() sleep(1901) MouseClick("Left",350,691) Func SendRandomly() Local $RandomNumber = Random(1,9,1) If $RandomNumber == 1 Then Send("Left") EndIF If $RandomNumber == 2 Then Send("right") EndIF If $RandomNumber == 3 Then Send("het") EndIF If $RandomNumber == 4 Then Send("heyy") EndIF If $RandomNumber == 5 Then Send("bauuuut") EndIF If $RandomNumber == 6 Then Send("yap") EndIF If $RandomNumber == 7 Then Send("LOL") EndIF If $RandomNumber == 8 Then Send("no") EndIF If $RandomNumber == 9 Then Send("yes") EndIf EndFunc Func ClickRandomly() Local $RandomNumber = Random(1,9,1) If $RandomNumber == 1 Then MouseClick("Left",592,173) EndIF If $RandomNumber == 2 Then MouseClick("Left",309,631) EndIF If $RandomNumber == 3 Then MouseClick("Left",350,691) EndIF If $RandomNumber == 4 Then MouseClick("Left",630,731) EndIF If $RandomNumber == 5 Then MouseClick("Left",1005,31) EndIF If $RandomNumber == 6 Then MouseClick("Left",1005,31) EndIF If $RandomNumber == 7 Then MouseClick("Left",1035,101) EndIF If $RandomNumber == 8 Then MouseClick("Left",1505,91) EndIF If $RandomNumber == 9 Then MouseClick("Left",1995,331) EndIf EndFunc Thank you for help, i really appreciated Link to comment Share on other sites More sharing options...
Bert Posted April 2, 2018 Share Posted April 2, 2018 I'm asking out of ignorance - why do you need such a script to click on the screen in random places? Looking to educate myself here The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Earthshine Posted April 2, 2018 Share Posted April 2, 2018 he won't post all the scripts. this is like a test mule for something else. nobody just says to themselves, hey I want a script to click all over randomly unless there is a good use case for it. notepad is just the mule. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 2, 2018 Moderators Share Posted April 2, 2018 Ok, we seem to have to keep posting this from time to time - Wannabe Mods If you think that a post is overtly against the forum rules, report it. If you have (legitimate!) questions about what the OP is trying to do in an attempt to assist them, ask. If you have nothing more to offer than snarky comments about what you think the OP's intentions are - keep it to yourself. We seem to be having to point this out to the same folks a lot lately - most recently not even a month ago by @Melba23 in this thread: "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Malkey Posted April 3, 2018 Share Posted April 3, 2018 In this example the ClickRandomly() function is a working re-write of your example of post #1 with the correct use of the Random() function; and, ClickRandomlyB() is my imaginative interpretation of your fanciful belief of what "Random(1,2,3,4,5,4,3,2,1)" does. Press "Shift" key to call the ClickRandomly Function; Press "Ctrl" key to call the ClickRandomlyB Function; and, Press "Esc" key to exit script. #include <Misc.au3> ; For _IsPressed() function only. #include <Array.au3> ; For _ArrayDisplay() function only. While 1 Select Case _IsPressed('1B') ; Press Esc key to exit script. ExitLoop Case _IsPressed('10') ; Press shift key to call the ClickRandomly Function. ClickRandomly() Case _IsPressed('11') ; Press Ctrl key to call the ClickRandomlyB Function. (Click sequencial points specified in ClickRandomlyB() parameter.) ClickRandomlyB("1, 2, 3, 4, 5, 4, 3, 2, 1") ; The string parameter is the index order of the points in the array, $aRandomPts, to be clicked. EndSelect Sleep(150) WEnd Func ClickRandomly() Local $aRandomPts = [[9, 0], [592, 173], [309, 631], [350, 691], [630, 731], [1005, 31], [1005, 31], [1035, 101], [1505, 91], [1995, 331]] ; The points to be randomly clicked ;_ArrayDisplay($aRandomPts) Local $r = Random(1, $aRandomPts[0][0], 1) ; Random index number to be used on the above Array. MouseClick("Left", $aRandomPts[$r][0], $aRandomPts[$r][1]) ConsoleWrite("$aRandomPts Index: " & $r & @TAB & "X: " & $aRandomPts[$r][0] & @TAB & "Y: " & $aRandomPts[$r][1] & @CRLF) ; For testing purposes only. EndFunc ;==>ClickRandomly Func ClickRandomlyB($sClickPointOrder) Local Static $r = 0 ; Incremented index number of the $aRNumbers array which contains the order of the points in the $aRandomPts array to be clicked. Local $aRandomPts = [[9, 0], [592, 173], [309, 631], [350, 691], [630, 731], [1005, 31], [1005, 31], [1035, 101], [1505, 91], [1995, 331]] Local $aRNumbers = StringRegExp($sClickPointOrder, "\d", 3) ; <== The order of the points to be clicked. (Parameter 3 = $STR_REGEXPARRAYGLOBALMATCH) ;_ArrayDisplay($aRNumbers) MouseClick("Left", $aRandomPts[$aRNumbers[$r]][0], $aRandomPts[$aRNumbers[$r]][1]) ConsoleWrite("$aRNumbers Index: " & $r & @TAB & "$aRNumbers Value/$aRandomPts Index: " & $aRNumbers[$r] & @TAB & "X: " & $aRandomPts[$aRNumbers[$r]][0] & @TAB & "Y: " & $aRandomPts[$aRNumbers[$r]][1] & @CRLF) ; For testing purposes only. $r = Mod($r + 1, UBound($aRNumbers)) ; Increment static variable, $r. EndFunc ;==>ClickRandomlyB iepurasul 1 Link to comment Share on other sites More sharing options...
lenclstr746 Posted April 11, 2018 Share Posted April 11, 2018 MouseClick("left",Random($x1,$x2),Random($y1,$y2),1,0) 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