Action Codes are kind of technical. You can just use the default buttons with their predefined actions without having to deal with action codes, and enjoy a flexible and powerful application. But if you want to define your own buttons, you’ll need to enter action codes.
The “Action” field on the Button screen is where you enter one or more action codes. The field is a text string. Generally, each code causes a keystroke to be sent to the remote computer. Therefore, you can cause buttons to control the computer in any way a keyboard can.
Most characters in the text string simply cause that character to be sent. For example, entering “hello” in the Action field (without the quotes) will cause the five characters “h”, “e”, “l”, “l”, and “o” to be sent to the remote computer when the button is touched.
The backslash “\” is a special escape character causing one or more subsequent characters in the string to be interpreted differently.
“\n” will send a single newline character.
“\t” will send a tab.
”\r” will send a return.
”\\” will send a single backslash.
So for example, “hello\rthere” will send “hello” followed by the return key, followed by “there”.
“\p” is special. It must be followed by exactly two decimal digits from 01 to 99 that represent a number of seconds to pause. Thus, “ABC\p05XYZ” means to type “ABC”, then pause five seconds, then type” XYZ”.
“\x” is extra special. It must be followed by exactly four hexadecimal digits that represent a key code. Key codes are numeric values that represent special keys like the Escape key, arrow keys, and so on. For example, the hexadecimal code for the Left Arrow key is FF51, so the action code “\xFF51″ would cause the Left Arrow key to be sent to the remote computer.
Hex digits can be upper or lower case. The hexadecimal key codes are as defined in the X11 and RFB protocols, and there are hundreds of them. Most of them represent normal keyboard keys and various Unicode characters. You can just enter plain text in the Action field, so for regular text you don’t need key codes, but codes for the special keys, such as the arrow keys, are quite useful. Some useful codes are listed below.
The results of poorly formatted escape sequences, such as where a backslash is not followed by one of the specific letters shown above, or \x is not followed by exactly four hex digits, is undefined.
Every key that is sent is immediately pressed and released. In other words, the keys are “tapped” and not “held”. However, a very few \x keycodes are exceptions to this rule and are treated as “toggle” codes. These codes are the exceptions:
”\xFFE1″ Shift key (left side)
”\xFFE3″ Control key (left side)
”\xFFE7″ Meta key (left side) (interpreted as the Option key on a Mac)
”\xFFE9″ Alt key (left side) (interpreted the Command key on a Mac)
The first time one of these codes are encountered in the action string, a keycode is sent to press the key and keep it held down. Therefore subsequent keys are shifted appropriately. To release the key, place its \x keycode into the string again. The second time the code is encountered, the keycode is sent to release the key. Subsequent encounters of the same code continue to toggle the key state. Note that the key state is tracked, and if any of these special keys are still pressed at the end of the action string, key codes are automatically sent to release the keys.
So for example to send Command-Q to a Macintosh remote computer, you can use the action string “\xFFE9Q”. To send Control-Alt-DEL to a PC, you could use the action string “\xFFE3\xFFE9\XFFFF”.
Only the codes listed above are treated specially. There are alternate ”right side of the keyboard” codes for Shift, Control, Alt and Meta and those are not treated as exceptions, and are “tapped” as with other normal keys.
Note also that the Shift is an unusual case. To send upper and lower case alphabetic characters, just type them into the action string as upper or lower case and it will be fine – you do not need to use the Shift code. The Shift key code should only be used to get special non-alpha codes, such as Shift-Escape for example.
Example command strings:
”Hello\nthere” sends “Hello”, then a newline, then “there”.
“\xFF52″ sends an Up arrow.
“\xFFE9\xFF1B” sends Command-ESC (invokes Front Row on a Mac)
“\xFFE3\xFFE9\xFFFF” Control-Alt-DEL
Some key codes:
These codes are sent to the remote computer, but it is up to the remote computer to interpret them. Different computers may interpret the codes in different ways, especially for the less common keys. Technically, you can send any of the over 65,000 possible codes. Many of them may send oddball Unicode characters, and many others will probably be ignored. While “\xFF51″ will likely perform a Left Arrow on every computer, “\xFEE9″ may or may not click the mouse button, and as for “\xFFE0″, well, does anyone have a computer with an F35 function key on it? Have fun experimenting!
BackSpace \xff08 /* Back space, back char */ Tab \xff09 Linefeed 0xff0a /* Linefeed, LF */ Clear 0xff0b Return 0xff0d /* Return, enter */ Pause 0xff13 /* Pause, hold */ Scroll_Lock 0xff14 Sys_Req 0xff15 Escape 0xff1b Delete 0xffff /* Delete, rubout */
Home 0xff50 Left 0xff51 /* Move left, left arrow */ Up 0xff52 /* Move up, up arrow */ Right 0xff53 /* Move right, right arrow */ Down 0xff54 /* Move down, down arrow */ Prior 0xff55 /* Prior, previous */ Page_Up 0xff55 Next 0xff56 /* Next */ Page_Down 0xff56 End 0xff57 /* EOL */ Begin 0xff58 /* BOL */
#define XK_Select 0xff60 /* Select, mark */ #define XK_Print 0xff61 #define XK_Execute 0xff62 /* Execute, run, do */ #define XK_Insert 0xff63 /* Insert, insert here */ #define XK_Undo 0xff65 #define XK_Redo 0xff66 /* Redo, again */ #define XK_Menu 0xff67 #define XK_Find 0xff68 /* Find, search */ #define XK_Cancel 0xff69 /* Cancel, stop, abort, exit */ #define XK_Help 0xff6a /* Help */ #define XK_Break 0xff6b #define XK_Mode_switch 0xff7e /* Character set switch */ #define XK_script_switch 0xff7e /* Alias for mode_switch */ #define XK_Num_Lock 0xff7f
#define XK_F1 0xffbe #define XK_F2 0xffbf #define XK_F3 0xffc0 #define XK_F4 0xffc1 #define XK_F5 0xffc2 #define XK_F6 0xffc3 #define XK_F7 0xffc4 #define XK_F8 0xffc5 #define XK_F9 0xffc6 #define XK_F10 0xffc7 #define XK_F11 0xffc8 #define XK_F12 0xffc9 #define XK_F13 0xffca #define XK_F14 0xffcb #define XK_F15 0xffcc #define XK_F16 0xffcd #define XK_F17 0xffce #define XK_F18 0xffcf #define XK_F19 0xffd0 #define XK_F20 0xffd1 #define XK_F21 0xffd2 #define XK_F22 0xffd3 #define XK_F23 0xffd4 #define XK_F24 0xffd5 #define XK_F25 0xffd6 #define XK_F26 0xffd7 #define XK_F27 0xffd8 #define XK_F28 0xffd9 #define XK_F29 0xffda #define XK_F30 0xffdb #define XK_F31 0xffdc #define XK_F32 0xffdd #define XK_F33 0xffde #define XK_F34 0xffdf #define XK_F35 0xffe0
#define XK_Shift_L 0xffe1 /* Left shift */ #define XK_Shift_R 0xffe2 /* Right shift */ #define XK_Control_L 0xffe3 /* Left control */ #define XK_Control_R 0xffe4 /* Right control */ #define XK_Caps_Lock 0xffe5 /* Caps lock */ #define XK_Shift_Lock 0xffe6 /* Shift lock */
#define XK_Meta_L 0xffe7 /* Left meta */ #define XK_Meta_R 0xffe8 /* Right meta */ #define XK_Alt_L 0xffe9 /* Left alt */ #define XK_Alt_R 0xffea /* Right alt */ #define XK_Super_L 0xffeb /* Left super */ #define XK_Super_R 0xffec /* Right super */ #define XK_Hyper_L 0xffed /* Left hyper */ #define XK_Hyper_R 0xffee /* Right hyper */
#define XK_Pointer_Left 0xfee0 #define XK_Pointer_Right 0xfee1 #define XK_Pointer_Up 0xfee2 #define XK_Pointer_Down 0xfee3 #define XK_Pointer_UpLeft 0xfee4 #define XK_Pointer_UpRight 0xfee5 #define XK_Pointer_DownLeft 0xfee6 #define XK_Pointer_DownRight 0xfee7 #define XK_Pointer_Button_Dflt 0xfee8 #define XK_Pointer_Button1 0xfee9 #define XK_Pointer_Button2 0xfeea #define XK_Pointer_Button3 0xfeeb #define XK_Pointer_Button4 0xfeec #define XK_Pointer_Button5 0xfeed #define XK_Pointer_DblClick_Dflt 0xfeee #define XK_Pointer_DblClick1 0xfeef #define XK_Pointer_DblClick2 0xfef0 #define XK_Pointer_DblClick3 0xfef1 #define XK_Pointer_DblClick4 0xfef2 #define XK_Pointer_DblClick5 0xfef3 #define XK_Pointer_Drag_Dflt 0xfef4 #define XK_Pointer_Drag1 0xfef5 #define XK_Pointer_Drag2 0xfef6 #define XK_Pointer_Drag3 0xfef7 #define XK_Pointer_Drag4 0xfef8 #define XK_Pointer_Drag5 0xfefd

