olo Posted May 16, 2013 Share Posted May 16, 2013 Hey Guys, Ive a file that I open and do all sorts of things with it. But my script only works when I do it for 1 file. How would I get it to: rerun through the tasks after Ive finished dealing with the first file. With about say 3 files of .XML extension on the desktop? This is my main script with the majority of functions and actions taking place inside the #include files. expandcollapse popup AutoItSetOption("SendKeyDelay", 50) #include <.\KSM-500\kWorkbench\kWorkbench_Open.au3> #include <.\KSM-500\kWorkbench\kWorkbench_Close.au3> #include <.\KSM-500\kSetup\kSetup_Close.au3> #include <..\Desktop\LoadFilekWB.au3> #include <..\Desktop\Setup.au3> #include <..\Desktop\Verify.au3> #include <..\Desktop\Program.au3> #include <.\Library\Error_log.au3> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Local $file = "BCU101C_DSI002.XML" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HotKeySet("{PAUSE}", "Quit") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func kWBOpen($installDir = "c:\acra", $timeout = 4) Return kOpenTheCane("kWorkbench.exe", "TkWBForm", $installDir, $timeout) EndFunc Func LDfiletask() Return LoadfileWB("TkWBForm", "Open", "TForm1", $file) EndFunc Func SnVnPTest() Return SnVnP("TDockingHolder", 10) EndFunc Func ksetClose($timeout = 4) Return KstpClose("TDockingHolder", $timeout) EndFunc Func VerFile($timeout = 20) Return Verify("TResultsForm", $timeout) EndFunc Func Prog($timeout = 20) Return Program("TResultsForm", $timeout) EndFunc Func kWorkClose() Return kWBClose("TkWBForm") EndFunc Func Quit() Exit EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func Main() $gInteractiveLog = 1 ;initialize log ACRAOpenLog("kWorkbench Task.log", 2) kWBOpen() LDfiletask() SnVnPTest() ksetClose() VerFile() Prog() kWorkClose() ; close the log ACRACloseLog() EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Main() Link to comment Share on other sites More sharing options...
water Posted May 16, 2013 Share Posted May 16, 2013 There are many ways to skin this cat. I would pack the processing into a function. And then loop through the list of files using FileFindFirstFile, FileFindFirstFile, FileClose and call the function for every file found. olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 16, 2013 Author Share Posted May 16, 2013 Hmm I see what you mean. But its a bit all over the place, my script that is. The basic run down of the script is as follows: 1) Open program called kWorkbench 2) Load an XML file into it. 3) Click a button in the kWorkbench which runs a program to setup stuff. After that is finished it closes and returns to kWorkbench 4) Click a button in kWorkbench that verifies the XML file. (Basically an info window) 5)Click a button in kWorkbench that programs the XML file. (Basically an info window) 6) Close kWorkbench Now I have a script for each of those steps that are assembled into the one above. Then the steps are run by calling the main function. Link to comment Share on other sites More sharing options...
water Posted May 16, 2013 Share Posted May 16, 2013 "If you can make it there, you make it anywhere". Sorry, it's not NY, it's AutoIt. But if you can make it for a single file it's easy to make it for many files. olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 16, 2013 Author Share Posted May 16, 2013 haha so just gotta loop through everything using those functions you listed. Link to comment Share on other sites More sharing options...
water Posted May 16, 2013 Share Posted May 16, 2013 Correct. olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 16, 2013 Moderators Share Posted May 16, 2013 olo, And do not use FileFindFirst/NextFile, use the _FileListToArray function to get an array of the files - or my RecFileListToArray UDF if you need more than one extension or to search recursively. M23 olo 1 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...
jdelaney Posted May 16, 2013 Share Posted May 16, 2013 (edited) If at some point your XML collection becomes huge, I'd suggest reading up on the xml.dom to speed up your output. edit: although, I don't know exactly what your app does...it's still a possiblity to reduce time for output Edited May 16, 2013 by jdelaney olo 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
olo Posted May 16, 2013 Author Share Posted May 16, 2013 Thanks guys ill go away and see what I come back with in a few. Link to comment Share on other sites More sharing options...
water Posted May 16, 2013 Share Posted May 16, 2013 Melba, what's wrong with FileFindFirst/Next _FileListToArray does the same under the covers. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 16, 2013 Moderators Share Posted May 16, 2013 water, Nothign worng with them at all - but in my opinion is is better for newer coders to use existing functions that wrap more complex concepts. There is much less chance of the script failing for reasons unconnected with the actual reason the script is being written - and it is much easier for us to debug when needed. Besides FileFindFirst/NextFile are themselves actually wrappers of the API calls - should we suggest the OP thinks about coding at the DllCall level? When coding in any level language I feel that you should take advantage of the libraries that are available until you feel confident enough to look deeper. But as I said that is a personal opinion - no-one is forced to follow it. M23 olo 1 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...
water Posted May 16, 2013 Share Posted May 16, 2013 I just wanted to keep it as simple as possible. I've often seen users asking this kind of questions having problems with arrays as well. But as I mentioned above: There are many ways to .... olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 17, 2013 Author Share Posted May 17, 2013 Heys guys ok Ive got it sort of working. The script runs etc and it detects there are 3 XML files in the desktop. So it runs 3 times, however it loads the same XML file 3 times. Now the XML file is located on the desktop along with the others. Is there any way to instead of set 1 specific file have it load the next XML file each time.? Local $file = "BCU101C_DSI002.XML" Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 Can you post the code where you enumerate the XML files and do the processing? olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 17, 2013 Author Share Posted May 17, 2013 (edited) Well here is now what my main looks like along with the loading script: expandcollapse popup#include-once #include <C:\Documents and Settings\User\Desktop\Library\Error_log.au3> Func LoadfileWB($MainWindowClassName, $ExternalTitle, $MsgSvrclass, $file) WinWaitActive("[CLASS:" & $MainWindowClassName & "]") WinSetState("[CLASS:" & $MsgSvrclass & "]", "", @SW_MINIMIZE) ControlClick("[CLASS:" & $MainWindowClassName & "]", "", "TButton1") Sleep(500) ControlCommand("[TITLE:" & $ExternalTitle & "]", "", "ToolbarWindow322", "SendCommandID", "41061") Sleep(500) If (ControlSend("[TITLE:" & $ExternalTitle & "]", "", "Edit1", $file)) Then If (ControlGetText ( "[TITLE:Open; ]", $file, 1148 )) Then ControlClick("[TITLE:" & $ExternalTitle & "]", "&Open", "Button2", "left", 1) Sleep(500) Else ACRAOutputError("Function not entered correctly via keyboard.") Exit EndIf Else Sleep(2000) ControlCommand("[TITLE:" & $ExternalTitle & "]", "OK", "[CLASS:Button; INSTANCE:1;ID:2 ]", "Check", "") ACRAOutputError("Function timed out while trying to load the file!") Exit EndIf ;Return False EndFunc ;Func LDfiletask() ; Return LoadfileWB("TkWBForm", "Open", "TForm1", $file) ;EndFunc ;LDfiletask() Local $file = "BCU101C_DSI002.XML" Local $Stats_TotalFiles = 0 Local $path = "C:\Documents and Settings\User\Desktop\" expandcollapse popupFunc Main() $gInteractiveLog = 1 ;initialize log ACRAOpenLog("kWorkbench Task.log", 2) Local $search = FileFindFirstFile($path & "*.XML") ; Check if the search was successful If $search = -1 Then ACRAOutputError("No files/directories matched the search pattern") Exit EndIf While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop $Stats_TotalFiles = $Stats_TotalFiles +1 kWBOpen() LDfiletask() SnVnPTest() ksetClose() VerFile() Prog() kWorkClose() Sleep(1000) WEnd ; Close the search handle FileClose($search) ShowStats() #cs kWBOpen() LDfiletask() SnVnPTest() ksetClose() VerFile() Prog() kWorkClose() #ce ; close the log ACRACloseLog() EndFunc Edited May 17, 2013 by olo Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 Where do you call LoadfileWB and which parameters do you pass? olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 17, 2013 Author Share Posted May 17, 2013 Where do you call LoadfileWB and which parameters do you pass? I have this function part of the main executable scipt. So the below function is just a few lines above the main function that I posted earlier. Func LDfiletask() Return LoadfileWB("TkWBForm", "Open", "TForm1", $file) EndFunc Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 I see nothing wrong with your code. You could inserte some debugging statements like ConsoleWrite("x: " & $file & @CRLF) in your script to verify that the content of $file is as expected. Replace "x: " with the location in your script (e.g. function name or whatever). olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 17, 2013 Author Share Posted May 17, 2013 (edited) no no the script executes fine. But I have 3 XML files on the desktop. Each of a different name. This script executes 3 times but each time using the same name. What I want to do is fine a way for the variable $file to look for the other XML files and not just the one below. local $file = "BCU101C_DSI002.XML" Edited May 17, 2013 by olo Link to comment Share on other sites More sharing options...
Solution water Posted May 17, 2013 Solution Share Posted May 17, 2013 I see. Set Local $file = "BCU101C_DSI002.XML" to Global $file = "BCU101C_DSI002.XML" and set Local $file = FileFindNextFile($search) to $file = FileFindNextFile($search) olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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