odd error

Alex Hall mehgcap at gmail.com
Tue Mar 9 17:48:10 CET 2010


Okay, I changed the keycode from 99 (c) to 107 (k), and the errors
have disappeared. However, now the function that should be called is
not. As I said in a previous message, I have always had trouble with
this sort of keystroke dictionary. It seems like, if a keycode is out
of order or not one more than the number before it, the function to
which it is tied will not get called. I am using the message looping
mode from Tim Golden's website, and it works beautifully until I try
to put an out-of-sequence keycode into the keystrokes dictionary. The
dictionary contains numbers 0-9 (48-57) and all is well, but when I
put in this 107 code then the function tied to 107 is not called, yet
the ones tied to 48-57 still work normally. Why would the sequence
matter, or does it not and I am doing something else wrong? Here is a
sample of my dictionary:

keys.append({
  1 : (48, win32con.MOD_CONTROL),
  2 : (49, win32con.MOD_CONTROL),
  3 : (50, win32con.MOD_CONTROL),
  4 : (51, win32con.MOD_CONTROL),
  5 : (52, win32con.MOD_CONTROL),
  6 : (53, win32con.MOD_CONTROL),
  7 : (54, win32con.MOD_CONTROL),
  8 : (55, win32con.MOD_CONTROL),
  9 : (56, win32con.MOD_CONTROL),
  10 : (57, win32con.MOD_CONTROL),
  11 : (107, win32con.MOD_CONTROL | win32con.MOD_SHIFT) #never calls
its #function, and note that it is not in the sequence of the other
ten
})

and here is a list of functions tied to it:

funcs.append({
  1 : exitProgram,
  2 : arm.sayLoad1,
  3 : arm.sayLoad2,
  4 : arm.sayLoad3,
  5 : arm.sayLoad4,
  6 : arm.sayProcAvg,
  7 : arm.sayUsedRam,
  8 : arm.sayDisk1Info,
  9 : arm.sayDisk2Info,
  10 : nextMode,
  11: clipboard.toClipboard
})

If I were to tie clipboard.toClipboard to any of keys 1-10 (0-9, or
48-57) then it would work fine; it is when the 107 shows up that the
function is not called, and this is a huge limitation for the rest of
the program since I am stuck with just the ten numbers available on
the keyboard. Any suggestions would be great!


On 3/9/10, Tim Golden <mail at timgolden.me.uk> wrote:
> On 09/03/2010 13:55, Alex Hall wrote:
>> Hi all,
>> In the same program I wrote about yesterday, I have a dictionary of
>> keystrokes which are captured. I just tried adding a new one, bringing
>> the total to 11. Here are entries 10 and 11; 10 has been working fine
>> for months.
>>
>>    10 : (57, win32con.MOD_CONTROL),
>>    11 : (99, win32con.MOD_CONTROL | win32con.MOD_SHIFT)
>>
>> Now, though, when I press ctrl-shift-c (keystroke 11)
>
> Ctrl-C (with or without any other modifier) has a special meaning
> which overrides any hotkeys. You may be able to do something by
> adding a break handler through SetConsoleCtrlHandler (exposed in
> win32api). But it would obviously be a special case outside your
> normal control flow.
>
> TJG
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap



More information about the Python-list mailing list