@@ -46,7 +46,7 @@ def __win32_event_filter(self, msg, data):
4646
4747 def __on_press (self , key ):
4848 userSettings = self .settings .get_config ()
49- if self .changeKey == True :
49+ if self .changeKey :
5050 keyPressed = getKeyPressed (self .keyboard_listener , key )
5151 if keyPressed not in self .hotkeys :
5252 if ">" in keyPressed :
@@ -93,41 +93,53 @@ def __on_press(self, key):
9393 keyPressed = vk_nb [keyPressed ]
9494 except :
9595 pass
96+
9697 for keys in userSettings ["Hotkeys" ]:
97- if userSettings ["Hotkeys" ][keys ] == [ ]:
98+ if not userSettings ["Hotkeys" ][keys ]:
9899 userSettings ["Hotkeys" ][keys ] = ""
100+
99101 if keyPressed not in self .hotkey_detection :
100102 self .hotkey_detection .append (keyPressed )
103+
101104 by_hotkey = True
105+
102106 if (
103- self . hotkey_detection == userSettings ["Hotkeys" ]["Record_Start" ]
104- and self .macro .record == False
105- and self .macro .playback == False
107+ self . __is_hotkey_triggered ( userSettings ["Hotkeys" ]["Record_Start" ], self . hotkey_detection )
108+ and self .macro .record == False
109+ and self .macro .playback == False
106110 ):
107111 self .macro .start_record (by_hotkey )
108112
109113 elif (
110- self . hotkey_detection == userSettings ["Hotkeys" ]["Record_Stop" ]
111- and self .macro .record == True
112- and self .macro .playback == False
114+ self . __is_hotkey_triggered ( userSettings ["Hotkeys" ]["Record_Stop" ], self . hotkey_detection )
115+ and self .macro .record == True
116+ and self .macro .playback == False
113117 ):
114118 self .macro .stop_record ()
115119
116120 elif (
117- self . hotkey_detection == userSettings ["Hotkeys" ]["Playback_Start" ]
118- and self .macro .record == False
119- and self .macro .playback == False
120- and self .main_app .macro_recorded == True
121+ self . __is_hotkey_triggered ( userSettings ["Hotkeys" ]["Playback_Start" ], self . hotkey_detection )
122+ and self .macro .record == False
123+ and self .macro .playback == False
124+ and self .main_app .macro_recorded == True
121125 ):
122126 self .macro .start_playback ()
123127
124128 elif (
125- self . hotkey_detection == userSettings ["Hotkeys" ]["Playback_Stop" ]
126- and self .macro .record == False
127- and self .macro .playback == True
129+ self . __is_hotkey_triggered ( userSettings ["Hotkeys" ]["Playback_Stop" ], self . hotkey_detection )
130+ and self .macro .record == False
131+ and self .macro .playback == True
128132 ):
129133 self .macro .stop_playback (by_hotkey )
130134
131135 def __on_release (self , key ):
132136 if len (self .hotkey_detection ) != 0 :
133137 self .hotkey_detection .pop ()
138+
139+ def __is_hotkey_triggered (self , hotkey_config , detected_keys ):
140+ has_modifier = any ("Key." in key for key in hotkey_config )
141+ if has_modifier :
142+ return set (hotkey_config ) == set (detected_keys )
143+ else :
144+ return any (key in detected_keys for key in hotkey_config )
145+
0 commit comments