This repository has been archived by the owner on Jan 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tilesbot.py
130 lines (99 loc) · 3.91 KB
/
tilesbot.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/python3
import random
import mss
import mss.tools
import threading
import time
from pynput import mouse,keyboard
from pynput.mouse import Controller, Button
mouse = Controller()
def mainFunc(timeDelay):
global monitor
offset=monitor["height"]-10
sct_img = sct.grab(monitor)
if sct_img.pixel(int(monitor["width"]/4),int(monitor["height"]/10))[0] <10:
mouse.position = (int(monitor["width"]/8) +int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset)
time.sleep(1)
mouse.click(Button.left)
elif sct_img.pixel(int(monitor["width"]/4*3),int(monitor["height"]/10))[0]<10:
mouse.position = (int(monitor["width"]/8*3) +int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset)
time.sleep(1)
mouse.click(Button.left)
elif sct_img.pixel(int(monitor["width"]/4*5),int(monitor["height"]/10))[0]<10:
mouse.position = (int(monitor["width"]/8*5) +int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset)
time.sleep(1)
mouse.click(Button.left)
elif sct_img.pixel(int(monitor["width"]/4*7),int(monitor["height"]/10))[0]<10:
mouse.position = (int(monitor["width"]/8*7) +int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset)
time.sleep(1)
mouse.click(Button.left)
while True:
if a:
break
sct_img = sct.grab(monitor)
if sct_img.pixel(int(monitor["width"]/4),int(monitor["height"]/10))[0]<10:
mouse.position = (int(monitor["width"]/8) +int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset)
mouse.click(Button.left)
elif sct_img.pixel(int(monitor["width"]/4*3),int(monitor["height"]/10))[0]<10:
mouse.position = (int(monitor["width"]/8*3)+int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset)
mouse.click(Button.left)
elif sct_img.pixel(int(monitor["width"]/4*5),int(monitor["height"]/10))[0]<10:
mouse.position = (int(monitor["width"]/8*5)+int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset)
mouse.click(Button.left)
elif sct_img.pixel(int(monitor["width"]/4*7),int(monitor["height"]/10))[0]<10:
mouse.position = (int(monitor["width"]/8*7)+int(monitor["left"]),int(monitor["height"]/10)+monitor["top"]+offset )
mouse.click(Button.left)
a=False
pos1 = (0,0)
pos2 = (0,0)
def on_press(key):
global offset
if key == keyboard.Key.space:
global pos1
global pos2
if pos1 ==(0,0):
pos1 = mouse.position
print("Position 1 = "+str(mouse.position))
elif pos2 ==(0,0):
pos2 = mouse.position
print("Position 2 = "+str(mouse.position))
if key == keyboard.Key.shift_r and offset+5<monitor["height"]:
offset+=5
print(offset)
if key == keyboard.Key.shift and offset-5> 0:
offset-=5
print(offset)
def on_release(key):
global a
if key == keyboard.Key.esc:
a=True
return False
listener = keyboard.Listener(
on_press=on_press,
on_release=on_release)
listener.start()
def listen():
listener.join()
threading.Thread(target=listen).start()
print("\nPress SPACE to select the boundaries\n\n1. Top Left\n2. Bottom Right\n")
while pos2==(0,0):
pass
with mss.mss() as sct:
# The screen part to capture
monitor = {"top": pos1[1], "left": pos1[0], "width": (pos2[0]-pos1[0]), "height": (pos2[1]-pos1[1])}
output = "sct-{top}x{left}_{width}x{height}.png".format(**monitor)
time.sleep(1)
print("\nPress ESC to exit\n ")
time.sleep(1)
print("Starting in 5")
time.sleep(1)
print("Starting in 4")
time.sleep(1)
print("Starting in 3")
time.sleep(1)
print("Starting in 2")
time.sleep(1)
print("Starting in 1")
time.sleep(1)
print(".......")
mainFunc(0)