BigBob Posted July 4, 2006 Share Posted July 4, 2006 Hi, I'm creating a For....Next loop in AutoIT 3, but on each iteration i want the variable $Numb1 to change. The actual variables that i want $Numb1 to change to are located in an excel spreadsheet range A1:A600. So effectively i want $Numb1 to change to the next number in the range on each iteration. I can't figure out a way to read the cells. I've tried to manually create an array to get the variables in (creating a 1 cell formula in excel to save me typing) ..but i'm sure i am missing something. Any help would be greatly appreciated Bob Build it bigger.....build it better! Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 4, 2006 Share Posted July 4, 2006 HI, show your code, please. I shouldn't be difficult if you already got the values in an array. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
BigBob Posted July 4, 2006 Author Share Posted July 4, 2006 HI, show your code, please. I shouldn't be difficult if you already got the values in an array. So long, Mega OK here my code. This is my first attempt at scripting so sorry if its very messy. I've tried to decelare the array in the first line but thats all i can do, i have no idea how to actually use an array. I simply need $numb1 to reflect the contents of the array. ********************************************************** ; AutoIt Version: 3.0 ; ; Script Function: ; Records data points ;\/ \/ \/ \/ \/ i'm taking a serious guess as to how to declare an array Global $big_Array[33] = ['0.05','0.1','0.03','0.02','0.06','0.04','0.02','0.06','0.01','0.02','0.04','0.09','0.08','0.09','0.07','0.07','0.05','0.03','0.06','0.07','0.06','0.04','0.02','0.09','0.1','0.04','0.08','0.08','0.07','0.1','0.1','0.07','0.02'] ; Prompt the user to run the script - use a Yes/No prompt $answer = MsgBox(4, "Data Picker", "Do you want to enter data points? This may take a while depending on the number of points") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "Data Picker", "OK. Bye!") Exit EndIf ; Lets find out the number of data points to be recorded by asking the user $NPoints = InputBox("Data Picker", "Please type in the number of data points you wish to enter and click OK") ; Execute the loop to cover all points For $count = 1 To $Npoints WinActivate("Olap-Indices") Send("^r") WinActivate("Olap-Indices2") Send("{RIGHT}") Send("{ENTER}") Send($Numb1) <------this is the var to change on each iteration, reflecting each value in the array WinActivate("Olap-Indices") Send("^s") WinActivate("Microsoft Excel - Data Values 020706") Send("^c") Send("{DOWN}") WinActivate("Enter points name") Send("^v") Send("{ENTER}") WinActivate("Olap-Indices2") Send("{DOWN}") Next ; Finished! MsgBox(0, "AutoIt Example", "Finished!") Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 4, 2006 Share Posted July 4, 2006 (edited) Hi, something like this? expandcollapse popup;\/ \/ \/ \/ \/ i'm taking a serious guess as to how to declare an array Global $big_Array[33] = ['0.05', '0.1', '0.03', '0.02', '0.06', '0.04', '0.02', '0.06', '0.01', '0.02', '0.04', '0.09', '0.08', '0.09', '0.07', '0.07', '0.05', '0.03', '0.06', '0.07', '0.06', '0.04', '0.02', '0.09', '0.1', '0.04', '0.08', '0.08', '0.07', '0.1', '0.1', '0.07', '0.02'] ; Prompt the user to run the script - use a Yes/No prompt $answer = MsgBox(4, "Data Picker", "Do you want to enter data points? This may take a while depending on the number of points") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "Data Picker", "OK. Bye!") Exit EndIf ; Lets find out the number of data points to be recorded by asking the user $NPoints = InputBox("Data Picker", "Please type in the number of data points you wish to enter and click OK") ; Execute the loop to cover all points For $count = 1 To UBound($big_Array) - 1 ;$Npoints WinActivate("Olap-Indices") Send("^r") WinActivate("Olap-Indices2") Send("{RIGHT}") Send("{ENTER}") Send($big_Array[$count]) ;<------this is the var to change on each iteration, reflecting each value in the array WinActivate("Olap-Indices") Send("^s") WinActivate("Microsoft Excel - Data Values 020706") Send("^c") Send("{DOWN}") WinActivate("Enter points name") Send("^v") Send("{ENTER}") WinActivate("Olap-Indices2") Send("{DOWN}") Next ; Finished! MsgBox(0, "AutoIt Example", "Finished!") Edit: maybe this For $count = 1 To UBound($big_Array) - 1 ;$Npoints should be For $count = 1 To $Npoints So long, Mega Edited July 4, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 5, 2006 Share Posted July 5, 2006 OK here my code. This is my first attempt at scripting so sorry if its very messy. I've tried to decelare the array in the first line but thats all i can do, i have no idea how to actually use an array. I simply need $numb1 to reflect the contents of the array. CODE********************************************************** ; AutoIt Version: 3.0 ; ; Script Function: ; Records data points ;\/ \/ \/ \/ \/ i'm taking a serious guess as to how to declare an array Global $big_Array[33] = ['0.05','0.1','0.03','0.02','0.06','0.04','0.02','0.06','0.01','0.02','0.04','0.09','0.08','0.09','0.07','0.07','0.05','0.03','0.06','0.07','0.06','0.04','0.02','0.09','0.1','0.04','0.08','0.08','0.07','0.1','0.1','0.07','0.02'] ; Prompt the user to run the script - use a Yes/No prompt $answer = MsgBox(4, "Data Picker", "Do you want to enter data points? This may take a while depending on the number of points") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "Data Picker", "OK. Bye!") Exit EndIf ; Lets find out the number of data points to be recorded by asking the user $NPoints = InputBox("Data Picker", "Please type in the number of data points you wish to enter and click OK") ; Execute the loop to cover all points For $count = 1 To $Npoints WinActivate("Olap-Indices") Send("^r") WinActivate("Olap-Indices2") Send("{RIGHT}") Send("{ENTER}") Send($Numb1) <------this is the var to change on each iteration, reflecting each value in the array WinActivate("Olap-Indices") Send("^s") WinActivate("Microsoft Excel - Data Values 020706") Send("^c") Send("{DOWN}") WinActivate("Enter points name") Send("^v") Send("{ENTER}") WinActivate("Olap-Indices2") Send("{DOWN}") Next ; Finished! MsgBox(0, "AutoIt Example", "Finished!") Here's my tweaks... First, though your array declaration was fine, I find that kind of thing hard to maintain and edit later (I always screw up counting the number of elements), so I just declare it as $big_String, broken in easy to read parts, and let StringSplit() count the elements for me. Second, the prompt was changed to ask the operator for a number between 1 and the number of data points in $big_String, and to do verification on the operator's input. expandcollapse popup; $big_String is a comma delimited list of values to use $big_String = "0.05, 0.1, 0.03, 0.02, 0.06, 0.04, 0.02, 0.06, 0.01, 0.02, 0.04, 0.09" $big_String = $big_String & ", 0.08, 0.09, 0.07, 0.07, 0.05, 0.03, 0.06, 0.07, 0.06, 0.04, 0.02, 0.09" $big_String = $big_String & ", 0.1, 0.04, 0.08, 0.08, 0.07, 0.1, 0.1, 0.07, 0.02" ; Split $big_String into $big_Array, $big_Array[0] = count $big_Array = StringSplit(StringStripWS($big_String, 8), ",") ; Prompt the user to run the script - use a Yes/No prompt If MsgBox(32 + 4, "Data Picker", "Do you want to enter data points? This may take a while depending on the number of points") = 6 Then ; Lets find out the number of data points to be recorded by asking the user While 1 $NPoints = Number(InputBox("Data Picker", "Enter number of data points to enter (between 1 and " & $big_Array[0] & "), and click OK")) If @error = 0 Then If IsNumber($NPoints) And $NPoints >= 1 And $NPoints <= $big_Array[0] Then ExitLoop Else MsgBox(16, "Data Picker", "You did not enter a number between 1 and " & $big_Array[0] & "! Try again...") EndIf Else MsgBox(64, "Data Picker", "Operator Canceled!") Exit EndIf WEnd ; Execute the loop to cover all points For $count = 1 To $NPoints WinActivate("Olap-Indices") Send("^r") WinActivate("Olap-Indices2") Send("{RIGHT}") Send("{ENTER}") Send(String($big_Array[$count])) WinActivate("Olap-Indices") Send("^s") WinActivate("Microsoft Excel - Data Values 020706") Send("^c") Send("{DOWN}") WinActivate("Enter points name") Send("^v") Send("{ENTER}") WinActivate("Olap-Indices2") Send("{DOWN}") Next ; Finished! MsgBox(0, "AutoIt Example", "Finished!") Else MsgBox(0, "Data Picker", "OK. Bye!") EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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