From 16e83a104a72a2f257d6ff63dee3c5fc06dd5ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Formanek=20Bal=C3=A1zs=20Istv=C3=A1n?= <formanek.balazs.istvan@itk.ppke.hu> Date: Sun, 13 Oct 2024 22:01:37 +0200 Subject: [PATCH] sprint #1 --- moni_dev/move_mouse.py | 27 +++++++++++++++++ moni_dev/test_manipulations.py | 16 ++++++++++ moni_dev/use_keyboard.py | 54 ++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 moni_dev/move_mouse.py create mode 100644 moni_dev/test_manipulations.py create mode 100644 moni_dev/use_keyboard.py diff --git a/moni_dev/move_mouse.py b/moni_dev/move_mouse.py new file mode 100644 index 0000000..38fff76 --- /dev/null +++ b/moni_dev/move_mouse.py @@ -0,0 +1,27 @@ +import pyautogui +import keyboard +import time + +# Function to move the mouse in the specified direction +def move_mouse(move_distance = 10, time_checking = 0.005, scroll_distance = 5): + while True: + if keyboard.is_pressed('W'): + pyautogui.move(0, -move_distance) # Move up + elif keyboard.is_pressed('S'): + pyautogui.move(0, move_distance) # Move down + elif keyboard.is_pressed('A'): + pyautogui.move(-move_distance, 0) # Move r + elif keyboard.is_pressed('D'): + pyautogui.move(move_distance, 0) # Move right + + elif keyboard.is_pressed('L'): + pyautogui.click() # Left click + elif keyboard.is_pressed('R'): + pyautogui.click(button='right') # Right click + + elif keyboard.is_pressed('up'): + pyautogui.scroll(scroll_distance) # Scroll upp + elif keyboard.is_pressed('down'): + pyautogui.scroll(-scroll_distance) # Scroll down + + time.sleep(time_checking) # Adjust speed of movement \ No newline at end of file diff --git a/moni_dev/test_manipulations.py b/moni_dev/test_manipulations.py new file mode 100644 index 0000000..5ea7024 --- /dev/null +++ b/moni_dev/test_manipulations.py @@ -0,0 +1,16 @@ +import pyautogui +import keyboard +import time +from move_mouse import move_mouse +from use_keyboard import press_button + +# Start listening for key presses +if __name__ == "__main__": + print("Use the arrow keys to move the mouse. Press 'Esc' to exit.") + + # Exit the program when 'Esc' is pressed + try: + while not keyboard.is_pressed('esc'): + press_button() + except: + print("Program terminated.") \ No newline at end of file diff --git a/moni_dev/use_keyboard.py b/moni_dev/use_keyboard.py new file mode 100644 index 0000000..2f0d25e --- /dev/null +++ b/moni_dev/use_keyboard.py @@ -0,0 +1,54 @@ +import pyautogui +import keyboard +import time + +# Function to move the mouse in the specified direction +def press_button(time_checking = 0.005): + shift_held = False + control_held = False + + while not keyboard.is_pressed('esc'): + if keyboard.is_pressed('W'): + pyautogui.press('up') + elif keyboard.is_pressed('S'): + pyautogui.press('down') # Move down + elif keyboard.is_pressed('A'): + pyautogui.press('right') # Move r + elif keyboard.is_pressed('D'): + pyautogui.press('left') # Move right + + elif keyboard.is_pressed('O'): + pyautogui.press('enter') + elif keyboard.is_pressed('P'): + pyautogui.press('space') + + + if keyboard.is_pressed('M'): + if not control_held: + pyautogui.keyDown('ctrl') + control_held = True + print("PRESSED CTRL") + elif keyboard.is_pressed('N'): + if control_held: + pyautogui.keyUp('ctrl') + control_held = False + print("released CTRL") + + if keyboard.is_pressed('B'): + if not shift_held: + pyautogui.keyDown('shift') + shift_held = True + print("PRESSED shift") + elif keyboard.is_pressed('V'): + if shift_held: + pyautogui.keyUp('shift') + shift_held = False + print("released shift") + + if keyboard.is_pressed('E'): + pyautogui.press('esc') + print("esc pressed") + + + time.sleep(time_checking) # Adjust speed of movement + \ No newline at end of file -- GitLab