Jump to content
Sign in to follow this  
t0ddie

controlsend not sending uppercase?

Recommended Posts

i am using controlsend to send text to a command prompt.

i type uppercase letters, but they are shown lowercase in the prompt.

and of course i tried +t+h+i+s

and i got t=h=i=s

is there a workaround? i havent tried shiftdown... but preferably without simulating holding down shift is there a way to do this?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

i am using controlsend to send text to a command prompt.

i type uppercase letters, but they are shown lowercase in the prompt.

and of course i tried +t+h+i+s

and i got t=h=i=s

is there a workaround? i havent tried shiftdown... but preferably without simulating holding down shift is there a way to do this?

<{POST_SNAPBACK}>

ControlSend does not send any character produced with the SHIFT key.

Search the forum for +ControlSendPlus +pekster, or HERE. But, I just tried to download it from the ftp link on that post, and could not get past the log-on even though the password is posted. Perhaps a PM is in order.

If you cannot find the UDF, I could post it since its legal notice says it can be distributed. The version I have is 2.0.3 (06/13/2004).


Phillip

Share this post


Link to post
Share on other sites

I'll post it since I found it already posted.

#include-once
Func ControlSendPlus($title, $text, $className, $string, $flag)
;VERSION 2.0.3 (06/13/2004)
    Local $ctrl = 0, $alt = 0, $upper, $start, $end, $i, $char, $and, $Chr5Index, $isUpper, $ret
    If $flag = 2 Or $flag = 3 Then $ctrl = 1
    If $flag = 2 Or $flag = 4 Then $alt = 1
    If $flag <> 1 Then $flag = 0;set the flag to the default function style
    $upper = StringSplit('~!@#$%^&*()_+|{}:"<>?ABCDEFGHIJKLMNOPQRSTUVWXYZ', "")
    
    If $flag <> 1 Then;don't replace special chars if it's raw mode
    ;replace {{} and {}} with +[ and +] so they will be displayed properly
        $string = StringReplace($string, "{{}", "+[")
        $string = StringReplace($string, "{}}", "+]")
    ;replace all special chars with Chr(5)
    ;add the special char to an array.  each Chr(5) corresponds with an element
        Local $Chr5[StringLen($string) / 2 + 1]
        For $i = 1 To StringLen($string)
            $start = StringInStr($string, "{")
            If $start = 0 Then ExitLoop;no more open braces, so no more special chars
            $end = StringInStr($string, "}")
            If $end = 0 Then ExitLoop;no more close braces, so no more special chars
        ;parse inside of braces:
            $Chr5[$i] = StringMid($string, $start, $end - $start + 1)
        ;replace with Chr(5) leaving the rest of the string:
            $string = StringMid($string, 1, $start - 1) & Chr(5) & _
                    StringMid($string, $end + 1, StringLen($string))
        Next
    ;take out any "!", "^", or "+" characters
    ;add them to the $Modifiers array to be used durring key sending
        Local $Modifiers[StringLen($string) + 1]
        For $i = 1 To StringLen($string)
            $char = StringMid($string, $i, 1)
            $and = 0
            If $char = "+" Then
                $and = 1
            ElseIf $char = "^" Then
                $and = 2
            ElseIf $char = "!" Then
                $and = 4
            ElseIf $char = "" Then
                ExitLoop
            EndIf
            If $and <> 0 Then
                $Modifiers[$i] = BitOR($Modifiers[$i], $and)
                $string = StringMid($string, 1, $i - 1) & _
                        StringMid($string, $i + 1, StringLen($string))
                $i = $i - 1
            EndIf
        Next
    Else;it is raw mode, so set up an all-0 modifier array
        Local $Modifiers[StringLen($string) + 1]
    EndIf
    
;now send the chars
    $Chr5Index = 1
    For $i = 1 To StringLen($string)
        $char = StringMid($string, $i, 1)
        If $char = Chr(5) Then
            $char = $Chr5[$Chr5Index]
            $Chr5Index = $Chr5Index + 1
        EndIf
        $isUpper = 0
        For $j = 1 To UBound($upper) - 1
            If $char == $upper[$j] Then $isUpper = 1
        Next
    ;1 SHIFT, 2 CTRL, 4 ALT (programmer note to keep the bits straight)
        If $isUpper = 1 Or BitAND($Modifiers[$i], 1) = 1 Then Send("{SHIFTDOWN}")
        If BitAND($Modifiers[$i], 4) = 4 And Not $alt Then $char = "!" & $char
        If BitAND($Modifiers[$i], 2) = 2 And Not $ctrl Then $char = "^" & $char
        If BitAND($Modifiers[$i], 4) = 4 And $alt Then Send("{ALTDOWN}")
        If BitAND($Modifiers[$i], 2) = 2 And $ctrl Then Send("{CTRLDOWN}")
        $ret = ControlSend($title, $text, $className, $char, $flag)
        If BitAND($Modifiers[$i], 4) = 4 And $alt Then Send("{ALTUP}")
        If BitAND($Modifiers[$i], 2) = 2 And $ctrl Then Send("{CTRLUP}")
        If $isUpper = 1 Or BitAND($Modifiers[$i], 1) = 1 Then Send("{SHIFTUP}")
        If Not $ret Then Return 0;window or control not found
    Next
    Return 1
