XenonTech Posted September 12, 2014 Share Posted September 12, 2014 (edited) While True $vVariable = "Have a nice day!" $vVariable = "Tacos taste good." $vVariable = "Shrek is love!" Send($vVariable) WEnd So basically the first time it loops I want it to send "Have a nice day!" then the second time, "Tacos taste good." and then on the third time to send "Shrek is love!" and then make it go back to the first variable and repeat the process. How is this possible? Edited September 12, 2014 by XenonTech Link to comment Share on other sites More sharing options...
MikahS Posted September 12, 2014 Share Posted September 12, 2014 (edited) Something like this.. $counter = 0 While True If $counter = 0 Then $vVariable = "Have a nice day!" Send($vVariable) EndIf If $counter = 1 Then $vVariable = "Tacos taste good." Send($vVariable) EndIf If $counter = 2 Then $vVariable = "Shrek is love!" Send($vVariable) EndIf $counter += 1 WEnd EDIT: Fixed formatting Edited September 12, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Danyfirex Posted September 12, 2014 Share Posted September 12, 2014 HI. Local $aArray[3]=["Have a nice day!", "Tacos taste good.", "Shrek is love!"] Local $i=0 While True ConsoleWrite($aArray[$i] & @CRLF) Send($vVariable) $i+=1 if $i=3 Then $i=0 WEnd Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
MikahS Posted September 12, 2014 Share Posted September 12, 2014 Doh on my part; Using an array would be the simplest method as shown by Danyfirex Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
trancexx Posted September 12, 2014 Share Posted September 12, 2014 But that's overcomplicating. Both of the examples can be reduced to: While True Send("Have a nice day!") Send("Tacos taste good.") Send("Shrek is love!") WEnd Somehow I think that's not what the OP meant. Danyfirex 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
XenonTech Posted September 12, 2014 Author Share Posted September 12, 2014 But that's overcomplicating. Both of the examples can be reduced to: While True Send("Have a nice day!") Send("Tacos taste good.") Send("Shrek is love!") WEnd Somehow I think that's not what the OP meant. I was using this method, but I recently went from 5 or 6 variables to a few thousand. I just want the code to be as compact as possible. Link to comment Share on other sites More sharing options...
XenonTech Posted September 12, 2014 Author Share Posted September 12, 2014 Thanks for the help everyone! Link to comment Share on other sites More sharing options...
XenonTech Posted September 12, 2014 Author Share Posted September 12, 2014 (edited) HI. Local $aArray[3]=["Have a nice day!", "Tacos taste good.", "Shrek is love!"] Local $i=0 While True ConsoleWrite($aArray[$i] & @CRLF) Send($vVariable) $i+=1 if $i=3 Then $i=0 WEnd Saludos So would I write Send($vVariable) to send the varaible? The array doesn't define the variable name in there. Sorry, I'm new to autoit. Edited September 12, 2014 by XenonTech Link to comment Share on other sites More sharing options...
Danyfirex Posted September 12, 2014 Share Posted September 12, 2014 of course you should send the array. Local $aArray[3]=["Have a nice day!", "Tacos taste good.", "Shrek is love!"] Local $i=0 While True ConsoleWrite($aArray[$i] & @CRLF) Send($aArray[$i]) $i+=1 if $i=3 Then $i=0 WEnd Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Gianni Posted September 12, 2014 Share Posted September 12, 2014 (edited) also this could do: Local $aArray[3]=["Have a nice day!", "Tacos taste good.", "Shrek is love!"] for $i = 0 to UBound($aArray)-1 Send($aArray[$i]) Next Edit: better reading OP I see that the loop should repeat forever this will correct my previous listing. Sorry. Local $aArray[3] = ["Have a nice day!", "Tacos taste good.", "Shrek is love!"] HotKeySet('{ESC}', '_exit') While True For $i = 0 To UBound($aArray) - 1 Send($aArray[$i] & @CR, 1) Next WEnd Func _exit() Exit EndFunc ;==>_exit Edited September 12, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
czardas Posted September 12, 2014 Share Posted September 12, 2014 (edited) Mod() is sometimes a good function for this kind of thing. ; HotKeySet('{ESC}', '_exit') Local $aArray[3] = ["Have a nice day!", "Tacos taste good.", "Shrek is love!"], _ $i = 0 While True Send($aArray[Mod($i, 3)] & @CR, 1) $i += 1 ; This value will eventually go out of range (> 99999999999999). WEnd Func _exit() Exit EndFunc ;==>_exit ; Theoretically the code will stop working because the variable $i will eventually go out of range. It probably won't happen within a milenium: because the Send function is really slow. If the looped process is millions of times faster, then out of range values could become a problem, in which case the code will need to be ammended. Edited September 12, 2014 by czardas Gianni 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Exit Posted September 13, 2014 Share Posted September 13, 2014 my two Cents: ControlFocus("[CLASS:SciTEWindow]","","Scintilla2") HotKeySet('{ESC}', '_exit') Func _exit() Exit EndFunc ;==>_exit Local $aArray[3] = ["Have a nice day!", "Tacos taste good.", "Shrek is love!"] For $i = 0 To 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 Send($aArray[Mod($i, 3)] & @CRLF, 1) Next App: Au3toCmd UDF: _SingleScript() 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