Closed SpecialCharacter closed 2 years ago
Description I took the example code and flipped it around. No my code does not work anymore.
Platform and pynput version MacOS Catalina 10.15.7 pynput version unknown
To Reproduce So I took the example code and flipped it around:
def darwin_intercept(event_type, event): import Quartz length, chars = Quartz.CGEventKeyboardGetUnicodeString( event, 100, None, None) if length > 0 and chars == 'x': # Suppress x return None elif length > 0 and chars == 'a': # Transform a to b Quartz.CGEventKeyboardSetUnicodeString(event, 1, 'b') else: return event
def darwin_intercept(event_type, event): import Quartz length, chars = Quartz.CGEventKeyboardGetUnicodeString( event, 100, None, None) if length > 0 and chars == 'a': # Transform a to b Quartz.CGEventKeyboardSetUnicodeString(event, 1, 'b') elif length > 0 and chars == 'c': # Transform c to d Quartz.CGEventKeyboardSetUnicodeString(event, 1, 'd') if length > 0 and chars == 'x': # Suppress x return None else: return event
Should be trivial, right? But now if I delete
if length > 0 and chars == 'x': # Suppress x return None
my code does not work anymore. When I leave it in but replace if by elif, it does not work either. This is puzzling me...
if
elif
My bad. After some more searching, I found the mistake in one of my conditions.
Description I took the example code and flipped it around. No my code does not work anymore.
Platform and pynput version MacOS Catalina 10.15.7 pynput version unknown
To Reproduce So I took the example code and flipped it around:
Should be trivial, right? But now if I delete
my code does not work anymore. When I leave it in but replace
if
byelif
, it does not work either. This is puzzling me...