EndFunc  ;==>ControlSendPlus

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I'll post it since I found it already posted.

<{POST_SNAPBACK}>

And here's the readme that goes along with the ContronSendPlus UDF:

ControlSendPlus UDF created by "pekster"

Version: 2.03 (created 06/13/2004 mm/dd/yyyy)

SHORT DESCRIPTION: This function is designed to replace the built-in ControlSend

  function. It will correctly handle the shift state (using the global state to

  send the required keys) as well as the control and alt key modifiers.

USAGE: ControlSendPlus("title", "text", "classnameNN", "string", flag)

  The first 4 text parameters are identical to the ControlSend function.

  The 'flag' parameter is a bit different. Consult the table below. Note that in

    all of these modes the global shift state is used to properly send

    characters.

    0 - Default behavior. Special characters like {ENTER} and {UP} are sent to

      the control. The '!', '^', and '+' are alt, control, and shift

      accordingly. All modifier keys are sent LOCALLY.

    1 - Raw mode. Keys are sent as they appear in the "string" parameter.

    2 - Global mode. Identical to mode 0, but the control and alt keystrokes are

      sent globally. See NOTE 1 below.

    3 - Global Ctrl mode.  Identical to mode 0, but control keystrokes are sent

      globally (alt keystrokes are local.) See NOTE 1 below.

    4 - Global Alt mode.  Identical to mode 0, but alt keystrokes are sent

      globally (control keystrokes are local.) See NOTE 1 below.

RETURN: As of version 2.0.3, this function has the same return as ControlSend.

  Success returns 1, and a failure to find the window or control returns 0. A

  failure is any failure to send any characters, so it is possible for some of

  the characters to get sent, and then the rest fail if the window closes

  during the send process.

KEYBOARD LAYOUTS: This function was designed to be used with the standard QWERTY

  US keyboard layout. If you have a different layout, you may need to change the

  function to properly detect characters that require a shift modifier. To do

  this, you will need to edit the string on line 7 between the single quotes.

  Place each character that requires a shift right after one-another. No further

  changes are required. Don't for get capital letters as well as your symbols!

BRACES ISSUE: This is not a bug, since I designed my function to imitate the

  ControlSend function as much as I could. The issue appears when you enter

  a string such as "{I ACTUALLY WANT BRACES}" with a flag other than 1. The

  proper methods of doing this are to use raw mode, or use the "{{}" and "{}}"

  special characters. However, it may appear as if sections of your string were

  ignored by my function. If this occurs, check your use of braces.

  You can also get strange outputs when you don't match braces, the exception

  being the "{{}" and "{}}" uses. If you need to do this, use flag 1.

NOTE 1: Some applications will not properly use the local alt and/ or control

  keystroke. This is why the additional 3 flags were added. To discover the

  proper flag to use for you particular application, you will have to try out

  the different flags. Sometimes both local and global mode work, and other

  times only one will.

LIMITATIONS: The current version observes the following limitations:

  * You cannot send Chr(5) since this character is use internally by the function

    to denote replaced characters. Attempts to do so could result in an error,

    or unexpected results.

  * The windows key "#" is not supported. In my testing, I was not able to use

    this key properly with my function or the ControlSend function, so I removed

    support for it. If you can give me an example where ControlSend can handle

    it, please email me so that I can release a new version with proper windows

    key support

CONTACT: If you have a suggestion, bug report, or otherwise have a need to

  contact me, You may use the information below. If you find a bug, please

  tell me what text you used as the string parameter, what flag you used, and

  the incorrect output that was returned. It also helps if you list your version

  of the function.

    E-mail: pekster@mail-page.com (preferred method)

    user "pekster" on the HiddenSoft forums at www.hiddensoft.com

ACKNOWLEDGEMENTS: Thanks to all the users on the HiddenSoft forums who supplied

  me with assistance. And a big thanks to Jon, the author of AutoIt version 3.

  www.autoitscript.com/autoit3/

LEGAL: This function is provided without any warranty. This code cannot do any

  damage to your computer by itself. If you use it in such a way to cause harm

  or damage of any kind, it is your own fault.

  You may edit, modify, or distribute this function as you see fit. I would ask

  that if you find a bug, or a feature that could be added or improved, please

  send me a detailed email so that I can release a new version. The only thing

  you may not do is claim that you wrote this code (although feel free to change

  it for use in your projects.) Always remember to give proper credit if you use

  a major portion of someone else's code.

