Newguy Posted October 29, 2013 Share Posted October 29, 2013 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 More sharing options...
Shrapnel Posted October 29, 2013 Share Posted October 29, 2013 (edited) What program website are you trying to automate? Edited October 29, 2013 by Shrapnel JayHawkfl 1 Link to comment Share on other sites More sharing options...
Newguy Posted October 29, 2013 Author Share Posted October 29, 2013 It is a web-based database that we use at work, that's really all I can say about it. Thanks Link to comment Share on other sites More sharing options...
Shrapnel Posted October 29, 2013 Share Posted October 29, 2013 The webpage title of "Ship Wave Rule Definition" kinda sounds like a game to me, and for that reason I cannot offer you any help. Link to comment Share on other sites More sharing options...
Newguy Posted October 29, 2013 Author Share Posted October 29, 2013 The name of the system is Warehouse Management Web. I am trying automoate the task of running our jobs (546004) through our MRP system, instead of doing it manually. Link to comment Share on other sites More sharing options...
Shrapnel Posted October 29, 2013 Share Posted October 29, 2013 Well since you are using internet explorer, i would first suggest looking into the _IE UDF for much more reliable automation than using mouseclick commands Link to comment Share on other sites More sharing options...
Newguy Posted October 29, 2013 Author Share Posted October 29, 2013 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 More sharing options...
Jfish Posted October 29, 2013 Share Posted October 29, 2013 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 More sharing options...
Shrapnel Posted October 29, 2013 Share Posted October 29, 2013 you could also just use a .txt file with all the numbers and the _FileReadToArray function if you dont want to mess with excel Link to comment Share on other sites More sharing options...
Jfish Posted October 29, 2013 Share Posted October 29, 2013 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 More sharing options...
Newguy Posted October 29, 2013 Author Share Posted October 29, 2013 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 More sharing options...
Shrapnel Posted October 29, 2013 Share Posted October 29, 2013 (edited) 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 October 29, 2013 by Shrapnel Link to comment Share on other sites More sharing options...
Jfish Posted October 30, 2013 Share Posted October 30, 2013 (edited) 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 October 30, 2013 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 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