I am honestly a bit lost as to why keys.append() is not a good choice here, but I have it working. I apparently have to use the ascii for capital letters if I am capturing the shift modifier, not the lowercase ascii. Using 67 instead of 99 works as expected.
I use append because the program has three different modes. Eventually, each mode may have its own keystrokes. When the user switches modes, the previous mode's keystrokes are unregistered and the new keystrokes, keys[currentModeNumber], are registered. The same with the functions; when a function is called from the dictionary, it is called using funcs[currentModeNumber]. Again, this lets me put all my functions into one big list, where each member of the list is a dictionary. I probably have the terminology wrong, but hopefully that makes sense. Sorry for not explaining that earlier, but I was just looking for problems in the key codes. Thanks for your help! On 3/10/10, Tim Golden <m...@timgolden.me.uk> wrote: > On 10/03/2010 09:16, Steven D'Aprano wrote: >> Perhaps all you need is a single dict, mapping characters to functions: >> >> funcs = { # Just a dict >> # keycode: function >> 'q': exitProgram, >> 'a': arm.sayLoad1 >> # etc. >> } >> >> >> Then whenever you get a keyboard event, convert it to the character: >> >> keycode = 113 >> c = chr(keycode) >> funcs(c)() > > FWIW (altho' it's not clear from the OP's code) he's basically > doing this: > > http://timgolden.me.uk/python/win32_how_do_i/catch_system_wide_hotkeys.html > > which uses the dictionary keys as an id in the call to RegisterHotKey. > > Obviously, that doesn't explain why he's building lists of dictionaries. > > > TJG > -- > http://mail.python.org/mailman/listinfo/python-list > -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap -- http://mail.python.org/mailman/listinfo/python-list