How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

When recently using Intel Active Management Technology (AMT) I was remotely connected via the RealVNC client, but was having trouble sending keystrokes like F2 to enter the BIOS, F12 to select a startup device, or F8 to access the Windows startup menu.

This setup is complicated for a few reasons – first I’m using a Mac keyboard. Secondly, OS X remaps the function keys to do things like dashboard, expose, brightness, and volume by default.

After a little searching and trial and error, I found that I can use the free utility included with Mac OS X – AppleScript Editor.app – to send keycodes to the VNC connection. Here’s the code for the applescript you can use to send the F12 key:

tell application "VNC Viewer"
  activate
  tell application "System Events" to key code 111
end tell

This is what it should look like in the editor:

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

To send key combos, like holding down alt and pressing F4, the syntax would be something like this:

tell application "System Events" to key code 118 using {command down}

We use command instead of alt because that is how Real VNC Viewer translates the “alt” key for a remote windows system by default.

To send other keyboard F-keys to the remote Windows machine, use the table below to find the appropriate key – make sure to reference the “Mac” column even if the remote machine is a Windows box.

What about JAVA?

But what happens if you are running a java applet for a KVM console? How do you tell java to do a keycode?

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

To tell java to send F12 try this:

tell application "System Events" to set frontmost of process "java" to true
tell application "System Events"
    tell process "java"
        key code 111
    end tell
end tell
KeyMacWindowsLinuxNotes
KeyUp12626103
KeyDown12528108
KeyLeft12325105
KeyRight12427106
KeyBackspace117814
KeyEnter76*28
KeyHome11536102
KeyEnd11935107
KeyPageDown12134109
KeyPageUp11633104
KeyReturn3613*
KeyDelete5146111
KeyTab48915
KeySpacebar492057
KeyShift5610*
KeyControl5911*
KeyMenu5818139The Alt key
KeyPrintScreen*42210
KeyEscape53271
KeyCapsLock572058
KeyHelp11447138
KeyF112211259
KeyF212011360
KeyF39911461
KeyF411811562
KeyF59611663
KeyF69711764
KeyF79811865
KeyF810011966
KeyF910112067
KeyF1010912168
KeyF1110312287
KeyF1211112388
KeyMacFn63**
KeyMacOption58**
KeyMacCommand55**
KeyWinLeftWindow*91*On "Natural" keyboards
KeyWinRightWindow*92*On "Natural" keyboards
KeyWinApplication11093*On "Natural" keyboards
KeyQ128116
KeyW138717
KeyE146918
KeyR158219
KeyT178420
KeyY168921
KeyU328522
KeyI347323
KeyO317924
KeyP358025
KeyA*6530
KeyS18331
KeyD26832
rbKeyF37033
KeyG57134
KeyH47235
KeyJ387436
KeyK407537
KeyL377638
KeyZ69044
KeyX78845
KeyC86746
KeyV98647
KeyB116648
KeyN457849
KeyM467750
Key0294811
Key118492
Key219503
Key320514
Key421525
Key523536
Key622547
Key726558
Key828569
Key9255710
KeyPeriod4719052
KeyComma4318851
KeySlash4419153The key with /? generally next to right shift key.
KeyNum0829682On numeric keypad or with NumLock
KeyNum1839779On numeric keypad or with NumLock
KeyNum2849880On numeric keypad or with NumLock
KeyNum3859981On numeric keypad or with NumLock
KeyNum48610075On numeric keypad or with NumLock
KeyNum58710176On numeric keypad or with NumLock
KeyNum68810277On numeric keypad or with NumLock
KeyNum78910371On numeric keypad or with NumLock
KeyNum89110472On numeric keypad or with NumLock
KeyNum99210573On numeric keypad or with NumLock
KeyMultiply6710655On numeric keypad or with NumLock
KeyAdd6910778On numeric keypad or with NumLock
KeySubtract7810974On numeric keypad or with NumLock
KeyDivide7511198On numeric keypad or with NumLock
KeyDecimal6511083On numeric keypad or with NumLock
KeyNumEqual81*117On numeric keypad or with NumLock

If you haven’t seen Intel’s AMT with KVM control – check it out. They say, “with out-of-band management capabilities, including Keyboard-Video-Mouse (KVM) Remote Control,3 Intel AMT allows IT to remotely remediate and recover systems after OS failures. Out-of-band alerting and event logging also help to reduce downtime,” and basically it just makes it really easy to connect to a computer to control it – even access the BIOS etc before it even boots into windows.

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

Related Posts:

This entry was posted in Tech Tips and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *