Jump to content

Loop?


Newguy
 Share

Recommended Posts

Hi, I am brand new to the scripting world and this is my first script. I would like to run the following script for a series of numbers, which are not sequential. For example: 546004-546780 (again, not sequential). I can pull this from an excel spreadsheet if need be.

Can you tell me what kind of loop, or functions I would need in order to execute this?

WinActivate("Ship Wave Rule Definition - Windows Internet Explorer", "")
Mouseclick("Left",611,278,1,100)
Mouseclick("Left",993,56,1,100)
Mouseclick("Left",1142,274,1,100)
Send("{BACKSPACE 6}")
Send("546004")
Mouseclick("Left",927,54,1,100)
Mouseclick("Left",1178,53,1,100)
WinWaitActive("Wave Template - Windows Internet Explorer")
Mouseclick("Left",523,74,1,50)
WinWaitActive("Message from webpage")
Mouseclick("Left",933,594,1,20)
 

Thanks

Link to comment
Share on other sites

Thanks, I will look into the IE UDFs for the mouseclicks. However, I would still like to know how to perform this task, where the variable is the job # 546004. The script will remain the same with the exception of the job #. So instead of having to type in a different job # each time, I would like to copy/paste in the job #s in, so that the script repeats itself but it would use a different job # each time it ran.

Send("546004")

Send("546006")

Send("546100")

Link to comment
Share on other sites

To read your numbers from Excel for sending in your script you can use the Excel UDF.  Take a look at_ExcelReadArray and  _ExcelReadSheetToArray.  Once your values are in an array you can loop through it to pass them to your function.  Be sure to #include <Array.au3> and #invclude <Excel.au3> at the top.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Here is a snippet to get you started that hard codes the values - as you can see from the other posts you could also pull them from a file or spreadsheet.

#include <Array.au3>

dim $myArray[3] = ["546004", "546006","546100"]

run("notepad.exe")

Sleep(3000)

for $a=0 to UBound($myArray)-1
    send($myArray[$a]&@crlf)
Next

MsgBox("","","All done with example")

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Again, thanks to all who have posted. And I apologize for not being more clear, as I'm a newbie. Jfish, your example almost gives me what I need, except that I would need each job # to run independently. I have hundreds that I would need to run one at a time. I have my list in excel, but can also paste it into the script.

Link to comment
Share on other sites

His example will do that if you add all the necessary steps into the for loop.

Edit: After you do some research and develop your script some more, post what you have created and we may be able to help further :)

Edited by Shrapnel
Link to comment
Share on other sites

I agree with Shrapnel, you will need to make an effort to try some coding yourself.  We have laid out the framework for you.  I am not sure from your posts if you understand what we were saying so I will over-explain a bit ...  An array holds a collection of information.  In this case, my example is storing only the three example values you offered.  This is the array holding the values we want to send in my example:

dim $myArray[3] = ["546004", "546006","546100"]

Once you have your data in an array you can loop through it like I did in my snippet.  You can use my example for how to pull items out of an array and send them using the send function.

for $a=0 to UBound($myArray)-1
    send($myArray[$a]&@crlf)
Next

While it is true my array is hard coded into my script (meaning that the script itself contains the values we are sending) I could have created it from a text file or a spreadsheet.  You say your values are in Excel.  Please refer to the below for how to read those from your spreadsheet and pull them into an array:

#include <Excel.au3>
#include <Array.au3>

$sFilePath1 = @ScriptDir & "\YOURSPREADSHEET.xls" ;This file should already exist - this is your file containing the values to send
$oExcel = _ExcelBookOpen($sFilePath1); this opens the spreadsheet and creates an Excel object

$aArray = _ExcelReadSheetToArray($oExcel) ;This reads everything on your sheet into an array (could take time if you have thousands)
_ArrayDisplay($aArray, "Array containing my info"); this displays your data in an array so you can see if it worked. Then you can add it to your loop.

Good luck.

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...