VERSION HISTORY:

  2.0.3 (06/13/2004)

    * Added: return value to match ControlSend (see RETURN above)

  2.0.2 (06/13/2004)

    * Bug fixed: dimension range error when using raw mode (flag 1)

    * I didn't fully get rid of all the code I should have in the 2.0.1 release

  2.0.1 (06/12/2004)

    * Removed a useless If...Else statement that wasn't needed

  2.0 (06/12/2004)

    * Updated to work with special chars like {UP}, {DOWN}, and {ASC ####}

    * Updated to work with key modifiers such as !, ^, and +

    * 3 flag modes added to take care of global vs local issue (see NOTE 1)

    * Name changed to ControlSendPlus to reflect the ability to use the !, ^,

      and + key modifiers (old name was ShiftControlSend)

  1.0 (06/09/2004)

    First release. No readme, and did not work with any special characters or

    modifier keys.

Edited: Corrected typo of function name (should be ControlSendPlus). Edited by phillip123adams

Phillip

Share this post


Link to post
Share on other sites

i am using controlsend to send text to a command prompt.

i type uppercase letters, but they are shown lowercase in the prompt.

and of course i tried +t+h+i+s

and i got t=h=i=s

is there a workaround? i havent tried shiftdown... but preferably without simulating holding down shift is there a way to do this?

<{POST_SNAPBACK}>

in fact I don't understand your problem because the following script works
run(@Comspec)
WinWaitActive(@WindowsDir)
Send("+t+h+i+s   ---   ")
Send("THIS   ")

can you post a replication script?

Edit: obviously you cannnot use ControlSend on a command prompt windows because no ControlID are available for this type of windows.

Edited by jpm

Share this post


Link to post
Share on other sites

i just leave the control id blank ("") and it types to the window just fine

so i can use controlsend on a command prompt.

the whole reason i want to controlsend in the first place, is i plan on having the window hidden. and i dont want user interference, or have the script malfunction when some other window becomes active and the program is sending text.

also jpm...

Send("+t+h+i+s --- ")

Send("THIS ")

of course that works! its not CONTROLsend

so what you guys are telling me....

is if i want to controlsend any shifted keys...

i have to add that huge function to my small script?

then when i want to make a shifted key... how would i use that?

i would like an example on usage.

although, i just want to send a goddamn ":" instead of a ";" and a few other little things.

seems like alot of crap just for a few little characters!

either way... i once again have gotten into something way complicated, when the issue is very small, and should be a quick fix.

then this thing is talking about wont work on all computers... hmmm, thats not good.

and uhmm, i dont get how to use the function

USAGE: ShiftControlSend("title", "text", "classnameNN", "string", flag)

isnt the function named controlsendplus?

controlsendplus("title", "text", "classnameNN", "string", flag) ???????? or no...

so how do i use this function?

god! is there a better way to put text into a command prompt?

i tried using a batch file... but it seems that i cant do a thing with that... because im not edgimacated (educated lol) enough to know what im doing.. and i cant remember what little i do know.

i dont need to use autoit to send the keys, but i dont really know any other way besides a batch file, and thats not really working for me.

frustration! urge to kill rising!

i dont even want to look at this topic for awhile. im going to have a goddamn beer

hopefully someone is laughing at me while reading this, and has the mercy to give me a solution to my problem.

thanks for reading this huge ass post.

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

I understand your frustation, but if "AutoIt Window info" does not show you any controlid you should not use ControlSend.

I am not sure what's happening to this kind of send.

I have look at the code but I cannot understand how to fix something. We need the designer JON to compe on stage. So Just wait he can analyse what can be done.

Sorry for not helping more :(

Share this post


Link to post
Share on other sites

USAGE: ShiftControlSend("title", "text", "classnameNN", "string", flag)

isnt the function named controlsendplus?

controlsendplus("title", "text", "classnameNN", "string", flag) ???????? or no...

<{POST_SNAPBACK}>

Sorry t0ddie! I never noticed the typo in the function name. Yes, it is ControlSendPlus. I've edited my post of the readme to correct the typo.

I agree, it would be much nicer if ControlSend could do this, but...

Here's a sample using ControlSendPlus with a bunch of shift state characters.

#include <ControlSendPlus.au3>
opt("WinTitleMatchMode", 4)
Run("Ftp.exe ", @ScriptDir & "\")
WinWait("classname=ConsoleWindowClass")
$hWnd = WinGetHandle("Classname=ConsoleWindowClass")
Sleep(1000)
_ControlSendPlus($hWnd, "", "", "This:Is;Just*A$Test." & "{enter}", 0)
_ControlSendPlus($hWnd, "", "", "AND THIS IS another test." & "{enter}", 0)

Phillip

Share this post


Link to post
Share on other sites

i really really like autoit, as im sure we all do.

and although this is an issue with .au3 i cant complain anymore, and i want to leave this off with a good note.

after all, im thankful that this is still a free program, and there is great support on the forums.

im sure a fix will come out for this eventually.

great feedback guys! thanks for the help. and dont worry about typo's.. i do that all the time heh. (edit)

just wanted to be sure i understood how to use that, and it didnt make sense at first.. but i figured it was a simple mistake. nice function

thank you autoit, and i suppose that would be mucho thanks to jon :(


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...