mhosbo Posted November 9, 2010 Share Posted November 9, 2010 Ok, before anyone tells me to read the help file or do a search, know that 1. I'm a beginner and 2. I searched for my answers before registering. Here's my issue that I just can't figure out on my own. I spent 2 hours searching, reading and failing. I need to do an unseeded random number between 950 and 1250, about 300 times. Let me know if more information is required. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 9, 2010 Moderators Share Posted November 9, 2010 mhosbo Welcome to the AutoIt forum. I spent 2 hours searching, reading and failingIn that case I think you need some "searching, reading" classes. Quoted from the Help file: #----------------------------- Random - Generates a pseudo-random float-type number. Random ( [Min [, Max [, Flag]]] ) Parameters Min [optional] - The smallest number to be generated. The default is 0. Max [optional] - The largest number to be generated. The default is 1. Flag [optional] - If this is set to 1 then an integer result will be returned. Default is a floating point number. #----------------------------- So you would need: Random(950, 1250, 1) Now for doing this 300 times you need a loop. Again from the Help file under <Language Reference - Loop Statements> we find: #----------------------------- A loop is how you refer to a section of script that you repeat a number of times. You might want to loop a given number of times or you might wish to repeat a section of script as long as a certain condition is true or false. The following loop statements are available in AutoIt: For...Next While...WEnd Do...Until For...In...Next While (no pun intended) all the statements perform similar functions, they are slightly different and one will usually be more appropriate than another for a given situation #----------------------------- You would be best served by a For...Next loop - so let us look at that in the Help file: #----------------------------- For...To...Step...Next - Loop based on an expression. For <variable> = <start> To <stop> [step <stepval>] statements ... Next Parameters variable - The variable used for the count. start - The initial numeric value of the variable. stop - The final numeric value of the variable. stepval - [optional] The numeric value (possibly fractional) that the count is increased by each loop. Default is 1 #----------------------------- So you would need: For $i = 1 To 300 ; Your random number generating code Next Now we need to think how to store the random numbers you generate - but you need to explain what you want to do with them first. All clear so far? 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 Link to comment Share on other sites More sharing options...
mhosbo Posted November 9, 2010 Author Share Posted November 9, 2010 At least I don't need failing classes, I've got that down. Here's what I'm doing. A number of MouseClicks, then send random number between 950 and 1250. Same thing, over and over, with some other stuff in the middle that I've already figured out how to do. I'm not doing this exactly 300 times. That number is unknown to me right now. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 9, 2010 Moderators Share Posted November 9, 2010 mhosbo,A number of MouseClicks, then send random number between 950 and 1250. Same thing, over and over, with some other stuff in the middle that I've already figured out how to doNow what does that make me think you are automating? How are you determining the number of passes through the loop? How do you know when it is time to stop? 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 Link to comment Share on other sites More sharing options...
mhosbo Posted November 9, 2010 Author Share Posted November 9, 2010 (edited) It is automation that I'm going to use on a program at work. Is that illegal? It will stop when I press esc. I'll be able to delete the records I don't need(on the work app) that are created through the macro. Edited November 9, 2010 by mhosbo Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 9, 2010 Moderators Share Posted November 9, 2010 mhosbo, Is that illegal?My apologies - sounded a lot like a game! If you do not know how many passes you need, then I would suggest a While...WEnd loop which you break out of with the escape key: #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 ; Start an infinite loop ; Random number code ; Other stuff If _IsPressed("1B", $dll) Then ExitLoop ; Exit loop if ESC pressed WEnd DllClose($dll) Exit 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 Link to comment Share on other sites More sharing options...
mhosbo Posted November 9, 2010 Author Share Posted November 9, 2010 I guess I'm just not cut out for this kinda stuff. I'll just keep studying and hopefully it will click in my brain one day. Thanks for trying to help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 9, 2010 Moderators Share Posted November 9, 2010 mhosbo, Why give up so easily? You get help here as you have just seen. What about the code I posted do you not understand? 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 Link to comment Share on other sites More sharing options...
mhosbo Posted November 10, 2010 Author Share Posted November 10, 2010 I guess I was hoping to assign a random number to a variable. That way, whenever I needed to send that random number, I could just do "Send ($n)" Mouseclick ( ) Send ($n) ;random number between 950 and 1250 ;code that opens a blank page Mouseclick ( ) Send {$n) Rinse and repeat. Like I said before, I am extremely new to coding/programming. Just trying to make it easier on me and my co-workers. Link to comment Share on other sites More sharing options...
AlmarM Posted November 10, 2010 Share Posted November 10, 2010 I guess I was hoping to assign a random number to a variable. That way, whenever I needed to send that random number, I could just do "Send ($n)" Mouseclick ( ) Send ($n) ;random number between 950 and 1250 ;code that opens a blank page Mouseclick ( ) Send {$n) Rinse and repeat. Like I said before, I am extremely new to coding/programming. Just trying to make it easier on me and my co-workers. Whats so hard then? Global $n = Random(950, 1250, 1) Send($n) Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
mhosbo Posted November 10, 2010 Author Share Posted November 10, 2010 Whats so hard then? Global $n = Random(950, 1250, 1) Send($n) Using that returned the same number. Here's what I have. Global $n = random(950, 1250, 1) send ($n) send ("{ENTER}") send ($n) send ("{ENTER}") send ($n) send ("{ENTER}") Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 10, 2010 Share Posted November 10, 2010 Of course it's the same number, you never change it! $n = random(950, 1250, 1) send ($n) send ("{ENTER}") $n = random(950, 1250, 1) send ($n) But this is a unnecessary way of doing it if you only use the numbers once. just do: send (random(950, 1250, 1)) send ("{ENTER}") send (random(950, 1250, 1)) send ("{ENTER}") .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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