Command line input being garbled

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jakobve
Posts: 1
Joined: 16 Mar 2018, 09:08

Command line input being garbled

16 Mar 2018, 09:48

Hi!

So I'm trying to execute a simple line in cmd, but some of the special characters (:, \, |, etc) are changed when sent to the command window.

This is the script I run:

Code: Select all

Run cmd.exe C:\apps\Capture2Text\Capture2Text_CLI.exe -o ocr.txt --screen-rect "825 125 1118 250" -d | clip
This is what gets output on CMD:

Code: Select all

C>=apps=Capture2Text=Capture2Text_CLI.exe -o ocr.txt --screen-rect 22825 125 1118 25022 -d \ clip
If I change my keyboard language from Swedish to US English, it works, but only if I don't do anything in between starting cmd and sending the commands. If I try to move the CMD window and then send text, the text never gets sent.

What am I doing wrong?
Guest

Re: Command line input being garbled

17 Mar 2018, 11:45

No need to run the cmd.exe, if you must %comspec% /c is the preferred method (search for it in the docs) but

Code: Select all

Run C:\apps\Capture2Text\Capture2Text_CLI.exe
should do it, you may need to quote the parameters, see the documentation for that.
If all else fails just create a batch file with that command and run the batch file run %comspec% /c mycli.bat
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Command line input being garbled

24 Mar 2018, 02:21

jakobve wrote:This is what gets output on CMD:
That doesn't make any sense to me. But anyway, if you want cmd.exe to execute a command, you need the /c or /k command-line switch (it isn't just preferred, but required).
If I change my keyboard language from Swedish to US English, it works, but only if I don't do anything in between starting cmd and sending the commands. If I try to move the CMD window and then send text, the text never gets sent.
It sounds like you are not using the script you posted, but are sending the commands as keystrokes. In that case, the result you described would make a little more sense.
Guest wrote:No need to run the cmd.exe
There is a need. If used correctly, cmd.exe will interpret the pipe character as an instruction to take the output of the first command and pass it to the second command. Without cmd.exe, "| clip" would simply be passed as a parameter and have the wrong effect.

However, the purpose of piping the output to clip is probably to get it into the script via the clipboard. In that case, I would suggest getting the output directly, such as by using the Shell.Exec() method shown in the RunWait documentation, or the StdoutToVar() function which can be found on the forums.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: gongnl, RandomBoy, Rohwedder and 361 guests