0
votes

I'm running Windows 10 Home Edition, and I've been using AutoHotkey v1.1.23.01 for the past couple of days now. I have the following script:

:*:dmenv::
Input, machine,,{Enter}
Send, FOR /f "tokens=*" `%i IN ('docker-machine env --shell=cmd %machine%') DO `%i
return

Every time I run this script from within the context of CMD, I receive the following output:

FOR qf "tokens=*" %i IN )wdocker-machine env --shell=cmd asdw( DO %i

As you can see, the forward slash (/) has been replaced by q, the parenthesis have been reversed, and single quotes (') have been replaced with w.

Can anyone tell what I might be missing here? I've already tried checking in other programs (ie Notepad++, Explorer etc.), and this script works everywhere except CMD.

I've tried escaping the characters by using the backtick like the AHK documentation suggests, and converting the .ahk file to UTF-8 via Notepad++. Also, I've tried using work-arounds such as chr(47) and Clipboard = code without any luck.

Final Note:

I've just realized that when I change my language to HEB, and write dmenv to run the script, it works: FOR /f "tokens=*" %i IN ('docker-machine env --shell=cmd asdf') DO %i

Why is this happening?

1

1 Answers

2
votes

Your keyboard layout isn't English, but cmd.exe is.

If you switch windows' language to English before running send, it'll work (note that switching languages can be done by ahk / dll calls)

You can, however, use the following workaround instead: (tested on Win10)

:*:dmenv::
Input, machine,,{Enter}
text = FOR /f "tokens=*" `%i IN ('docker-machine env --shell=cmd %machine%') DO `%i
clp_bck := clipboardAll
clipboard := text
send ^v ; use ctrl v to send the text
clipboard := clp_bck
return