Tasmania Posted September 25, 2007 Author Share Posted September 25, 2007 Adding in waits seems to fix sendtext. Is there anyone who knows why? I'm curious, I'm a programmer of many languages and I've never seen a language that has a specified window to place something and need it to be active anyway before. Link to comment Share on other sites More sharing options...
Tasmania Posted September 25, 2007 Author Share Posted September 25, 2007 (edited) For some reason, I'm still getting unreliable performance from this command. Anyone have any ideas? I will post my entire code below, if it allows me to post that long! By unreliable, sometimes it will change from lowercase to uppercase in the middle of a string or have similar effects to that. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form=c:\documents and settings\uspjefe\desktop\projects\frmquestions.kxf $frmCInfo = GUICreate("Syte Line Automation", 419, 314, -1, -1) $grpInfo = GUICtrlCreateGroup(" Information ", 0, 0, 417, 241) $lblAttn = GUICtrlCreateLabel("&Attn:", 8, 17, 32, 17) $txtAttn = GUICtrlCreateInput("", 96, 17, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblEmail = GUICtrlCreateLabel("&Email:", 8, 41, 38, 17) $txtEmail = GUICtrlCreateInput("", 96, 41, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblPwo = GUICtrlCreateLabel("&PWO #:", 8, 65, 49, 17) $txtPwo = GUICtrlCreateInput("", 96, 65, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblInum = GUICtrlCreateLabel("Full &Item Num:", 8, 89, 77, 17) $txtInum = GUICtrlCreateInput("", 96, 89, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblSca = GUICtrlCreateLabel("&SCA # (No 0):", 8, 113, 76, 17) $txtSca = GUICtrlCreateInput("", 96, 113, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) GUICtrlSetLimit(-1, 7) $lblDesc = GUICtrlCreateLabel("&Description:", 8, 137, 66, 17) $txtDesc = GUICtrlCreateInput("", 96, 137, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) GUICtrlSetLimit(-1, 40) $lblRstdate = GUICtrlCreateLabel("&Request Date:", 8, 161, 79, 17) $dteRstdate = GUICtrlCreateDate("", 96, 161, 105, 21, $WS_TABSTOP) $lblType = GUICtrlCreateLabel("T&ype:", 8, 184, 37, 17) $cmbType = GUICtrlCreateCombo("CONCEPT", 96, 184, 105, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$CBS_UPPERCASE)) GUICtrlSetData(-1, "RECONCEPT|SAMPLE|RESAMPLE|ADDL SMPL|HEAT SEAL TOOL|BLISTR FRM TOOL") $lblProdCode = GUICtrlCreateLabel("Produc&t Code:", 8, 208, 78, 17) $cmbPcode = GUICtrlCreateCombo("SAM-CONCPT", 96, 208, 105, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$CBS_UPPERCASE)) GUICtrlSetData(-1, "SAM-SAMPL|SAM-ADDL|MAH-FAC|MAH-FAM|BFT-VAC|BFT-PRESS") $lblPO = GUICtrlCreateLabel("P&O Number:", 216, 17, 68, 17) $txtPO = GUICtrlCreateInput("N/C", 304, 17, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblPOamt = GUICtrlCreateLabel("PO A&mount:", 216, 41, 67, 17) $txtPOamt = GUICtrlCreateInput("0", 304, 41, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblPOdiscount = GUICtrlCreateLabel("PO Disco&unt:", 216, 64, 73, 17) $txtPOdiscount = GUICtrlCreateInput("", 304, 64, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblPE = GUICtrlCreateLabel("Projec&t Enj:", 216, 89, 64, 17) $txtPE = GUICtrlCreateInput("", 304, 89, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblPM = GUICtrlCreateLabel("Project &Mngr:", 216, 113, 73, 17) $txtPM = GUICtrlCreateInput("", 304, 113, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblCharge = GUICtrlCreateLabel("&Charge:", 216, 137, 47, 17) $txtCharge = GUICtrlCreateInput("", 304, 137, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblQty = GUICtrlCreateLabel("Quantit&y:", 216, 160, 52, 17) $txtQty = GUICtrlCreateInput("1.00", 304, 160, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) $lblMaterial = GUICtrlCreateLabel("Materia&l:", 216, 184, 50, 17) $txtMaterial = GUICtrlCreateInput("", 304, 184, 105, 21) $lblGauge = GUICtrlCreateLabel("&Gauge:", 216, 208, 45, 17) $txtGauge = GUICtrlCreateInput("", 304, 208, 105, 21, BitOR($ES_UPPERCASE,$ES_AUTOHSCROLL)) GUICtrlCreateGroup("", -99, -99, 1, 1) $lblExNotes = GUICtrlCreateLabel("Extra &Notes:", 8, 248, 68, 17) $edtExNotes = GUICtrlCreateEdit("", 80, 248, 241, 57, BitOR($ES_UPPERCASE,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, "") $btnContinue = GUICtrlCreateButton("Contin&ue", 336, 248, 75, 25, 0) $btnExit = GUICtrlCreateButton("E&xit", 336, 280, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; ********** Variables that are needed to start ********** $displayed = 0 $readonly = 0 ; ********** End variables that are needed to start ********** While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE; Exit icon - upper right Exit Case $btnExit Exit Case $btnContinue GUISetState(@SW_HIDE) ExitLoop Case Not $txtInum If StringLen(GUICtrlRead($txtInum)) > 0 And $displayed <= 2 Then If StringInStr(GUICtrlRead($txtInum), "SAMPLE") Then GUICtrlSetData($cmbType, "SAMPLE") GUICtrlSetData($cmbPcode, "SAM-SAMPL") $displayed += 1 ElseIf StringInStr(GUICtrlRead($txtInum), "ADDSAM") Then GUICtrlSetData($cmbType, "ADDL SAMPL") GUICtrlSetData($cmbPcode, "SAM-ADDL") $displayed += 1 ElseIf StringInStr(GUICtrlRead($txtInum), "CONCEPT") Then GUICtrlSetData($cmbType, "CONCEPT") GUICtrlSetData($cmbPcode, "SAM-CONCPT") $displayed += 1 ElseIf StringInStr(GUICtrlRead($txtInum), "H") Then GUICtrlSetData($cmbType, "HEAT SEAL TOOL") GUICtrlSetData($cmbPcode, "MAH-FAC") $displayed += 1 ElseIf StringInStr(GUICtrlRead($txtInum), "FORMTOOL") Then GUICtrlSetData($cmbType, "BLISTER FORM TOOL") GUICtrlSetData($cmbPcode, "BFT-VAC") $displayed += 1 EndIf ElseIf StringLen(GUICtrlRead($txtInum)) = 0 And $displayed <= 3 Then $displayed = 0 EndIf EndSwitch WEnd ; ********** Variables that will NOT be changed ********** $attn = StringUpper(GUICtrlRead($txtAttn)) $email = StringUpper(GUICtrlRead($txtEmail)) $pwo = StringUpper(GUICtrlRead($txtPwo)) $inum = StringUpper(GUICtrlRead($txtInum)) $sca = StringUpper(GUICtrlRead($txtSca)) $date = GUICtrlRead($dteRstdate) $newdate = StringSplit($date, "/") If StringLen($newdate[2]) < 2 Then $day = "0" & $newdate[2] Else $day = $newdate[2] EndIf If StringLen($newdate[1]) < 2 Then $mon = "0" & $newdate[1] Else $mon = $newdate[1] EndIf $yr = StringRight($newdate[3], 2) $date = $mon & "/" & $day & "/" & $yr $type = StringUpper(GUICtrlRead($cmbType)) $pcode = StringUpper(GUICtrlRead($cmbPcode)) $po = StringUpper(GUICtrlRead($txtPO)) $poamt = StringUpper(GUICtrlRead($txtPOamt)) $podisc = StringUpper(GUICtrlRead($txtPOdiscount)) $pe = StringUpper(GUICtrlRead($txtPE)) $pm = StringUpper(GUICtrlRead($txtPM)) $charge = StringUpper(GUICtrlRead($txtCharge)) $desc = StringUpper(GUICtrlRead($txtDesc)) $exnotes = StringUpper(GUICtrlRead($edtExNotes)) $qty = StringUpper(GUICtrlRead($txtQty)) $gauge = StringUpper(GUICtrlRead($txtGauge)) $material = StringUpper(GUICtrlRead($txtMaterial)) ; Default location is going to be bft $loc = "bft" $newitem = 0 ; ********** End variables that will NOT be change ********** ; First thing we need to do is to see if we can find main menu for Syte Line If WinExists("Main Menu - dekb") Then WinActivate("Main Menu - dekb"); Maximize the dekalb blister site ElseIf WinExists("Main Menu - bft") Then WinActivate("Main Menu - bft"); Maximize the blister form tools site ElseIf WinExists("Main Menu - dekm") Then WinActivate("Main Menu - dekm"); Maximize the dekalb machenery site Else Run("P:\dlc91c\bin\prowin32.exe -basekey INI -ininame p:\syteline6\symix.ini -pf p:\syteline.prd\dekbrun.pf -p menu\symix.p") WinWaitActive("ERP 6.01.00") Send("{SPACE}") WinWaitActive("Main Menu - dekb") EndIf If $type = "HEAT SEAL TOOL" Then If Not WinActive("Main Menu - dekm") Then Send("!fw") WinWaitActive("Select a Site/Entity") Send("dekm{ENTER}{ENTER}") WinWaitActive("Main Menu - dekm") $loc = "dekm" EndIf ElseIf Not WinActive("Main Menu - bft") Then Send("!fw") ; Wait until the select a site is active WinWaitActive("Select a Site/Entity") ; Go to blister form tools Send("BFT{ENTER}{ENTER}") ; Wait until the main menu loads WinWaitActive("Main Menu - bft") $loc = "bft" EndIf ; Now activate the customer order entry window WinMenuSelectItem("Main Menu - ", "", "&Customer", "&Customer Service", "&Order Maintenance") ; Wait for the window to become active WinWaitActive("Order Maintenance - ") ; Select a new entry WinMenuSelectItem("Order Maintenance - ", "", "&Edit", "N&ew") WinWaitActive("Order Maintenance") ; Figure out if there is a PO or Not If $po Not = "" Then ControlSend("Order Maintenance - ", "", "[ID:56]", $po) Else MsgBox(0, "Error", "You did not enter anything in the PO text box. Stopping script.") Exit EndIf ; Now have the user enter in the customer MsgBox(0, "Notice", "Please select the customer and the address and enter the shipping and contact information.") ControlClick("Order Maintenance - ", "", "[ID:76]") ControlFocus("Select A Customer", "", "[ID:182]") ; Wait for them to Continue WinWaitActive("Order Line Maintenance - ") Send("!d") ; Select a new entry WinMenuSelectItem("Order Line Maintenance - ", "", "&Edit", "N&ew") WinWaitActive("Order Line Maintenance") ; Once at the new entry enter in the item description ControlSend("Order Line Maintenance - ", "", "[ID:369]", $inum) Send("{TAB}") WinWaitActive("Validate", "", 2) If WinActive("Validate") Then Send("{SPACE}") $compname = InputBox("Company Name", "Please enter the company name:", "", " M", 190, 115) $newitem = 1 WinWaitClose("Company Name") WinMenuSelectItem("Main Menu - ", "", "&Material", "&Inventory", "&Item Maintenance") WinWaitActive("Item Maintenance - ") ControlClick("Item Maintenance - ", "", "[ID:618]") WinMenuSelectItem("Item Maintenance - ", "", "&Edit", "N&ew") WinWaitActive("Item Maintenance") ControlSend("Item Maintenance", "", "[ID:512]", $inum) ControlSend("Item Maintenance", "", "[ID:514]", $compname & "-" & $desc, 1) ControlSend("Item Maintenance", "", "[ID:520]", "EA") ControlSend("Item Maintenance", "", "[ID:554]", $pcode) ControlClick("Item Maintenance", "", "[ID:622]") ControlSend("Item Maintenance", "", "[ID:664]", $pe) ControlSend("Item Maintenance", "", "[ID:666]", $pm) ControlSend("Item Maintenance", "", "[ID:668]", $pwo) WinMenuSelectItem("Item Maintenance - ", "", "&Edit", "&Save") WinClose("Item Maintenance - ") If Not WinActive("Order Line Maintenance - ") Then WinActivate("Order Line Maintenance - ") EndIf EndIf WinWaitActive("Information", "", 2) ControlClick("Information", "", "[ID:2]") If $qty > 1 Then ControlSend("Order Line Maintenance - ", "", "[ID:370]", $qty) EndIf ControlSend("Order Line Maintenance - ", "", "[ID:371]", $charge) ControlSend("Order Line Maintenance - ", "", "[ID:372]", $date) ControlClick("Order Line Maintenance - ", "", "[ID:374]") Send("{END}{ENTER}{ENTER}") If StringLen($exnotes) > 1 Then $exnotesyes = 1 Else $exnotesyes = 0 EndIf WinWaitActive("Order Line Maintenance - " & $loc & " - Notes") Switch $type Case "CONCEPT" Or "RECONCEPT" $send = "DESC: " & $desc & "{ENTER}{ENTER}" & $type & "{ENTER}{ENTER}SEE ATTACHED PWO/EMAIL{ENTER}{ENTER}" $send &= "SHIP VIA EMAIL CONCEPT PROJECT TO:{ENTER}" & $attn & "{ENTER}" & $email If $exnotesyes Then $send &= "{ENTER}{ENTER}" & $exnotes EndIf Send($send & "{TAB 2}{SPACE}") Case "SAMPLE" Or "RESAMPLE" $send = "DESC: " & $desc & "{ENTER}{ENTER}" & $type & "{ENTER}{ENTER}SEE ATTACHED PWO/EMAIL{ENTER}{ENTER}" $send &= "SHIP TO ATTN:{ENTER}" & $attn If $exnotesyes Then $send &= "{ENTER}{ENTER}" & $exnotes EndIf Send($send & "{TAB 2}{SPACE}") Case "ADDL SAMPL" $send = $qty & " ADDITIONAL SAMPLES{ENTER}{ENTER}DESC: " & $desc & "{ENTER}{ENTER}GAUGE/MATERIAL: " & $gauge & "/" & $material $send &= "{ENTER}{ENTER}SEE ATTACHED FORM/EMAIL{ENTER}{ENTER}SHIP TO ATTN:{ENTER}" & $attn If $exnotesyes Then $send &= "{ENTER}{ENTER}" & $exnotes EndIf Send($send & "{TAB 2}{SPACE}") Case "BLISTER FORM TOOL" Or "HEAT SINK TOOL" If $exnotesyes Then Send($send & "{TAB 2}{SPACE}") Else MsgBox(64, "Message", "You did not enter in any extra notes and this is a Blister Form Tool or Heat Sink Tool. Enter in the notes now.") EndIf Case Default MsgBox(64, "Message", "Unknown entry for 'Notes.' Please enter in notes now.") WinWaitClose("Order Line Maintenance - " & $loc & " - Notes") EndSwitch WinWaitActive("Order Line Maintenance - ") ControlSend("Order Line Maintenance - ", "", "[ID:376]", "EA") ControlSend("Order Line Maintenance - ", "", "[ID:406]", $desc, 1) Send("{TAB}") WinWaitActive("Validate", "OK", 1) If WinActive("Validate", "OK") Then ControlClick("Validate", "", "[ID:2]") EndIf WinWaitActive("Question", "OK", 1) If WinActive("Question", "OK") Then ControlClick("Question", "", "[ID:1]") EndIf If $po = "N/C" Then ControlSend("Order Line Maintenance - ", "", "[ID:439]", "100") Else ControlSend("Order Line Maintenance - ", "", "[ID:439]", $podisc) EndIf WinMenuSelectItem("Order Line Maintenance - ", "", "&Edit", "&Save") WinWaitActive("Warning", "OK", 1) If WinActive("Warning", "OK") Then MsgBox(48, "Error", "Credit hold. Unable to continue.") Exit EndIf WinMenuSelectItem("Order Line Maintenance - ", "", "&Reports", "&Order Reports", "Order &Verification") WinWaitActive("Order Verification - ") WinMenuSelectItem("Order Verification - ", "", "&Edit", "&Print") WinWaitActive("Success", "OK", 5) ControlClick("Success", "", "[ID:2]") WinMenuSelectItem("Order Verification - ", "", "&Edit", "&Update") WinWaitActive("Order Verification - ") ControlSend("Order Verification - ", "", "[ID:1606]", "F") ControlSend("Order Verification - ", "", "[ID:1607]", "C:\SYMWORK\" & $sca & ".DOC") Send("{F2}") WinMenuSelectItem("Order Verification - ", "", "&Edit", "&Print") WinWaitActive("Success", "OK", 5) ControlClick("Success", "", "[ID:2]") WinClose("Order Verification - ") ControlClick("Order Line Maintenance - ", "", "[ID:412]") WinWaitActive("Question", "OK", 3) ControlClick("Question", "", "[ID:1]") ControlClick("Order Line Maintenance - ", "", "[ID:412]") WinWaitActive("Job Orders - ") WinMenuSelectItem("Job Orders - ", "", "&Activities", "&Copy Routing/BOM") WinWaitActive("Job Orders - ") If $type = "CONCEPT" Or $type = "RECONCEPT" Then ControlSend("Copy Routing/BOM - ", "", "[ID:1071]", "CONCEPT ROUTING TEMPLATE") ElseIf $type = "SAMPLE" Or $type = "RESAMPLE" Then ControlSend("Copy Routing/BOM - ", "", "[ID:1071]", "SAMPLE ROUTING TEMPLATE") ElseIf $type = "ADDITIONAL SAMPLES" Then ControlSend("Copy Routing/BOM - ", "", "[ID:1071]", "ADDL SAMPLE ROUTING TEMPLATE") ElseIf $type = "HEAT SEAL TOOL" Then ControlSend("Copy Routing/BOM - ", "", "[ID:1071]", "HSTBOM") ElseIf $type = "BLISTER FORM TOOL" Then ControlSend("Copy Routing/BOM - ", "", "[ID:1071]", "FORM TOOL ROUTING TEMPLATE") EndIf If $type = "HEAT SEAL TOOL" Then ControlClick("Copy Routing/BOM - ", "", "[ID:1105]") WinWaitActive("Information", 5) Send("{SPACE}{SPACE}") Else WinWaitActive("Copy Routing/BOM - ") ControlSend("Copy Routing/BOM - ", "", "[ID:1079]", "Y") Send("{TAB}") ControlClick("Copy Routing/BOM - ", "", "[ID:1105]") WinWaitActive("Information", 5) Send("{SPACE}{SPACE}") EndIf WinClose("Copy Routing/BOM - ") ControlClick("Job Orders - ", "", "[ID:967]") WinWaitActive("Information", "PDM Information Sent", 5) ControlClick("Information", "", "[ID:2]") WinMenuSelectItem("Job Orders - ", "", "&Reports", "&Job Paperwork") WinWaitActive("Job Paperwork - ") WinMenuSelectItem("Job Paperwork - ", "", "&Edit", "&Update") WinWaitActive("Job Paperwork - ") ControlSend("Job Paperwork - ", "", "[ID:1688]", "Y") ControlSend("Job Paperwork - ", "", "[ID:1691]", "A") ControlSend("Job Paperwork - ", "", "[ID:1694]", "N") ControlSend("Job Paperwork - ", "", "[ID:1700]", "N") Send("{F2}") WinMenuSelectItem("Job Paperwork - ", "", "&Edit", "&Print") WinWaitActive("Success") ControlClick("Success", "", "[ID:2]") WinActivate("Job Paperwork - ") WinMenuSelectItem("Job Paperwork - ", "", "&Edit", "&Update") WinWaitActive("Job Paperwork - ") ControlSend("Job Paperwork - ", "", "[ID:1688]", "N") Send("{F2}") WinMenuSelectItem("Job Paperwork - ", "", "&Edit", "&Print") WinWaitActive("Success") ControlClick("Success", "", "[ID:2]") WinClose("Job Paperwork - ") WinClose("Job Orders - ") WinClose("Order Line Maintenance - ") WinClose("Order Maintenance - ") Sleep(1000) $boxlbl = MsgBox(36, "Box Label", "Do you need to create a box label?") If $boxlbl = 6 Then MsgBox(48, "Excel", "Please ensure that Microsoft Excel is in your task bar.") If WinExists("Microsoft Excel - BOX LABEL MAKER") Then WinMinimizeAll() $salesperson = InputBox("Salesperson", "Please enter the salesperson:", "", " M", 190, 115) If $newitem = 0 Then $compname = InputBox("Company Name", "Please enter the company name:", "", " M", 190, 115) EndIf $sca = GUICtrlRead($txtSca) $pwo = GUICtrlRead($txtPwo) $desc = GUICtrlRead($txtDesc) WinActivate("Microsoft Excel - BOX LABEL MAKER") WinSetState("Microsoft Excel - BOX LABEL MAKER", "", @SW_RESTORE) If Not WinActive("Microsoft Excel - BOX LABEL MAKER") Then MsgBox(16, "Error", "'Microsoft Excel - BOX LABEL MAKER' was not found. Exiting.") Exit EndIf Sleep(1250) Send("^g") WinWaitActive("Go To") Send("H1{ENTER}") Send($sca & "{ENTER}") Send("^g") WinWaitActive("Go To") Send("H2{ENTER}") Send($pwo & "{ENTER}") Send("^g") WinWaitActive("Go To") Send("H3{ENTER}") Send($compname & "{ENTER}") Send("^g") WinWaitActive("Go To") Send("H4{ENTER}") Send($desc & "{ENTER}") Send("^g") WinWaitActive("Go To") Send("H5{ENTER}") Send($salesperson & "{ENTER}") Send("^p") Sleep(1000) Send("{ENTER}") EndIf EndIf Sleep(1000) WinMinimizeAll() Edited September 25, 2007 by Tasmania Link to comment Share on other sites More sharing options...
enaiman Posted September 26, 2007 Share Posted September 26, 2007 I'm using myself ControlSend alot - sometimes I use it to send passwords (and I do have uppercase letters and symbols in it) - setting the flag to 1 (send raw keys) works everytime. robertocm 1 SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) 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