Garrik Posted October 5, 2019 Posted October 5, 2019 Hi guys! I need some help here, is there a way to use Random with While? I need this script to run in between 1 and 4 times but I dont know how to do it, can you please help me? dim $i=1 While $i<=4 Sleep(3000) Send("{LWINDOWN}r{LWINUP}") Sleep(3000) Send("C:\Users\123\Catalogos\tags.txt{ENTER}") Sleep(3000) WinActivate("tags: Bloc de notas","") Sleep(3000) Send("{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{DEL}{DEL}") Sleep(3000) Send("{CTRLDOWN}g{CTRLUP}{ALTDOWN}{F4}{ALTUP}") Sleep(3000) Send("{CTRLDOWN}v{CTRLUP}{SPACE}") $i=$i+1 WEnd
Developers Jos Posted October 5, 2019 Developers Posted October 5, 2019 Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
water Posted October 5, 2019 Posted October 5, 2019 The answer is in the title of your thread Replace the upper limit of your While with the Random function. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Garrik Posted October 5, 2019 Author Posted October 5, 2019 Im sorry I dont know what you mean with Replace the upper limit of your While with the Random function.?????
water Posted October 5, 2019 Posted October 5, 2019 The start value of your While loop is 1 (lower limit), the end value is 4 (upper limit). So replace 4 with the Random function. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Garrik Posted October 5, 2019 Author Posted October 5, 2019 yo mean like this? but i still need it to be a loop when it gets more than 1 like in 2,3,4 Random(1, 4) Sleep(3000)Send("{LWINDOWN}r{LWINUP}")Sleep(3000)Send("C:\Users\123\Catalogos\tags.txt{ENTER}")Sleep(3000)WinActivate("tags: Bloc de notas","")Sleep(3000)Send("{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{DEL}{DEL}")Sleep(3000)Send("{CTRLDOWN}g{CTRLUP}{ALTDOWN}{F4}{ALTUP}")Sleep(3000)Send("{CTRLDOWN}v{CTRLUP}{SPACE}") Next
water Posted October 5, 2019 Posted October 5, 2019 Please re-read my last post and you will see that you still need the While statement and need to replace the end value as I described. Not too hard, isn't it My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Garrik Posted October 5, 2019 Author Posted October 5, 2019 Im really sorry but I dont get it 😌, can you please write it down? As you can see Im not that good at writing scripts.... Sorry for this
Developers Jos Posted October 5, 2019 Developers Posted October 5, 2019 Did you actually open the helpfile and check the information for the random() function and have you tried to understand it? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Garrik Posted October 5, 2019 Author Posted October 5, 2019 yes I did thats why I'm asking if is possible to do a loop with random or how to do it... I'm not that experienced doing scripts Can you please help me?
Developers Jos Posted October 5, 2019 Developers Posted October 5, 2019 Well I don't think you really did as example 3 shows a For..Next loop with the exact thing you are asking for. Try again and this time take the time to understand how that example works. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Garrik Posted October 5, 2019 Author Posted October 5, 2019 Well I'm having a hard time writing down my first script I just wanted some help here, I've seen that you need to to type the script and in base of that you ask your questions and you write the possible answers... I don't know how to do it Can someone please help me with a written example?? If this is to much to ask?
Developers Jos Posted October 5, 2019 Developers Posted October 5, 2019 1 minute ago, Garrik said: Well I'm having a hard time writing down my first script I just wanted some help here, I've seen that you need to to type the script and in base of that you ask your questions and you write the possible answers... I don't know how to do it Can someone please help me with a written example?? If this is to much to ask? Well It can't be that you have even looked closer at what I pointed you to and tried something in these 8 minutes between my and your post. Just cut&pasting a piece of script written by you or somebody else and then expecting us to jump to attention and coding it for you is not the way it works here. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
water Posted October 5, 2019 Posted October 5, 2019 Another question: Can you please tell us what you try to do with your script? Using Send is not very reliable as it might interfere with user actions. Why do you need Random() at all? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Garrik Posted October 5, 2019 Author Posted October 5, 2019 thanks for answering me, what this script do is coping some words from a notepad, but as you can see always copy 4 times I need it to randomly do it between 1 and 4 times dim $i=1While $i<=4Sleep(3000)Send("{LWINDOWN}r{LWINUP}")Sleep(3000)Send("C:\Users\123\Catalogos\tags.txt{ENTER}")Sleep(3000)WinActivate("tags: Bloc de notas","")Sleep(3000)Send("{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{DEL}{DEL}")Sleep(3000)Send("{CTRLDOWN}g{CTRLUP}{ALTDOWN}{F4}{ALTUP}")Sleep(3000)Send("{CTRLDOWN}v{CTRLUP}{SPACE}")$i=$i+1WEnd
water Posted October 5, 2019 Posted October 5, 2019 Global $i = 1 Global $EndValue = Random(1, 4) While $i <= $EndValue Sleep(3000) Send("{LWINDOWN}r{LWINUP}") Sleep(3000) Send("C:\Users\123\Catalogos\tags.txt{ENTER}") Sleep(3000) WinActivate("tags: Bloc de notas", "") Sleep(3000) Send("{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{DEL}{DEL}") Sleep(3000) Send("{CTRLDOWN}g{CTRLUP}{ALTDOWN}{F4}{ALTUP}") Sleep(3000) Send("{CTRLDOWN}v{CTRLUP}{SPACE}") $i = $i + 1 WEnd Wasn't too hard, was it? Garrik 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Developers Jos Posted October 5, 2019 Developers Posted October 5, 2019 @Garrik, Sad to see the zero effort approach. It won't get you far when you are unwilling to take direction and learn yourself, but that is your choice. Skeletor, Earthshine and Musashi 3 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Garrik Posted October 5, 2019 Author Posted October 5, 2019 (edited) Is not that, like I said Im not that expierenced, Im trying to learn by examples applied in what I do, Im sorry if I bother all of you Im just trying yo learn, and as I sayed I did that script by my self. Now you just said that "send" is not the best option... I'll see what can I do to change it. And again thanks for helping! Edited October 5, 2019 by Garrik
rm4453 Posted October 5, 2019 Posted October 5, 2019 (edited) @garrik Let's start by answering this question: How does one select a random number? Answer: https://www.autoitscript.com/autoit3/docs/functions/Random.htm Alright next question: How does one put the randomly selected number into a variable? Answer: https://www.autoitscript.com/autoit3/docs/functions/Random.htm Next question: How does one use that variable to determine how many times to loop? Answer: Look at your code! *OR: https://www.autoitscript.com/autoit3/docs/functions/Random.htm Edited October 5, 2019 by rm4453
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