BlueScreen Posted July 28, 2004 Posted July 28, 2004 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
SlimShady Posted July 28, 2004 Posted July 28, 2004 In other word, why it works only on Notepad?Good question.
ezzetabi Posted July 28, 2004 Posted July 28, 2004 In my comp shows "ò".. it is maybe a intenational keyboard problem?
SlimShady Posted July 28, 2004 Posted July 28, 2004 My test script: Run(@ComSpec) Sleep(500) $Title = WinGetTitle("") ControlSend($Title,"", "", "@") It sends a "2" here.
BlueScreen Posted July 28, 2004 Author Posted July 28, 2004 Dudes, Looks like ControlSend is having troubles with "@". Any suggestion except using "SHIFT"?
sugi Posted July 28, 2004 Posted July 28, 2004 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 Jon Posted July 28, 2004 Administrators Posted July 28, 2004 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.
BlueScreen Posted July 28, 2004 Author Posted July 28, 2004 (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??? Edited July 28, 2004 by BlueScreen
sugi Posted July 28, 2004 Posted July 28, 2004 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?
this-is-me Posted July 28, 2004 Posted July 28, 2004 (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 July 28, 2004 by this-is-me Who else would I be?
pekster Posted July 28, 2004 Posted July 28, 2004 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.
BlueScreen Posted July 28, 2004 Author Posted July 28, 2004 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...
ezzetabi Posted July 29, 2004 Posted July 29, 2004 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
BlueScreen Posted July 29, 2004 Author Posted July 29, 2004 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...
pekster Posted July 29, 2004 Posted July 29, 2004 I wanna try Pekster's ControlSendPlus function but the link is down... 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.
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