forked from ultralytics/yolov5
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMain-new.py
68 lines (46 loc) · 1.58 KB
/
Main-new.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import time
from math import *
from decimal import Decimal
from fpsdetect import *
from ctypes import *
from utils.fpsutils import *
import threading
import pyautogui
import win32api
import win32con
from utils.metrics import ConfusionMatrix
is_screen = False
class ScreenThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
global is_screen
while True:
if is_screen is True:
screenShot()
def screenShot():
img = pyautogui.screenshot(region=[0,0,1920,1080])
if __name__ == "__main__":
while True:
try:
img = ScreenShot()
detections = detect(img)
btc = FindBestCenter(detections)
x = btc[0] - ScreenShot_W // 2
y = btc[1] - ScreenShot_H // 2
print(x,y,btc[0],btc[1])
if btc is not None:
is_screen = True
#cod16
# import pydirectinput
# pydirectinput.move(x,y)
#CF,CSGO,
# win32api.keybd_event(17,0,0,0)
# win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,0,0)
# time.sleep(0.2)
win32api.mouse_event(win32con.MOUSEEVENTF_MOVE,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
except:
#print('No detect !')
pass