示例#1
0
 def _get_media_event(key_id, key_down):
     # Credit: https://gist.github.com/fredrikw/4078034
     flags = 0xa00 if key_down else 0xb00
     return NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(  # nopep8: We can't make this line shorter!
         NSSystemDefined, (0, 0),
         flags,
         0, 0, 0, 8,
         (key_id << 16) | flags,
         -1
     ).CGEvent()
示例#2
0
 def _get_media_event(key_id, key_down):
     # Credit: https://gist.github.com/fredrikw/4078034
     flags = 0xa00 if key_down else 0xb00
     return NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(  # nopep8: We can't make this line shorter!
         NSSystemDefined, (0, 0),
         flags,
         0, 0, 0, 8,
         (key_id << 16) | flags,
         -1
     ).CGEvent()
示例#3
0
 def doKey(down):
     ev = NSEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2_(
         NSSystemDefined, # type
         (0,0), # location
         0xa00 if down else 0xb00, # flags
         0, # timestamp
         0, # window
         0, # ctx
         8, # subtype
         (key << 16) | ((0xa if down else 0xb) << 8), # data1
         -1 # data2
         )
     cev = ev.CGEvent()
     CGEventPost(0, cev)