added fishy move and updated readme

This commit is contained in:
ADAM-PC\adam_ 2018-08-05 20:14:49 +05:30
parent 5a73792eba
commit 94cb039c90
9 changed files with 497 additions and 2 deletions

View File

@ -1,2 +1,15 @@
# fishyboteso
Fishing bot for Elder Scrolls Online made using tensorflow and python
### fishyboteso
Auto fishing bot for Elder Scrolls Online. The Bot automatically fishes till the fishing hole disappears then it sends notification of to the users phone including the statistics of that fishing hole.
### Demo Video
<div align="center">
<a href="https://www.youtube.com/watch?v=E4Y9BFhCICI"><img src="https://img.youtube.com/vi/E4Y9BFhCICI/0.jpg" alt="IMAGE ALT TEXT"></a>
</div>
### Technology Stack
- Python
- Tensorflow
- cv2
- docopt
- numpy
- pyautogui

0
fishy_move/NewRecord.py Normal file
View File

117
fishy_move/Utils.py Normal file
View File

@ -0,0 +1,117 @@
from PIL import ImageGrab, Image
import cv2
import pytesseract
import numpy as np
from pynput.keyboard import Key, Controller, Listener
import json
import _thread
import time
def getSizeFromConfig():
config = json.load(open("config.json"))
return config["box"]["x"],config["box"]["y"],config["box"]["w"],config["box"]["h"]
def process_img(screen):
img = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
return img
def getValuesFromImage(cvImg):
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract.exe'
tessdata_dir_config = '--tessdata-dir "C:/Program Files (x86)/Tesseract-OCR/" -c tessedit_char_whitelist=0123456789.'
img = (255 - cvImg)
img = Image.fromarray(img)
text = pytesseract.image_to_string(img, lang="eng", config=tessdata_dir_config)
text.replace(" ","")
print(text)
#cv2.imshow('gray_image', img)
vals = text.split("\n")
try:
return float(vals[0]), float(vals[1]), float(vals[2])
except Exception:
time.sleep(0.5)
return getValues()
#1
def getValues():
keyboard = Controller()
keyboard.press(Key.enter)
keyboard.type("/getcoords")
keyboard.press(Key.enter)
time.sleep(0.5)
screen = np.array(ImageGrab.grab())
screen = screen[y:y + h, x:x + w]
new_screen = process_img(screen)
#cv2.imshow('window', new_screen)
i,j,a = getValuesFromImage(new_screen)
#print(str(i)+" "+str(j)+" "+str(a))
return x,y,a
def configureValuesBox():
_thread.start_new_thread(changeSizeFromConsole, ())
screen = np.array(ImageGrab.grab())
print(str(screen.shape[1])+"x"+str(screen.shape[0]))
print(str(x)+" "+str(y)+" "+str(w)+" "+str(h))
while True:
screen = np.array(ImageGrab.grab())
screen = screen[y:y+h, x:x+w]
new_screen = cv2.cvtColor(screen, cv2.COLOR_BGR2RGB)
cv2.imshow('window', new_screen)
k = cv2.waitKey(25) & 0xFF
if k == ord('q') or k == ord('Q'):
updateBoxInConfig()
cv2.destroyAllWindows()
break
def updateBoxInConfig():
global x,y,w,h
with open("config.json", "r") as jsonFile:
data = json.load(jsonFile)
data["box"]["x"] = x
data["box"]["y"] = y
data["box"]["w"] = w
data["box"]["h"] = h
with open("config.json", "w") as jsonFile:
json.dump(data, jsonFile)
def changeSizeFromConsole():
global x, y, w, h
while True:
sizeValsStr = input()
sizeVals = sizeValsStr.split(" ")
x,y,w,h = int(sizeVals[0]),int(sizeVals[1]),int(sizeVals[2]),int(sizeVals[3])
x,y,w,h = getSizeFromConfig()
def on_release(key):
if key == Key.f9:
getValues()
with Listener(
on_release=on_release) as listener:
listener.join()
# configureValuesBox()

View File

