pyatom/pyatom — Issue #23: Function keys don't work
Author: jonathonw
Created: 2012-02-28 05:26:57+00:00
State: open

When attempting to send a function key (i.e. `F2`) via `sendKey()`, atomac crashes with the error:

Traceback (most recent call last):
File "PPMidiController.py", line 71, in
main()
File "PPMidiController.py", line 55, in main
print_message(m, textSlider, bgSlider, pp)
File "PPMidiController.py", line 29, in print_message
app.sendKey("F2")
File "build/bdist.macosx-10.7-intel/egg/atomac/AXClasses.py", line 793, in sendKey
File "build/bdist.macosx-10.7-intel/egg/atomac/AXClasses.py", line 241, in _sendKey
File "build/bdist.macosx-10.7-intel/egg/atomac/AXClasses.py", line 201, in _addKeyToQueue
File "build/bdist.macosx-10.7-intel/egg/atomac/AXClasses.py", line 334, in _sendKeyWithModifiers
ValueError: Please provide only one character to send

This appears to be because the modifiers for the function key constants are uppercase: since they are uppercase, Atomac changes them to lowercase and attempts to send the string with the shift modifier key pressed. This fails, because the lowercase version of the constant is not in the keymap.

This is easily fixed; a patch changing the function key constant to match the rest of the key constants (lowercase, surrounded in angle brackets) is forthcoming.