Krishna Posted June 23, 2009 Posted June 23, 2009 Dear Friends, Few days back i started using AutoIt and really wondering this is very good tool and it is for free. Thanks to AutiIt team. I developed an AutoIt script (Converter.au3) which simple invokes a GUI application then it selects say File->convert, then access edit boxes, list box and items, buttons etc. It is perfectly working fine. Basically the GUI application selects a set of files from a directory and converts into another format. Now if i run the autoit script 2 times simultaneously none of the instance will work properly . 1) some times only first main window (for both the Converter.a3u instances) will display and nothing happens further. 2) some times an error - _MemInit:Invalid Window Handle is popped up. My question (requirement) is i need to simultaneously invoke multiple instances of Convert.au3 script. Will there will be clashes of windows displayed by different .a3u scripts. Is there a way to deal with a GUI instanace and its sub windows by a particular instance of Convert.au3 which has invoked the GUI originally. Please give me ideas or point to some examples or documentation. Thanks in adavance . Regards, Krishna
picea892 Posted June 23, 2009 Posted June 23, 2009 Would you mind showing some code. so we can get a sense of what is going on. Are you using titles? You should probably be using handles. Handles are unique to a window where titles will not be. So if you have more than one window with the same title the script may hit the wrong window. I understand It would find the first one via the Z order
Krishna Posted June 24, 2009 Author Posted June 24, 2009 Would you mind showing some code. so we can get a sense of what is going on. Are you using titles? You should probably be using handles. Handles are unique to a window where titles will not be. So if you have more than one window with the same title the script may hit the wrong window. I understand It would find the first one via the Z order Hello Picea, Thank you very much your response. I have copied my script below. As you pointed out i am using the title of the windos to access it and its controls. I shall try with handles. After going thru the below script if you have any suggestions please let me know. Regards, Krishna #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: Script Function: To Invoke RW.exe, select RW files and convert them into Std files. #ce ---------------------------------------------------------------------------- #include <GUIListBox.au3> #include <GuiListView.au3> #include <GuiEdit.au3> ; Check if required no. of arguments are supplied If $CmdLine[0] < 3 Then MsgBox(0, "Incorrect arguments specified. Exiting...", "Usage : RW150Converter <RW150 EXE PATH> <RW Input Files Directory> <RW Output Files Directory>"); Exit EndIf ; Invoke RW.exe Run($CmdLine[1]) ; Wait until RW main window is displayed WinWaitActive("DEFAULT - RW Converter Module") ; A message box saying 'Port in use Try different port' will be popped up. ; If so then simply press 'OK', then In the 'Settings' window click on CANCLE (INSTANCE:22) If WinExists("RW") OR WinActive("RW") Then Send("{ENTER}") WinWaitActive("Change Settings") ControlClick("Change Settings", "", "[CLASS:Button; INSTANCE:22]") WinWaitClose("Change Settings") EndIf If WinExists("PW150TM") OR WinActive("PW150TM") Then Send("{ENTER}") WinWaitActive("Change Settings") ControlClick("Change Settings", "", "[CLASS:Button; INSTANCE:22]") WinWaitClose("Change Settings") EndIf ; Select File->Change Settings Send("!f") Send("{ENTER}") ; Wait for the Change Settings window to appear WinWaitActive("Change Settings") ; Modify the edit box 'Current Drive Directory' edit box to show RW input files path $hPath = ControlGetHandle("", "", 1124) _GUICtrlEdit_SetText($hPath, $CmdLine[2]) ; Modify the edit box 'Current download/write path' edit box to show Std output files path $hPath = ControlGetHandle("", "", 1103) _GUICtrlEdit_SetText($hPath, $CmdLine[3]) ControlClick("Change Settings", "", "[CLASS:Button; INSTANCE:21]") WinWaitClose("Change Settings") If WinExists("RW") OR WinActive("RW") Then Send("{ENTER}") WinWaitActive("Change Settings") ControlClick("Change Settings", "", "[CLASS:Button; INSTANCE:22]") WinWaitClose("Change Settings") EndIf ; Select File->Convert... Send("!f") Send("{DOWN}") Send("{DOWN}") Send("{ENTER}") ; Wait for the window 'Choose on or more ...' to appear WinWaitActive("Choose one or more files to convert") ; From the window get the handle of the ListBox showing the list of RW files. $hListBox = ControlGetHandle("Choose one or more files to convert", "", 0) ; Get the count of RAW files from the ListBox $RWFileCount = _GUICtrlListBox_GetCount($hListBox) ; Get the handle for the 'Files Selected' Edit box. $hEditBox = ControlGetHandle("", "", 1046) ; Update the 'Files Selected' Edit box with the no. of RAW files count _GUICtrlEdit_SetText($hEditBox, $RWFileCount) ; Now select all the RAW files listed in the ListBox Send("{SHIFTDOWN}") For $i = 0 to ($RWFileCount - 1) Step 1 _GUICtrlListBox_ClickItem($hListBox, $i, "left", False, 2) Next Send("{SHIFTUP}") ; Click 'OK' button to start converting RAW files ControlClick("", "", "[CLASS:Button; INSTANCE:6]") ; Wait until the conversion is completed and a pop up display the status of conversion WinWaitActive("RW") If WinExists("RW", "") OR WinActive("RW", "") Then Send("{ENTER}") EndIf If WinExists("RW", "") OR WinActive("RW", "") Then Send("{ENTER}") EndIf ; Click 'Cancle' button to exit the 'Choose one or more files....' window. ControlClick("", "", "[CLASS:Button; INSTANCE:7]") WinWaitClose("Choose one or more files to convert") ; Now conversion process is completed so exit from the PW250TM main window. Select File->Exit Send("!f") Send("{DOWN}") Send("{DOWN}") Send("{DOWN}") Send("{DOWN}") Send("{DOWN}") Send("{DOWN}") Send("{ENTER}") WinWaitClose("DEFAULT - RW Converter Module") ; END
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