@ -0,0 +1,23 @@
from pynput.keyboard import Key, Listener
from pynput.mouse import Button, Controller
mouse = Controller()
moveValue =80
def on_press(key):
if key == Key.up:
mouse.move(0,-moveValue)
elif key == Key.down:
mouse.move(0,moveValue)
elif key == Key.left:
mouse.move(-moveValue,0)
elif key == Key.right:
mouse.move(moveValue,0)
# Collect events until released
with Listener(
on_press=on_press,
) as listener:
listener.join()

1
fishy_move/config.json Normal file
View File

@ -0,0 +1 @@
{"box": {"x": 20, "y": 747, "w": 100, "h": 100}}

62
fishy_move/execute.py Normal file
View File

@ -0,0 +1,62 @@
import pynput
import time
from threading import Timer
offsetTime = 3.0
fo = open("record.txt", "r")
keys = {"w":'w', "a":'a', "s":'s', "d":'d', "space":pynput.keyboard.Key.space, "up":pynput.keyboard.Key.up, "down":pynput.keyboard.Key.down, "left":pynput.keyboard.Key.left, "right":pynput.keyboard.Key.right}
recordList = []
keyboard = pynput.keyboard.Controller()
mouse = pynput.mouse.Controller()
class Record:
def __init__(self, c, dt, ut):
self.char = c
self.downTime = dt
self.upTime = ut
self.obj = keys[c]
def shedule(self):
Timer(offsetTime+self.downTime, keyboard.press, [self.obj]).start()
Timer(offsetTime+self.upTime, keyboard.release, [self.obj]).start()
def __str__(self):
return "press "+self.char+" from "+str(self.downTime)+ " to "+str(self.upTime)
def moveMouse(x,y):
mouse.position = (x,y)
def sheduleMouse(x,y,t):
Timer(offsetTime+t, moveMouse, [x,y]).start()
strInst = fo.read()
instList = strInst.split("\n")
for i in instList:
if i == "":
break
instParts = i.split(":")
if instParts[0] == "mouse" :
sheduleMouse(int(instParts[1]),int(instParts[2]),float(instParts[3]))
else:
recordList.append(Record(instParts[0], float(instParts[1]), float(instParts[2])))
for i in recordList:
i.shedule()
Timer(offsetTime, print, ["gooooooooooo!!!!"]).start()
fo.close()

97
fishy_move/record.py Normal file
View File

@ -0,0 +1,97 @@
from pynput import keyboard, mouse
import time
fo = open("record.txt", "w")
initTime = time.time()
class Key:
pressed = False
downTime = 0.0
upTime = 0.0
def __init__(self, c):
#print(str(c)+" created")
self.char = c
def startTimer(self):
self.downTime = time.time() - initTime
self.pressed = True
def stopTimer(self):
self.upTime = time.time() - initTime
self.pressed = False
field = self.char+":"+str(self.downTime)+":"+str(self.upTime)
fo.write(field+"\n")
return field
w = Key('w')
a = Key('a')
s = Key('s')
d = Key('d')
e = Key('e')
space = Key("space")
up = Key('up')
down = Key("down")
left = Key("left")
right = Key("right")
keys = {'w':w, 'a':a, 's':s, 'd':d, 'e':e, keyboard.Key.space:space, keyboard.Key.up:up, keyboard.Key.down:down, keyboard.Key.left:left, keyboard.Key.right:right}
def on_press(key):
try:
i = keys.get(key.char, None)
if i is not None and not i.pressed:
i.startTimer()
except AttributeError:
i = keys.get(key, None)
if i is not None and not i.pressed:
i.startTimer()
def on_move(x, y):
field = "mouse:"+str(x)+":"+str(y)+":"+str(time.time() - initTime)
#print(field)
fo.write(field+"\n")
def on_release(key):
## print('{0} released'.format(
## key))
try:
i = keys.get(key.char, None)
if i is not None and i.pressed:
print(str(i.stopTimer()))
except AttributeError:
i = keys.get(key, None)
if i is not None and i.pressed:
print(str(i.stopTimer()))
if key == keyboard.Key.ctrl_r:
# Stop listener
return False
input("Press Enter when ready...")
print("get ready")
time.sleep(3)
print("goooooooo!!!!")
with keyboard.Listener(on_press=on_press,on_release=on_release) as listener:
with mouse.Listener(on_move=on_move) as listener2:
listener.join()
# Collect events until released
fo.close()

