def bind_callback(shortcut: str, callback: typing.Callable) -> None: if on_linux(): import keybind keybind.KeyBinder.activate({shortcut: callback}, run_thread=True) else: # replace all - with +, except for the last character, in case it is the actual "-" key adapted_shortcut = shortcut[:-1].replace("-", "+") + shortcut[-1] import keyboard keyboard.register_hotkey(adapted_shortcut, callback)
def main(): register_hotkey("F1", game_menu.switch) register_hotkey("F2", lambda: os._exit(1)) win32gui.SetForegroundWindow(game_window.hwnd) while True: try: overlay.fill(Colors.trans) window_focused = game_window.hwnd == win32gui.GetForegroundWindow() if window_focused: try: local_player = Entity( mem.read_int(Offsets.game_module + Offsets.dwLocalPlayer)) except: sleep(0.2) continue for e in get_entities(local_player): if not e.dormant and e.alive: try: if settings.trigger_bot: Hacks.trigger_bot(local_player, e) if settings.esp_boxes: e.draw_box() if settings.esp_glow: e.glow() e.spotted() e.draw_health() e.draw_distance(local_player) e.draw_weapon() e.draw_name() # e.cham() except Exception as exc: print(f"Entity Error: ({e}) {exc}") events = pygame.event.get() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() break if game_menu.menu.is_enabled(): try: game_menu.draw_menu(events, overlay) except: pass track_game() pygame.display.update() pygame.time.delay(5) except KeyboardInterrupt: break
## win.SetActiveWindow(q) win.ShowWindow(q,2) win.BringWindowToTop(q) win.SetForegroundWindow(q) select = int(input("Enter a number (0 to cancel): "))-1 if select==-1: return pyperclip.copy(data[select]) except Exception as e: print(e) ##print(__name__) ##print(__file__) ##print(sys.executable) keyboard.register_hotkey('Ctrl+c',copy) keyboard.register_hotkey('Ctrl+.',infront) try: while True: continue except Exception as e: print(e)
def down_pressed(): global curr_location curr_location = len(clipboard) - 1 typewrite(clipboard[curr_location]) def left_pressed(): global curr_location sleep(0.2) print "LEFT" curr_location -= 1 if curr_location - 1 != -1 else 0 keyboard.write(clipboard[curr_location]) # typewrite(clipboard[curr_location]) def right_pressed(): global curr_location print "RIGHT" sleep(0.2) curr_location += 1 if curr_location + 1 != len(clipboard) else 0 typewrite(clipboard[curr_location]) keyboard.register_hotkey('ctrl+c', copy_pressed) keyboard.register_hotkey('alt+shift+left', left_pressed) keyboard.register_hotkey('alt+shift+right', right_pressed) keyboard.register_hotkey('alt+shift+down', down_pressed) keyboard.wait()
import keyboard keyboard.register_hotkey("command+f20", lambda: print('>>', flush=True)) keyboard.register_hotkey("command+f19", lambda: print('<<', flush=True)) keyboard.register_hotkey("command+f18", lambda: print('<<', flush=True)) # This doesn't work :( #keyboard.register_hotkey("command+f20", lambda: keyboard.send("ctrl+alt+f1")) #keyboard.register_hotkey("command+f19", lambda: keyboard.send("ctrl+alt+f2")) #keyboard.register_hotkey("command+f18", lambda: keyboard.send("ctrl+alt+f2")) input()
def restart(self): """ Clear keys held and rehook keyboard. """ self.keys_held = set() for keycombo, cb in self.hooks.items(): keyboard.register_hotkey(keycombo, cb)