diff --git a/dealy.py b/dealy.py new file mode 100644 index 0000000..5902601 --- /dev/null +++ b/dealy.py @@ -0,0 +1,22 @@ +import time + + +def delay(us): + end_time = time.perf_counter_ns() + us * 1000 + while time.perf_counter_ns() < end_time: + print("", end="") + + +if __name__ == '__main__': + import threading + + def test(): + time.sleep(1) + print("hello") + + def test_2(): + delay(1000 * 1000 * 10) + + threading.Thread(target=test).start() + threading.Thread(target=test_2).start() + diff --git a/lol_script/main.py b/lol_script/main.py index ba86e06..ece8617 100644 --- a/lol_script/main.py +++ b/lol_script/main.py @@ -70,7 +70,8 @@ if __name__ == '__main__': upper_gray = np.array([120, 120, 120]) while True: tmp_pos_lis = [] - now_screen = screen_shot_mss(2200, 900, 180, 90) + # now_screen = screen_shot_mss(2200, 900, 180, 90) + now_screen = screen_shot_mss(2200, 900, 0, 0) mask = cv2.inRange(now_screen, lower_gray, upper_gray) contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) diff --git a/lol_script/test_mouse.py b/lol_script/test_mouse.py new file mode 100644 index 0000000..7ca6071 --- /dev/null +++ b/lol_script/test_mouse.py @@ -0,0 +1,15 @@ +import time +from dealy import delay +from mouse.logitech import Logitech +from poe.start import get_start + +while True: + delay(10) + if get_start(): + st = time.time() + for _ in range(300): + delay(100) + Logitech.mouse.move(1, 1) + print(int((time.time() - st) * 1000), " ms") + + break \ No newline at end of file diff --git a/poe/start.py b/poe/start.py index fba88c1..6f7602a 100644 --- a/poe/start.py +++ b/poe/start.py @@ -1,4 +1,6 @@ import threading + +import winsound from pynput import keyboard IS_START = False @@ -13,9 +15,13 @@ def listener_keyword(): if key.char == "=": IS_START = not IS_START print(f"IS_START: {IS_START}") + if IS_START: + winsound.Beep(800, 200) + else: + winsound.Beep(400, 200) except AttributeError: pass with keyboard.Listener(on_press=on_press) as listener: listener.join() -threading.Thread(target=listener_keyword).start() +threading.Thread(target=listener_keyword, daemon=True).start()