175
fishy_move/record.txt Normal file
View File

@ -0,0 +1,175 @@
left:146.9617018699646:147.29516649246216
left:147.36071157455444:147.4603865146637
left:147.5449104309082:147.61167883872986
left:147.71089577674866:147.7939555644989
left:147.87733817100525:147.96011018753052
left:148.04392194747925:148.1439971923828
left:148.22690057754517:148.3100986480713
left:148.3941605091095:148.4941704273224
left:148.57644939422607:148.66000938415527
left:148.7606327533722:148.84273552894592
left:148.9427671432495:149.0263752937317
left:149.1263313293457:149.20888924598694
left:149.30911946296692:149.3917145729065
left:149.4926598072052:149.57478857040405
left:149.65938448905945:149.74205899238586
left:149.8421881198883:149.92574548721313
left:150.0083041191101:150.10837817192078
left:150.20784783363342:150.2914502620697
left:150.3923807144165:150.47448062896729
left:150.57460284233093:150.67428588867188
left:150.75763297080994:150.8572337627411
left:150.9407889842987:151.04086232185364
left:151.140930891037:151.22401595115662
left:151.32458806037903:151.406644821167
left:151.507257938385:151.5904746055603
left:151.67375946044922:151.77364420890808
left:151.85673809051514:151.93929958343506
left:152.03987073898315:152.14044070243835
left:152.222998380661:152.32256770133972
left:152.42330265045166:152.50608468055725
left:152.5889995098114:152.68887758255005
left:152.78921008110046:152.87196969985962
left:152.9885504245758:153.05509519577026
left:153.15516781806946:153.2387251853943
left:153.33799409866333:153.42138290405273
left:153.53841924667358:153.62172770500183
left:153.72180104255676:153.80435824394226
left:153.92094159126282:154.0050060749054
left:154.10508036613464:154.2041676044464
left:154.30473971366882:154.38682460784912
left:154.48739671707153:154.5701720714569
left:154.67041945457458:154.75325417518616
left:154.8538634777069:154.95346117019653
left:155.05303168296814:155.1361207962036
left:155.23618865013123:155.31927680969238
left:155.4025959968567:155.5191833972931
left:155.58572936058044:155.6692886352539
left:155.769859790802:155.85266995429993
left:155.9687943458557:156.0520601272583
left:156.15213131904602:156.25127410888672
left:156.31862688064575:156.418194770813
left:156.50175404548645:156.61833500862122
left:156.68438076972961:156.7843415737152
left:156.86771535873413:156.9677894115448
left:157.06785774230957:157.1677656173706
left:157.25114965438843:157.35122060775757
left:157.43478059768677:157.5506329536438
left:157.61735248565674:157.71695160865784
left:157.80051136016846:157.90056324005127
left:158.21680068969727:158.33205366134644
w:158.89988780021667:162.34624099731445
left:162.99560737609863:163.1113736629486
left:163.17844080924988:163.2786409854889
left:163.32827472686768:163.4108316898346
left:163.51110100746155:163.61117148399353
left:163.69473481178284:163.7782917022705
left:163.86135005950928:163.9604208469391
left:164.02752256393433:164.12759494781494
left:164.2106533050537:164.32723760604858
left:164.39328241348267:164.49389457702637
left:164.577166557312:164.66074395179749
left:164.74330496788025:164.84279608726501
left:164.92703700065613:164.99368238449097
left:165.0764617919922:165.1765329837799
left:165.2595911026001:165.34264969825745
left:165.44322037696838:165.54279851913452
left:165.60884618759155:165.70893263816833
left:165.79199123382568:165.89256238937378
left:165.97512030601501:166.09240674972534
left:166.17532801628113:166.27513122558594
left:166.35822367668152:166.44079852104187
left:166.52493238449097:166.62423491477966
left:166.70829439163208:166.77434134483337
w:167.17482137680054:170.87045073509216
left:171.18750643730164:171.2865777015686
left:171.36930108070374:171.45358538627625
left:171.55315494537354:171.63571500778198
left:171.7362847328186:171.80258989334106
left:171.8857123851776:171.96874618530273
left:172.06915402412415:172.15255451202393
left:172.25312495231628:172.33619022369385
left:172.41874289512634:172.4859538078308
left:172.58549308776855:172.66805219650269
left:172.75161051750183:172.83466911315918
left:173.11816310882568:173.21773386001587
left:173.3178038597107:173.41733932495117
left:173.50120878219604:173.6006371974945
left:173.6677050590515:173.7674958705902
w:174.00035619735718:176.61318016052246
right:176.71426653862:176.83184957504272
right:176.89789533615112:176.98095512390137
right:177.04702305793762:177.1313054561615
right:177.21382427215576:177.29692006111145
right:177.38051438331604:177.48014163970947
right:177.54663228988647:177.6472408771515
right:177.69678735733032:177.7973997592926
right:177.87998366355896:177.9639766216278
right:178.02925062179565:178.12982487678528
right:178.19586825370789:178.31295228004456
right:178.39601135253906:178.47906970977783
right:178.54557085037231:178.64596962928772
right:178.7129430770874:178.79550313949585
right:178.89566564559937:178.97837114334106
right:179.06261539459229:179.12894368171692
right:179.21170592308044:179.29495358467102
right:179.37903928756714:179.47794842720032
right:179.5447211265564:179.628399848938
right:179.7109568119049:179.79453897476196
right:179.8778624534607:179.94440960884094
right:180.04447960853577:180.12703800201416
right:180.2106111049652:180.32757115364075
right:180.39364075660706:180.47697186470032
w:180.72716188430786:182.02826380729675
left:182.04477620124817:182.15835523605347
left:182.2254023551941:182.32497358322144
left:182.39171075820923:182.49147176742554
left:182.55801820755005:182.65810823440552
left:182.72515630722046:182.82572674751282
left:182.90853786468506:182.9910957813263
left:183.0741708278656:183.17402577400208
left:183.24108409881592:183.35760140419006
left:183.4406614303589:183.54073429107666
left:183.60727882385254:183.70700240135193
left:183.7905502319336:183.89015007019043
left:183.97421026229858:184.05665922164917
left:184.13986372947693:184.24000310897827
left:184.3230926990509:184.42316317558289
left:184.5067219734192:184.5893852710724
left:184.6726474761963:184.7727165222168
left:184.85577654838562:184.9560739994049
left:185.0401005744934:185.13967084884644
left:185.2232301235199:185.3385956287384
w:185.67186331748962:186.4060401916504
w:186.7870271205902:186.878112077713
right:187.38669800758362:187.48634362220764
right:187.5704047679901:187.63644981384277
right:187.73652029037476:187.7860550880432
right:188.06925582885742:188.11879229545593
right:188.23546719551086:188.28541493415833
right:188.37212705612183:188.45314002037048
right:188.53619980812073:188.61875820159912
right:188.70231819152832:188.81830024719238
right:188.885404586792:188.98504900932312
right:189.05159640312195:189.15166902542114
right:189.23522782325745:189.31778478622437
right:189.41835594177246:189.51741790771484
right:189.61815762519836:189.6845302581787
right:189.76759099960327:189.90023493766785
right:189.9672145843506:190.03328132629395
right:190.116863489151:190.2344036102295
right:190.31747817993164:190.3835380077362
right:190.48434209823608:190.55022501945496
right:190.65040016174316:190.71746230125427
right:191.1167562007904:191.2158272266388
w:192.0651626586914:193.99642205238342
left:194.246595621109:194.3631784915924
left:194.42922520637512:194.52929520606995
left:194.61235666275024:194.71341681480408
left:194.79547309875488:194.89604711532593
left:194.96209454536438:195.07867312431335
left:195.14572048187256:195.26167178153992
w:196.34482789039612:196.90655064582825
down:197.5431363582611:197.64255261421204
down:197.79238176345825:197.90874576568604
down:202.137699842453:202.22125792503357

View File

@ -0,0 +1,7 @@
tesseract windows
pytesseract
eso addon
custom mapcoords
pchats
increase chat size