sriKnight Posted May 1, 2012 Share Posted May 1, 2012 How can I take a string from a specific field and compare it to data in an array? No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 What do you mean by "specific field"? An AutoIt variable? Or .... My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 (edited) In the software that I am navigating there is a control id that has a "lot number." I want to take the information in the box and compare it to a cell in an array. Edited May 1, 2012 by sriknight No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 Use function ControlGetText to retrieve the text of a control. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 I have that in my script. After I get the text how do i tell auto it "Hey, you just got the text from that field. Now, look at $aArray1[$c][0] and see if the information is a match. If that information does not match then close that window and pull up the next one (i already have those commands done). Once the new window is open look at that same field again and see if it matches $aArray1[$c][0]. Just do that until they match and when they do match carry out this set of commands. No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 $sControlText = ControlGetText(....) If $sControlText <> $aArray1[$c][0] Then ; Close the window and pull up the next one EndIf My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 WinActivate("CORRIDOR", "") send("{ALT}" & "T") send("{DOWN 3}") send("{ENTER}") WinWaitActive("Current Parts in Inventory Search", "") WinActivate("Current Parts in Inventory Search", "") ControlCommand("Current Parts in Inventory Search", "", "SysTabControl323", "TabRight", "") ControlSend("Current Parts in Inventory Search", "Lot number:", 1070, "980") send("{TAB}") ControlClick("Current Parts in Inventory Search", "Lot reference number:", 1300, "left") ControlClick("Current Parts in Inventory Search", "Less", 1947, "left") ControlClick("Current Parts in Inventory Search", "Scan", 1063, "left") sleep(700) ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") WinWaitActive("Edit Lot", "") WinActivate("Edit Lot", "") $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) if $sControlTextLT <> "LT12-00980.3" then do ControlClick("Edit Lot", "Close", "Button24", "left") ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") Until $sControlTextLT = "LT12-00980.3" Else ControlClick("Edit Lot", "Adjust quantity", "Button8", "left") EndIf That is my code as it stands right now. I dont have the array made yet. i am getting a syntax error. I am not a programer by any means so im not sure what the problem is let alone how to fix it. No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 Change$sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) if $sControlTextLT <> "LT12-00980.3" thento$sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) if $sControlTextLT <> "LT12-00980.3" then You access two different variables $sControlText and $sControlTextLT. Shouldn't they be the same? You have to put ControlgetText into your Do ... Until loop otherwise variable $sControlTextLT will never change My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 $sControlTextLT is actually a type o. WinActivate("CORRIDOR", "") send("{ALT}" & "T") send("{DOWN 3}") send("{ENTER}") WinWaitActive("Current Parts in Inventory Search", "") WinActivate("Current Parts in Inventory Search", "") ControlCommand("Current Parts in Inventory Search", "", "SysTabControl323", "TabRight", "") ControlSend("Current Parts in Inventory Search", "Lot number:", 1070, "980") send("{TAB}") ControlClick("Current Parts in Inventory Search", "Lot reference number:", 1300, "left") ControlClick("Current Parts in Inventory Search", "Less", 1947, "left") ControlClick("Current Parts in Inventory Search", "Scan", 1063, "left") sleep(700) ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") WinWaitActive("Edit Lot", "") WinActivate("Edit Lot", "") $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) if $sControlText <> "LT12-00980.3" then do ControlClick("Edit Lot", "Close", "Button24", "left") ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") until $sControlText = "LT12-00980.3" Else ControlClick("Edit Lot", "Adjust quantity", "Button8", "left") EndIf now the only error I get is with the "else" statement on line 47 No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 The syntax error has been resolved. The script will now start, but it does not do what its supposed to do when the it finds a match, No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 I have updated the script and it it now runs with out looping to infinity. expandcollapse popupWinActivate("CORRIDOR", "") send("{ALT}" & "T") send("{DOWN 3}") send("{ENTER}") WinWaitActive("Current Parts in Inventory Search", "") WinActivate("Current Parts in Inventory Search", "") ControlCommand("Current Parts in Inventory Search", "", "SysTabControl323", "TabRight", "") ControlSend("Current Parts in Inventory Search", "Lot number:", 1070, "980") send("{TAB}") ControlClick("Current Parts in Inventory Search", "Lot reference number:", 1300, "left") ControlClick("Current Parts in Inventory Search", "Less", 1947, "left") ControlClick("Current Parts in Inventory Search", "Scan", 1063, "left") sleep(700) ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") WinWaitActive("Edit Lot", "") WinActivate("Edit Lot", "") $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) if $sControlText <> "LT12-00980.1" then do ControlClick("Edit Lot", "Close", "Button24", "left") ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") WinWaitActive("Edit Lot", "") WinActivate("Edit Lot", "") until $sControlText <> "LT12-00980.1" Else EndIf ControlClick("Edit Lot", "Adjust quantity", "Button8", "left") If I can get this last issue worked out i think I'll be good on this one..... For my testing there are three lots that can be adjusted. LT12-00980, LT12-00980.2, LT12-00980.1 (this is the order that the GUI of the software lists these lots). If I edit the script to only look for LT12-00980 then the "do" statement does not run. and it adjusts the lot as expected. If I edit the script to look for LT12-00980.1 (the third lot displayed) the script will run, see that the first lot is not a match, and then open the next lot. this lot is LT12-00980.2 but the script will still try to adjust the lot instead of moving to the third lot. No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 I modified your script a bit. I changed "WinWaitActive" to "WinWait" so if the users gives focus to another window your script will still work. And I changed the Do Until loop. WinActivate("CORRIDOR", "") Send("{ALT}" & "T") Send("{DOWN 3}") Send("{ENTER}") WinWait("Current Parts in Inventory Search", "") WinActivate("Current Parts in Inventory Search", "") ControlCommand("Current Parts in Inventory Search", "", "SysTabControl323", "TabRight", "") ControlSend("Current Parts in Inventory Search", "Lot number:", 1070, "980") Send("{TAB}") ControlClick("Current Parts in Inventory Search", "Lot reference number:", 1300, "left") ControlClick("Current Parts in Inventory Search", "Less", 1947, "left") ControlClick("Current Parts in Inventory Search", "Scan", 1063, "left") Sleep(700) ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") Send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") WinWait("Edit Lot", "") WinActivate("Edit Lot", "") $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) While $sControlText <> "LT12-00980.3" ControlClick("Edit Lot", "Close", "Button24", "left") ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") Send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) WEnd ControlClick("Edit Lot", "Adjust quantity", "Button8", "left") My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 I used your modification and the script did not carry out the last action. It kept looping though. WinActivate("CORRIDOR", "") send("{ALT}" & "T") send("{DOWN 3}") send("{ENTER}") WinWaitActive("Current Parts in Inventory Search", "") WinActivate("Current Parts in Inventory Search", "") ControlCommand("Current Parts in Inventory Search", "", "SysTabControl323", "TabRight", "") ControlSend("Current Parts in Inventory Search", "Lot number:", 1070, "980") send("{TAB}") ControlClick("Current Parts in Inventory Search", "Lot reference number:", 1300, "left") ControlClick("Current Parts in Inventory Search", "Less", 1947, "left") ControlClick("Current Parts in Inventory Search", "Scan", 1063, "left") sleep(700) ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") WinWaitActive("Edit Lot", "") WinActivate("Edit Lot", "") $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) While $sControlText <> "LT12-00980.1" ControlClick("Edit Lot", "Close", "Button24", "left") ControlClick("Current Parts in Inventory Search", "", "SysListView322", "left") Send("{DOWN}") ControlClick("Current Parts in Inventory Search", "Open", 1663, "Left") $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) WEnd ControlClick("Edit Lot", "Adjust quantity", "Button8", "left") No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 I had to add another WinWaitActive before the $sControlText = ControlGetText("Edit Lot", "Lot number:", 1136) I am now in business. Thanks much for all of the help. No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 Glad we could help. It's quite hard to write a script for an application you can't test with. I would add one thing to your script: Error checking. After each function call you have to test if an error occurred. Else someone will call you and say "Your application doesn't work any longer" and "I didn't do anything!". So ControlSend("Current Parts in Inventory Search", "Lot number:", 1070, "980")should becomeControlSend("Current Parts in Inventory Search", "Lot number:", 1070, "980") If @error Then MsgBox(16, "Error Message", "Error returned by function ControlSend for 'Lot number:'. @error = " & @error) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 So here is what the script is for. I have to update information on these lots. I will be the only one that runs the script. If an error occurs at that spot I will have some more movements to make, but that isn't too difficult. Here is another question.... Based on a lot's attributes there might be an extra button on the edit page. Is there a way to kick off a set of instructions if a button exists? No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 You could use ControlGetPos for this button. If @error = 1 then the control could not be found. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Spiff59 Posted May 1, 2012 Share Posted May 1, 2012 (edited) Well, I started to write a reply to you (when this thread had zero replies), then I went to a long lunch. A lot has happened since! Your main flaw was pointed out, that your Do/Until loop would only be terminated when a variable was of a certain value, yet that variable was never modified within the loop. I started to throw something together, but as Water pointed out, it is difficult to do when one can't test the script. I do think it is more efficient, when referencing a window or control multiple times to get it's handle, rather than provide it's title each time. I was leaning toward doing it similar to this: Global $sCurrentParts = "Current Parts in Inventory Search" ; do what you need to do to get to Current Parts window here WinWaitActive($sCurrentParts) ; wait for CP window $iResult = Find_Lot("LT12-00980.3") ; search for lot number If $iResult = -1 Then MsgBox(0,"Lot Number Search", "Lot " & $sLot & " not found.") Else MsgBox(0,"Lot Number Search", "Lot " & $sLot & " found in row " & $iResult) EndIf Exit ;----------------------------------------------------------------------------------------------------------------------------------- Func Find_Lot($sLot) Local $hWin_CurrentParts = WinGetHandle($sCurrentParts) ; get CP window handle Local $hCtrl_ListView = ControlGetHandle($hWin_CurrentParts, "", "[NAME:SysListView322]") ; get LV handle Local $iLV_Count = ControlListView($hWin_CurrentParts, "", $hCtrl_ListView, "GetItemCount") ; get LV row count Local $hCtrl_OpenButton = ControlGetHandle($hWin_CurrentParts, "", "[ID:1663]") ; get Open button handle - not sure what AU3Info data to use For $x = 0 to $iLV_Count - 1 ; loop through LV rows, adjust end limit down by 1 since row numbers start at zero WinActivate($hWin_CurrentParts) WinWaitActive($hWin_CurrentParts) ControlListView($hWin_CurrentParts, "", $hCtrl_ListView, "Select", $x) ; select row $x ControlClick($hWin_CurrentParts, "", $hCtrl_OpenButton, "Left") ; click CP Open button WinWaitActive("Edit Lot") $sControlText = ControlGetText("Edit Lot", "", "[ID:1136]") ; get lot number from EL window - not sure what AU3Info data to use ControlClick("Edit Lot", "", "[NAME:Button24]", "Left") ; click EL Close button If $sControlText = $sLot Then Return $x ; lot found, return row number Next Return -1 ; lot not found, return -1 EndFunc Maybe you can steal some ideas out of it. Edit: PS - It would look better, and be easier to follow if you were more consistant in referencing the controls using the same type of data, rather than some by ID, some by NAME, some by CLASS, etc. Edited May 1, 2012 by Spiff59 Link to comment Share on other sites More sharing options...
sriKnight Posted May 1, 2012 Author Share Posted May 1, 2012 looking in the help it then builds that location in an array. All i need is if its there then <command> if not the <command>. No, I'm not a programer.Yes, I am a noob.You know what the difference is between you and me?I make this look good. Link to comment Share on other sites More sharing options...
water Posted May 1, 2012 Share Posted May 1, 2012 That's why I refer to @error and not the array returned. If @error is set then the control could not be found. And that's what you want to know, right? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - 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