Sign in to follow this  
Followers 0
BlueScreen

ControlSend issues

15 posts in this topic

Guys,

Why 'ControlSend ("Untitled - Notepad","", "Edit1", "@")' does displays the "@" and 'ControlSend ("C:\WINDOWS\System32\cmd.exe","", "", "@")' shows "2"?

In other word, why it works only on Notepad?

10x

Share this post


Link to post
Share on other sites



In other word, why it works only on Notepad?

Good question.

Share this post


Link to post
Share on other sites

In my comp shows "ò".. it is maybe a intenational keyboard problem?

Share this post


Link to post
Share on other sites

My test script:

Run(@ComSpec)
Sleep(500)
$Title = WinGetTitle("")
ControlSend($Title,"", "", "@")

It sends a "2" here.

Share this post


Link to post
Share on other sites

Dudes,

Looks like ControlSend is having troubles with "@". :ph34r:

Any suggestion except using "SHIFT"? :(

Share this post


Link to post
Share on other sites

I get a "q" instead...

Maybe sending {ASC nnn} is a good workaround for this general problem? I just tried the following code and it looks fine for me:

Run(@ComSpec)
Sleep(1000)
$Title = WinGetTitle("")
For $i = 32 to 254
   ControlSend($Title,"", "", '{ASC '& $i &'}')
Next

Share this post


Link to post
Share on other sites

Good question.

Notepad ins a windows app which handles keyboard messages nicely. cmd.exe seems to handle message differently and relies more on checking the physical state of the keyboard which can lead to odd results with ControlSend.

The standard version of Send is preferable to use when you want to send these characters to the command prompt.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Sugi,

Try this:

Goto "START"-->"RUN"-->"CMD"--><CR>

Run this script of you w/o @COMSPEC.

$Title = "Command Prompt"
For $i = 32 to 254
  ControlSend($Title,"", "", '{ASC '& $i &'}')
Next

Why isn't it the same??? :ph34r:

Edited by BlueScreen

Share this post


Link to post
Share on other sites

Well, first I guess your $Title is not correct... or is the title of your command prompt really "Command Prompt" after starting it like you described? At least it's not for me.

But after correcting $Title instead of sending everything to the cmd.exe window everything got sent to SciTE...

After adding a WinActivate($Title) before going into the For loop, everything works again...

I tested something else (open notepad before trying):

Opt('WinTitleMatchMode',4)
$Title = "classname=Notepad"
WinActivate($Title)
For $i = 32 to 254
    ControlSend($Title,"", "Edit1", 'xxx{ASC '& $i &'}')
Next

If you click on another window while the script is sending the keys, the 'xxx' is sent to notepad but the {ASC nnn} is sent to the window I clicked on. And notepad forces it's way to the foreground.

@Jon: It seems to me that {ASC nnn} is always sent to the active window. Is this a bug or a feature or is it impossible to send {ASC nnn} to inactive windows?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Controlsend doesn't correctly send the shift. You can send {Shiftdown}2{Shiftup} instead of doing a winactivate and send. You can also use controlsendplus by peskter or pkster or something like that.

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

Yup. This is the exact problem my UDF solves.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Jon,

The standard version of Send is preferable to use when you want to send these characters to the command prompt.

I agree, but the disadvantage is that you have to focus the window.

In ControlSend, the window can be minimized and still stuff can be written there.

I wanna try Pekster's ControlSendPlus function but the link is down... :ph34r:

Share this post


Link to post
Share on other sites

Why not use "cmd /c command" ? Do you need to write inside a window?

Or just pass the a single asked thig?

Do you tried

"cmd /c echo "The string"|command" It may work...

E.G.:

echo y|format c: /u :ph34r::(:lol:

Share this post


Link to post
Share on other sites

10x, ezzetabi,

I need send "@" to a window, but ControlSend MUST be used since window's state can be minimized.

I have managed to tweak with 'Send("{SHIFTDOWN}")'

Send("{SHIFTDOWN}")

ControlSend .........................

Send("{SHIFTUP}")

10x, everybody...

Share this post


Link to post
Share on other sites

I wanna try Pekster's ControlSendPlus function but the link is down...  :ph34r:

Sorry, I moved the files but forgot to change the index page. Even if you problem is solved now, you may still want to check out my function. It will not only handle the shift-state problem, but also includes flags so that you can fix problems with control and/or alt. I know that a command prompt has problems with one of them as well.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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