Sign in to follow this  
Followers 0
Tasmania

Capslock and ControlSend

23 posts in this topic

This may sound simple, however after about an hour and fifteen minutes of playing around, I still have yet to figure a nice way for this to work.

My script is entering data based off of gui input into a program called Syte Line, and the most reliable way to input the data is known to be Control Send, however ControlSend is sending the application the data in lower-case format, even if the variable containing the string is capitalized with StringUpper. When I run the ControlSend with {CAPSLOCK} in front, it turns numbers into symbols. Any idea's?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have tried SetText(), multiple times, however to no luck as it does not enter anything in the field at all.

Edited by Tasmania

Share this post


Link to post
Share on other sites

I have even attempted to enter the string that contains numbers as RAW and it still outputs symbols.

Share this post


Link to post
Share on other sites

From AutoIT Help file under ControlSend

Remarks

ControlSend works in a similar way to Send but it can send key strokes directly to a window/control, rather than just to the active window.

ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send - and yes it does send shift, ctrl, alt etc.

As mention in the Send help the keyboard that send different chars when in CAPS LOCK and using the Shift Key cannot be simulated. An example is the Czech Keyboard. A good workaround is to use the ControlSetText.

The control might first need to be given focus with the ControlFocus command, specially when referencing an controlID created by the script itself.

Opt("SendKeyDelay",...) alters the the length of the brief pause in between sent keystrokes.

Opt("SendKeyDownDelay",...) alters the length of time a key is held down before being released during a keystroke.


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

Well, I can't use SetText for some reason, because it's not setting the text for the input box. I have tried to give the box focus and then set the text, and it is still not working.

Share this post


Link to post
Share on other sites

StringUpper does not work when set in variables or when set when using the ControlSend function, it still displays characters in lower-case.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

#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", 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 = GUICtrlRead($txtAttn)
$email = GUICtrlRead($txtEmail)
$pwo = GUICtrlRead($txtPwo)
$inum = GUICtrlRead($txtInum)
$sca = GUICtrlRead($txtSca)
$date = GUICtrlRead($dteRstdate)
$newdate = StringSplit($date, "/")
$yr = StringRight($newdate[3], 2)
$date = $newdate[1] & "/" & $newdate[2] & "/" & $yr
$type = GUICtrlRead($cmbType)
$pcode = GUICtrlRead($cmbPcode)
$po = GUICtrlRead($txtPO)
$poamt = GUICtrlRead($txtPOamt)
$podisc = GUICtrlRead($txtPOdiscount)
$pe = GUICtrlRead($txtPE)
$pm = GUICtrlRead($txtPM)
$charge = GUICtrlRead($txtCharge)
$desc = GUICtrlRead($txtDesc)
$exnotes = GUICtrlRead($edtExNotes)
$qty = GUICtrlRead($txtQty)
$gauge = GUICtrlRead($txtGauge)
$material = 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")

; Figure out if there is a PO or Not
If $po Not = "" Then
    ControlSend("Order Maintenance - bft", "", "[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.")

; Wait for them to Continue
WinWaitActive("Order Line Maintenance - ")

Send("!d")

; Select a new entry
WinMenuSelectItem("Order Line Maintenance - ", "", "&Edit", "N&ew")

; 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")
    
    ControlSend("Item Maintenance", "", "[ID:512]", $inum)
    
    ControlSend("Item Maintenance", "", "[ID:514]", $compname & "-" & $desc)
    
    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

This is how my code looks right now... or well a small part of my code...

Edited by Tasmania

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I'm not using Send, I'm using ControlSend, and when I program it I do it as such:

; $po contains N/C at this point, inside of the variable it (itself) is in caps
ControlSend("Order Maintenance - bft", "", "[ID:56]", StringUpper($po))
Edited by Tasmania

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

I did, the result is the same.

Share this post


Link to post
Share on other sites

I'm attaching some pictures of what I am speaking of to assist.

Share this post


Link to post
Share on other sites

Even when I enter in "037037CONCPET" in the send to control, without a variable, it sends symbols.

Share this post


Link to post
Share on other sites

Same result. I just wrote a very small autoit for notepad to attempt the same things as I am here, however I have been unable to reproduce this as of yet. Possibly this has something to do with my code as you see it right now?

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Still having the same issue, however I have noticed that I can't use SetText after using WinMenuSelectItem for some reason... even if I do the Alt keys, set-text doesn't work. Why?

Edit: However if I don't go through the menu, it works just fine.

Edited by Tasmania

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

New interesting thing:

If you view my original code, and now view this code section, you will notice that two things have flipped. For some reason, settext works now that the code is flipped.

; Select a new entry
WinMenuSelectItem("Order Maintenance - ", "", "&Edit", "N&ew")

; 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.")

WinWaitClose("Notice")

; Figure out if there is a PO or Not
If $po Not = "" Then
    ControlSetText("Order Maintenance - ", "", "[ID:56]", $po)
Else
    MsgBox(0, "Error", "You did not enter anything in the PO text box. Stopping script.")
    Exit
EndIfoÝ÷ ØKÞj+z)íz·¬¶)àËajØ!ùb¦Ø^r^j¢»­¦ëb¬Ø­Â䱫­¢+ØìM±Ð¹Ü¹ÑÉä)]¥¹5¹ÕM±Ñ%Ñ´ ÅÕ½Ðí=ÉÈ5¥¹Ñ¹¹´ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìµÀí¥ÐÅÕ½Ðì°ÅÕ½Ðí8µÀíÜÅÕ½Ðì¤()]¥¹]¥ÑÑ¥Ù ÅÕ½Ðí=ÉÈ5¥¹Ñ¹¹´ÅÕ½Ðì¤((ì¥ÕɽÕХѡɥÌA
Edited by Tasmania

Share this post


Link to post
Share on other sites

It appears as though for set-text I need to wait for the window to become active before it runs settext? Is this true?

Share this post


Link to post
Share on other sites

SetText displays the text, however it's not actually there, it only appears to be there. If I click in the text box and hit space or anything except left or right arrows, it turns itself blank. This I feel is part of the application I'm running. Back to the drawing board...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0