bremen Posted April 20, 2016 Posted April 20, 2016 I have a small script to navigate a third party GUI and do some stuff. I have an excel spreadsheet that contains my data. I build an array off of that data and loop through it. I run into and issue if a part number is not recognized by my data base. What I think will eliminate this issue is once a part number is loaded "look at a certain field". If that field doesnt have anything in it then carry out one set of instructions and move to the next row in the array. If there is something there carry out a different set of instructions and move to the next row of the array. How can I make this possible? expandcollapse popup;; Builds an array of data from an excel work sheet ; opens excel workbook ;REST THE WORKBOOK FOR YOUR FILE PATH AND NAME Local $oExcel = _ExcelBookOpen("C:\ AUTO IT SPP Update 1.xls") ; reads data into array $aArray1 = _ExcelReadSheetToArray($oExcel, 1, 1, 0, 2, True) ; closes the excel workbook _ExcelBookClose($oExcel) ; displays the array that was read. _ArrayDisplay($aArray1) ; counts the number of rows in the array $rows = UBound($aArray1) -1 for $c = 1 to $rows ;;activates the window of the software I need to use and inputs the first part number WinActivate(" - [Inventory") WinWaitActive(" - [Inventory") ControlClick(" - [Inventory", "Part number:", 905, "left") controlsend(" - [Inventory", "Part number:", 905, $aArray1[$c][0]) send("{TAB}") Sleep(900) ;;This is where I am having the issue. After the tab command is sent if the part number doesn’t exist and the rest of the script continues it will cause an error with the software it is interacting with. ;;Performs the updates as required ControlCommand(" - [Inventory","Part number","SysTabControl325","TabRight","") ;;ControlClick(" - [Inventory", "Enable posting definition", 2288, "left") ControlCommand(" - [Inventory", "Enable posting definition", 2288, "Check", "") Sleep(900) ControlCommand(" - [Inventory", "Posting profile:", "ComboBox4", "ShowDropDown") ControlCommand(" - [Inventory", "Posting profile:", "ComboBox4", "SelectString", $aArray1[$c][1]) ControlCommand(" - [Inventory", "Posting profile:", "ComboBox4", "HideDropDown") send("{TAB}") Sleep(900) ;;applies my changes ControlClick(" - [Inventory", "Apply", 12321, "left") Sleep(900) ;;clears out the record and moves the next row in the array ControlClick(" - [Inventory", "Manufacturer code:", 1112, "left") Send("{ALT}f"&"n") Sleep(900) next
alien4u Posted April 20, 2016 Posted April 20, 2016 Something like this should help: WinActivate(" - [Inventory") WinWaitActive(" - [Inventory") ControlClick(" - [Inventory", "Part number:", 905, "left") If $aArray1[$c][0] <> "" Then controlsend(" - [Inventory", "Part number:", 905, $aArray1[$c][0]) send("{TAB}") Sleep(900) Else ContinueLoop Check if what you are going to send is not a NULL value and then Send it, otherwise jump to the next element on Array. Regards Alien.
bremen Posted April 20, 2016 Author Posted April 20, 2016 I am never going to send a null value. After I send my value from the array to field "905" I want to see if field "906" is null. If it is null I want to click a few buttons in the software and then go to the next row in the array.
alien4u Posted April 20, 2016 Posted April 20, 2016 Then what do you mean with this: ;;This is where I am having the issue. After the tab command is sent if the part number doesn’t exist and the rest of the script continues it will cause an error with the software it is interacting with. Regards Alien.
bremen Posted April 20, 2016 Author Posted April 20, 2016 (edited) In the software I when working with part numbers I have the option to create a new record or if I enter in a part number that is already in the system it will bring the details of that record into focus. If I enter a part number that the system does not recognize it will wait for me to give that number a description and create a new entry. There are no windows or alerts that pop up if the record is not in the system. Not all items in my array are in my database. Edited April 20, 2016 by bremen added more detail
alien4u Posted April 20, 2016 Posted April 20, 2016 Ohh I see, now I understand better, when your software wait for you give the new number a description nothing change? label? toolbox? dropdown menu? input field? nothing? Regards Alien.
bremen Posted April 20, 2016 Author Posted April 20, 2016 Nothing changes at all. It assumes that because you entered in an unknown number that you want to make a new record. My only other option is to send another key stroke that will cause a second window pop up and display a key value. If that key value = 0 then that can be a trigger, but then that gets into reading the value in that window, retaining that value so that you can close the window and keep working that the main window. Easiest thing is Send the part number Send "tab" keystroke Is the description field blank? Yes = clear form go to next row in array No = update record, clear form, next row in array
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