Jump to content

Recommended Posts

Posted

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

Posted

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
  • Administrators
Posted

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.


 

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
Posted

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?

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?
Posted

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.

Posted

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:

Posted

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:

Posted

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...

Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...