-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
230 lines (182 loc) · 7.34 KB
/
main.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import imagesearch as i
import pyautogui
import time
from PIL import Image
def search(image,istekler={}):
print(" ╔═══*.·:·.☽✧ ✦ ✧☾.·:·.*═══╗ \n")
settings={
"hassasiyet":0.7,
"hangisiVar":False,
"tersi":False,
#"eminsen":False, #emin değilsen -1,-1
"sinirliSayidaAra":1,
"bulanaKadarAra":False,
"bulanaKadarHiz":0.1,
"hepsiVarsa":False,
"birisiVarsa":True,
"solTikla":False,
"sagTikla":False,
"ortaTikla":False,
"hareketEttir":False,
"hareketHizi":0,
"scrollYap":False,
"scrollMiktari":100,
"ortaNokta":True,
"alanAra":False, #False ise tam ekran
"x1":-1,
"x2":-1,
"y1":-1,
"y2":-1,
"info":False,
}
for istek in istekler:
settings[istek]=istekler[istek]
#print(settings)
# ayar kontrol
if settings["alanAra"]:
if settings["x1"]<0 or settings["x2"]<0 or settings["y1"]<0 or settings["y2"]<0:
raise Exception("Koordinatlar doğru değil!",settings["x1"],settings["x2"],settings["y1"],settings["y2"])
if settings["x1"]-settings["x2"]==0 or settings["y1"]-settings["y2"]==0:
raise Exception("x1-x2=0 veya y1-y2=0 olamaz",settings["x1"],settings["x2"],settings["y1"],settings["y2"])
x1 = settings["x1"]
x2 = settings["x2"]
y1 = settings["y1"]
y2 = settings["y2"]
birisiVarsa = settings["birisiVarsa"]
bulanaKadar = settings["bulanaKadarAra"]
alanAra = settings["alanAra"]
timesample = settings["bulanaKadarHiz"]
precision = settings["hassasiyet"]
solTikla = settings["solTikla"]
sagTikla = settings["sagTikla"]
ortaTikla = settings["ortaTikla"]
hareketEttir = settings["hareketEttir"]
hareketHizi = settings["hareketHizi"]
scrollYap = settings["scrollYap"]
scrollMiktari = settings["scrollMiktari"]
hepsiVarsa=settings["hepsiVarsa"]
tersi=settings["tersi"]
if tersi==True and (solTikla or sagTikla or ortaTikla or hareketEttir or scrollYap):
raise Exception("Tersi özelliği ile her şey kullanılamaz,",solTikla, sagTikla, ortaTikla, hareketEttir, scrollYap)
def eylemYap(x,y):
if solTikla:
pyautogui.click(x, y, button='left', duration=hareketHizi)
if sagTikla:
pyautogui.click(x, y, button='right', duration=hareketHizi)
if ortaTikla:
pyautogui.click(x, y, button='middle', duration=hareketHizi)
if hareketEttir:
pyautogui.moveTo(x, y, hareketHizi)
if scrollYap:
pyautogui.scroll(scrollMiktari, x, y)
def bul(image):
if alanAra==True and bulanaKadar==True:
#x,y = i.imagesearcharea_loop(image,x1,y1,x2,y2, timesample, precision)
x,y = i.imagesearcharea(image,x1,y1,x2,y2, precision)
elif alanAra==True and bulanaKadar==False:
x,y = i.imagesearcharea(image,x1,y1,x2,y2, precision)
elif alanAra==False and bulanaKadar==True:
#x,y = i.imagesearch_loop(image, timesample, precision)
x,y = i.imagesearch(image, precision)
elif alanAra==False and bulanaKadar==False:
x,y = i.imagesearch(image, precision)
print(image,x,y)
if bulanaKadar==False:
#eylemYap(x,y)
return x,y
elif bulanaKadar==True and x!=-1 and y!=-1:
#eylemYap(x,y)
return x,y
def emirVer(adamlar):
if "dict" in str(type(adamlar)):
for adam in adamlar.values():
if adam[0]!=-1 and adam[1]!=-1 and adam!=None:
eylemYap(adam[0],adam[1])
elif "list" in str(type(adamlar)) or "tuple" in str(type(adamlar)):
adamlar=list(adamlar)
if len(adamlar)==2:
eylemYap(adamlar[0],adamlar[1])
#elif "str" in str(type(adamlar)):
# eylemYap(adamlar)
def urlToImg(url):
import urllib.request
#print('Beginning file download with urllib2...')
url = url
urllib.request.urlretrieve(url, 'url.jpg')
def sonAdim(dondurulecek,cevap=""):
if cevap!="":
emirVer(cevap)
return dondurulecek
say=0
cevapDict={}
if "list" in str(type(image)):
for rsm in image:
cevapDict[rsm]=(-1,-1)
while bulanaKadar or say<settings["sinirliSayidaAra"]:
print(cevapDict)
if "list" in str(type(image)):
for img in image:
if "http" in img:
urlToImg(img)
url=img
img="url.jpg"
cevap=bul(img)
cevapDict[url]=cevap
else:
cevap=bul(img)
cevapDict[img]=cevap
#im = cv2.imread(img)
#h, w, c = im.shape
if not hepsiVarsa:
if (not tersi and birisiVarsa and (cevap!=(-1,-1) and cevap!=None)):
print("wdwdw")
return sonAdim((img,cevap),cevap)
elif (tersi and ((cevap==(-1,-1) or cevap==None))):
print("asdasd")
return sonAdim((img,cevap))
if hepsiVarsa:
if tersi and list(cevapDict.values()).count((-1,-1))==len(list(cevapDict.values())): #tersi
print("kkk")
#if not tersi:
# emirVer(cevapDict)
return sonAdim(cevapDict)
elif tersi and list(cevapDict.values()).count(None)==len(list(cevapDict.values())):
print("wooooww")
return sonAdim(cevapDict)
elif (not tersi and not (-1,-1) in list(cevapDict.values())) and not None in list(cevapDict.values()):#normal
print("hahi")
return sonAdim(cevapDict)
elif not bulanaKadar:
print("zazaza")
return sonAdim(cevapDict)
elif "str" in str(type(image)):
#print(image)
if "http" in image:
urlToImg(image)
image="url.jpg"
#im = cv2.imread(image)
#h, w, c = im.shape
cor = bul(image)
if (not bulanaKadar):
print("faaaaa")
return sonAdim({image:cor},cor)
elif (not tersi and bulanaKadar and ((cor!=(-1,-1) and cor!=None))):
print("ggffdgaaaaa")
return sonAdim({image:cor},cor)
elif (tersi and (cor==(-1,-1) or cor==None)):
print("asds4a")
return sonAdim({image:cor},cor)
if bulanaKadar:
time.sleep(timesample)
say+=1
# olmadığını söyle
if "list" in str(type(image)):
cevapDict={}
for rsm in image:
cevapDict[rsm]=(-1,-1)
print("looool")
return cevapDict
elif "str" in str(type(image)):
print("lol")
return {image:(-1,-1)}
print("\n ╚═══*.·:·.☽✧ ✦ ✧☾.·:·.*═══╝ ")