How do I type() a backslash in Windows?

Asked by Olof Bjarnason

Sikuli X-1.0rc3 (r905)
OS: Windows7 Professional.

I want to type in a path on a command prompt in Windows 7 using Sikuli (great project btw!).

When running this script:

type("\\")

.. I get this error:

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Invalid key code

I have looked through all Key constants for a "BACKSLASH" but cannot find any:
print(dir(Key))

.. gives me:

['ADD', 'ALT', 'BACKSPACE', 'CAPS_LOCK', 'CMD', 'CTRL', 'C_ADD', 'C_ALT', 'C_CAPS_LOCK', 'C_CMD', 'C_CTRL', 'C_DELETE', 'C_DIVIDE', 'C_DOWN', 'C_END', 'C_ESC', 'C_F1', 'C_F10', 'C_F11', 'C_F12', 'C_F13', 'C_F14', 'C_F15', 'C_F2', 'C_F3', 'C_F4', 'C_F5', 'C_F6', 'C_F7', 'C_F8', 'C_F9', 'C_HOME', 'C_INSERT', 'C_LEFT', 'C_META', 'C_MINUS', 'C_MULTIPLY', 'C_NUM0', 'C_NUM1', 'C_NUM2', 'C_NUM3', 'C_NUM4', 'C_NUM5', 'C_NUM6', 'C_NUM7', 'C_NUM8', 'C_NUM9', 'C_NUM_LOCK', 'C_PAGE_DOWN', 'C_PAGE_UP', 'C_PAUSE', 'C_PRINTSCREEN', 'C_RIGHT', 'C_SCROLL_LOCK', 'C_SEPARATOR', 'C_SHIFT', 'C_UP', 'C_WIN', 'DELETE', 'DIVIDE', 'DOWN', 'END', 'ENTER', 'ESC', 'F1', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'HOME', 'INSERT', 'LEFT', 'META', 'MINUS', 'MULTIPLY', 'NUM0', 'NUM1', 'NUM2', 'NUM3', 'NUM4', 'NUM5', 'NUM6', 'NUM7', 'NUM8', 'NUM9', 'NUM_LOCK', 'PAGE_DOWN', 'PAGE_UP', 'PAUSE', 'PRINTSCREEN', 'RIGHT', 'SCROLL_LOCK', 'SEPARATOR', 'SHIFT', 'SPACE', 'TAB', 'UP', 'WIN', '__class__', '__copy__', '__deepcopy__', '__delattr__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__unicode__', 'class', 'equals', 'getClass', 'hashCode', 'notify', 'notifyAll', 'toJavaKeyCode', 'toString', 'wait']

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Olof Bjarnason
Solved:
Last query:
Last reply:
Revision history for this message
Olof Bjarnason (objarni) said :
#1

I've also tried type(Key.SEPARATOR), which seem to be ignored by Sikuli.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

look faq 933

Revision history for this message
Harry Readinger (temporary22) said :
#3

I just tried type("\\") on my windows machine and it worked fine.

What type of keyboard are you using?

Revision history for this message
Olof Bjarnason (objarni) said :
#4

I'm using Swedish keyboard (which is qwerty but backslash has the odd combination AltGr+'+'), and I've now found out that type() is assuming American keyboard layout. There is a wish-list item to make it more international, and I'll go for the paste() solution for now.

Thanks!