def start(self): keyboard.wait('esc') mouse.on_click(self.add_mouse_left_click) keyboard.on_press(self.add_keypress) keyboard.wait('esc') mouse.unhook_all() keyboard.unhook_all() saver.save_file(self)
def start_read_keyloggers_callback(self): """ Inicia el callback para contar las teclas pulsadas """ keyboard.hook(self.callback_keyboard) if self.MOUSE_ENABLED: mouse.on_click(self.callback_mouse, ('left', )) mouse.on_right_click(self.callback_mouse, ('right', )) mouse.on_middle_click(self.callback_mouse, ('middle', ))
moving = "\n" + "pyautogui.moveTo(" + str(pos_xy[0]) + "," + str( pos_xy[1]) + ",0.5)" py_pos_src = prnt + moving + "\n" + "pyautogui.click(" + str( pos_xy[0] ) + "," + str( pos_xy[1] ) + ")" + "\n" + "pyautogui.typewrite('*')" + "\n" + "time.sleep(" + str( TIME_SLEEP) + ")" + "\n\n" # 改行コード含む all_py_src = all_py_src + py_pos_src pyperclip.copy(all_py_src) callback = say_hello #左クリック callback2 = say_hello2 #右クリック mouse.on_click(callback) #クリックで関数呼び出し mouse.on_right_click(callback2) #右ボタンで関数呼び出し pyperclip.copy("") # クリップボードクリアー global loop loop = 1 strt_flg = 0 cntr = 0 #クリック、入力の位置にシーケンシャルNO.をつける pyautogui.alert('記録を開始しますか?') #プログラムストップ:OKボタンのクリックを待つ strt_flg = 1 #--------------------------------------------------- if __name__ == '__main__': while (loop): pyautogui.alert( '操作記録を開始しました!!\n終了するにはOKボタンをクリック') # プログラムストップ:OKボタンのクリックを待つ
def runTracker(self): mouse.on_right_click(lambda: self.rightClick()) mouse.on_click(lambda: self.leftClick())
try: randmin = int(randmin) randmax = int(randmax) toggle_hotkey = keyboard.add_hotkey(hotkey, toggle_grumby) except: messagebox.showerror( "MOYORAL RESERVOIR ERROR", "There was an error loading settings. All settings were reset to default" ) saveFile = open('../config/hotkey.txt', "w") saveFile.write("ctrl+g\n1\n9\nFalse") saveFile.close() toggle_hotkey = keyboard.add_hotkey(hotkey, toggle_grumby) # Calls the press_random_num_key function for every mouse click. The function does nothing if Grumby is deactivated, but it is called every mouse click if grumby is open mouse.on_click(press_random_num_key) ########## - Create the GUI - ########## # Create window window = Tk() window.title("Grumby v0.1") window.geometry('407x308') window.resizable(width=False, height=False) # Set the default background style = Style() change_background("deactivated") # Create the frame used in the settings mainFrame = Frame(window) hotkeyFrame = Frame(mainFrame, style='TFrame')
# presses but doesn't release mouse.hold('left') # mouse.press('left') # drag from (0, 0) to (100, 100) relatively with a duration of 0.1s mouse.drag(0, 0, 100, 100, absolute=False, duration=0.1) # whether a button is clicked print(mouse.is_pressed('right')) # move 100 right & 100 down mouse.move(100, 100, absolute=False, duration=0.2) # make a listener when left button is clicked mouse.on_click(lambda: print("Left Button clicked.")) # make a listener when right button is clicked mouse.on_right_click(lambda: print("Right Button clicked.")) # remove the listeners when you want mouse.unhook_all() # scroll down mouse.wheel(-1) # scroll up mouse.wheel(1) # record until you click right events = mouse.record()
def __init__(self): self.logger = logging.getLogger(__name__) self.click_delay = 0.5 mouse.on_click(self.report_position, args=())
def run(self): self.logger.debug("MouseClickTrigger started") mouse.on_click(self.on_click)
"""Mouse to Keypress This very short script converts from a mouse click to a keypress (down & up) of the 'Space' key. """ import keyboard import mouse def pressKey(): keyboard.send('space') mouse.on_click(pressKey) keyboard.wait()
for curr_id, monitor in enumerate(monitors): _centroid_x = (monitor[0] + monitor[0] + 1920) / 2.0 _centroid_y = (monitor[1] + monitor[1] + 1080) / 2.0 dist = (x - _centroid_x)**2 + (y - _centroid_y)**2 if dist < min_dist: min_dist = dist _monitor_id = curr_id return _monitor_id, _win_handle, _rect def mouse_click_callback(): global prev_active_win_name interrupt_wait.set() mouse.on_click(mouse_click_callback, args=()) while True: interrupt_wait.wait(check_interval) interrupt_wait.clear() active_win_name = win32gui.GetWindowText( win32gui.GetForegroundWindow()) print('active_win_name: {}'.format(active_win_name)) # (prev_active_win_name is None or prev_active_win_name != active_win_name) if active_win_name not in (win_name, win_name2): prev_active_win_name = active_win_name _monitor_id, _win_handle, rect = getMonitorID(active_win_name) monitor_id, win_handle, _ = getMonitorID(win_name)
import pyautogui import time from repair_mini_game import * import keyboard import mouse from window_input import Window, Key top_strike_point = (787, 420) bot_strike_point = (787, 648) def show_pixels(*args): px = pyautogui.position() print(px) print(pyscreeze.pixel(px[0], px[1])) if __name__ == "__main__": mouse.on_click(show_pixels) keyboard.on_press_key("`", show_pixels) while True: pass
import sys, os sys.path.insert(0, os.path.abspath('..')) from webcam_utils.webcam import init_webcam, save_image import mouse from windows.cursor import queryMousePosition from utils.constants import * def on_click_event(cam): img_path = save_image(cam) posX, posY = queryMousePosition() with open(TRAIN_INDEX_PATH, 'a') as f: f.write("{0} {1} {2}\n".format(img_path, posX, posY)) print("Got pic -- {0} X: {1} Y: {2}".format(img_path, posX, posY)) if __name__ == "__main__": try: cam = init_webcam() print("before") mouse.on_click(on_click_event, [cam]) print("Registered smth") input() finally: mouse.unhook_all()
def onBtnClick(self, e): self.btn.SetLabel("Click A") mouse.on_click(lambda: self.onMouseClick()) self.cont_mouse = 0
def record(self): self.init_log() mouse.on_click(self.click) keyboard.add_hotkey('F2', lambda: self.f2()) keyboard.add_hotkey('ESC', lambda: self.esc()) keyboard.wait()