Mapping characters to keys problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mpalmer
Posts: 2
Joined: 13 Jun 2018, 22:13

Mapping characters to keys problem

13 Jun 2018, 22:59

Hi. First post.

I am writing an AutoHotKey script to automate Skype for Business for an educational institution.

One portion of the code requires that I open cmd.exe and enter some text which contains characters such as ", ` and others.

However, when I send the text to the command window, characters do not match output. To make things worse it differs from machine to machine.

An example:

I send this:
"copy ""Filename with spaces.doc"" c:\test" {Enter}

This is the expected output:
copy "Filename with spaces.doc" c:\test

This is the output on my hope PC:
copy @Filename with spaces.doc@ c:\test

This is the output on a work PC:
Copy ~Filename with spaces.doc~ c:\test

I can see that with the home PC example, there is some confusion somewhere with keyboard types (US versus UK). As for the work PC example, what the flipping flip is going on there?

There are other more indirect methods of solving this problem though they require fancy batch files and less friendly coding. I would rather keep it simple so other programmers can make sense of the code when I am not present to explain it. I also have limited time in which to complete this little project.

Anyone have any ideas?

Matt
gregster
Posts: 9012
Joined: 30 Sep 2013, 06:48

Re: Mapping characters to keys problem

13 Jun 2018, 23:30

Hi Matt, this works for me, only tested on one layout and computer:

Code: Select all

sendinput {text}copy "Filename with spaces.doc" c:\test
sendinput {Enter}
Note that {Text} mode needs Autohotkey version v1.1.27+
HTH
mpalmer
Posts: 2
Joined: 13 Jun 2018, 22:13

Re: Mapping characters to keys problem

14 Jun 2018, 05:15

Lo and behold! It seems to work with SendInput. Very interesting...
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Mapping characters to keys problem

14 Jun 2018, 20:09

The important part is not SendInput, but {Text}. Without it, the characters are translated to key combinations which are dependent on keyboard layout.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, inseption86, mebelantikjaya and 337 guests