Home Page








Features Contents

4th July 2004


Brian Grainger
Michael Newman

email.gif (183 bytes)


In an earlier article I introduced the problem of trying to create a keyboard macro that would send characters defined by key codes from the numeric keypad. In particular, I had been told it would be useful to generate the Esperanto characters additional to our normal alphabet. At that time I introduced a program Michael Newman had developed that used a command line program to send the characters to a file, which could then be inserted into a Word file.

The drawbacks to this solution were that it utilised the command line, rather than being totally within Windows, and you could not insert the file into any application you wished. The solution offered was limited to Microsoft Word.

Not long after that article was published Michael came up with a new program, SNDKEY.EXE. He had created a little gem that used the Win32 API to send the character asked by the user to the output stream as a text character. The Sendkeys function of Windows Scripting Host (WSH) can then be used to send this text character, or combine it with regular characters. If the numpad keys for the character you require is 0123 then the following line creates the character:

Windows XP
cmd /c "sndkey.exe" 0123

Windows 9x
command.com /c "sndkey.exe" 0123

Michael has sent this program to me, along with the source, makefile and a copy of the GPL license under which it is released. In addition he includes an example script for Windows XP, which sends the results to a Word document. This has all been bundled up into a .zip file and can be downloaded here:


The SNDKEY.EXE program is called up by the command processor, whose name differs between various versions of Windows. If you are going to use the program on a Windows 9x machine then a different name is required, so I have created a version of the example script for a Windows 9x machine. The script also refers to the location of the SNDKEY.EXE file itself which may vary in your own environment. It should be fairly obvious what needs to change when you write your own script.

I have only recently found another difference between Windows XP and Windows 9x machines, which makes script writing a bit awkward. Windows 9x is centred around applications and in my first article introducing WSH I assumed this was true of all Windows. I introduced a Wsh.AppActivate construct to give focus to a particular application Window. I have since found that Windows XP is centred around documents so Wsh.AppActivate required a document name in scripting for Windows XP. This tends to limit scripts somewhat, because if you want to write a general macro used with any document you cannot say what the document will be called. The solution to the problem is to assume that the window requiring focus is active, which it usually is, and simply leave out the Wsh.AppActivate line from the script.

My Windows 9x example script for SNDKEY has done this. I tested the result in Windows for the following applications: Word, Excel, Wordpad, Front Page Express, Outlook Express and even Notepad. They all worked. The Windows 9X version of the example script can be downloaded here:


I hope that by looking at these example script you can see how to create any character you wish. Couple the script up to a shortcut on the desktop and you have a keyboard shortcut to any character you desire, including the Esperanto keys.

Earlier Articles in this series can be found here:
Keyboard Macros with Windows Scripting Host
Esperanto and Plugging the Gaps in Windows Scripting Host