WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sending Keystrokes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Sending Unicode Keystrokes

 Keywords: SendKey SendKeysTo ClipPut ClipBoard Unicode ANSI Extended ASCII Keyboard Foreign Chinese German Double Byte Characters Question Marks Umlaut

Question:

Is there a way to Send German-Umlaut characters with the SendKey Functions? It seems strange that the SendKey Functions always return @FALSE. Why don't they return @TRUE except when it cannot send the correct characters.

Answer:

SendKey and SendKeysTo is one of the few WinBatch functions that accepts strings but does not have direct Unicode support. Basically, they translate your Unicode string to ANSI, translates the translation to keyboard scan codes and then sends them to the keyboard driver. But since your system is not set to a German locale, WinBatch does not know how to translate the Unicode to the characters before the conversion to the appropriate scan codes.

Using the system clipboard to copy and paste the values is the best approach.

Run( "notepad.exe", "" )
WinWaitExist( "~Notepad", 5)

UmlautChar = ChrHexToUnicode("DF00") ; ß
UmlautChar = ChrHexToUnicode("E400") ; ä
UmlautChar = ChrHexToUnicode("F600") ; ö
UmlautChar = ChrHexToUnicode("FC00") ; ü
UmlautChar = ChrHexToUnicode("C400") ; Ä
UmlautChar = ChrHexToUnicode("D600") ; Ö
UmlautChar = ChrHexToUnicode("DC00") ; Ü

;Handle Unicode Characters using SendKey
ClipPut(UmlautChar) ; Place Unicode character in clipboard
SendKey("^v") ; Clipboard paste
Exit
There is really no way for the SendKey function to confirm the keystrokes were sent to their intended target. SendKey return value is meaningless hence the return value of zero.

Question:

I am using WinBatch version 2008C on windows XP. My script mostly deals with characters for persons name that are in English. However I want to use SendKey to send a user name with chinese characters. They appear as question marks (???) in the WinBatch script. Is there any way that the chinese characters can be accepted by the script? Thanks.
Surname = {a Chinese character}
First_name = {a Chinese character}
;Winactivate to open the screen
WinActivate("GIOS")
TimeDelay(0.5)
;Entering name and DOB data
SendKey(Surname)
SendKey("{ENTER}")
TimeDelay(0.5)
SendKey(First_name)
SendKey("{ENTER}")

Answer:

SendKey and SendKeysTo is one of the few WinBatch functions that accepts strings but does not have direct Unicode support. Basically, they translate your Unicode string (Chinese Character) to ANSI, translates the translation to keyboard scan codes and then sends them to the keyboard driver. But since your system is not set to a Chinese locale, WinBatch does not know how to translate the Unicode to the double-byte characters before the conversion to the appropriate scan codes. You end up with the '?' characters.

Without knowing more about your applications it is a little difficult to recommend a solution. One suggestion is using the system clipboard to copy and paste the Chinese users names into your app. That might be worth a try.

Surname = {a Chinese character}
First_name = {a Chinese character}
;Winactivate to open the screen
WinActivate("GIOS")
TimeDelay(0.5)
;Entering name and DOB data
ClipPut(Surname)
SendKey("^v") ;Clip board paste
SendKey("{ENTER}")
TimeDelay(0.5)
ClipPut(First_name)
SendKey("^v") ;Clip board paste
SendKey("{ENTER}")

Article ID:   W18271
Filename:   Sending Unicode Keystrokes.txt
File Created: 2014:06:27:08:30:44
Last Updated: 2014:06:27:08:30:44