功能更新 添加sleep函数

main
阳光少年 3 months ago
parent 1e08543e56
commit 92eff76239

@ -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()

@ -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)

@ -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

@ -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()

Loading…
Cancel
Save