-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
183 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
infi.systray==0.1.11 | ||
numpy==1.16.4 | ||
opencv-python==4.1.0.25 | ||
Pillow==6.0.0 | ||
PyAutoGUI==0.9.44 | ||
PyGetWindow==0.0.5 | ||
PyMsgBox==1.0.6 | ||
pypiwin32==223 | ||
PyRect==0.1.4 | ||
PyScreeze==0.1.21 | ||
PyTweening==1.0.3 | ||
pywin32==224 | ||
win10toast==0.9 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,147 @@ | ||
from PIL import ImageGrab | ||
import pyautogui | ||
# -*- coding: utf-8 -*- | ||
import webbrowser | ||
import sys | ||
import os | ||
import struct | ||
import time | ||
# | ||
import pyautogui | ||
import numpy as np | ||
import cv2 | ||
import sys | ||
# | ||
from win10toast import ToastNotifier | ||
from PIL import ImageGrab | ||
from win32gui import GetWindowText, GetForegroundWindow, GetWindowRect | ||
from PyQt5 import QtGui, QtCore, QtWidgets | ||
|
||
|
||
class FishBotTray(QtCore.QThread): | ||
|
||
def __init__(self, icon): | ||
QtCore.QThread.__init__(self) | ||
self.icon = icon | ||
# vars | ||
self.flag_exit = True | ||
self.lastx = 0 | ||
self.lasty = 0 | ||
self.is_block = False | ||
self.is_stop = False | ||
self.new_cast_time = 0 | ||
self.recast_time = 40 | ||
|
||
def run(self): | ||
self.icon.showMessage('wow-fish-bot by YECHEZ', 'BOT is READY!\ngithub.com/YECHEZ/wow-fish-bot') | ||
while self.flag_exit: | ||
if GetWindowText(GetForegroundWindow()) != 'World of Warcraft': | ||
self.icon.setToolTip('World of Warcraft no active window !') | ||
#print('World of Warcraft no active window !') | ||
#print('-- New check 2 sec') | ||
from threading import Thread | ||
from infi.systray import SysTrayIcon | ||
|
||
|
||
def resource_path(relative_path): | ||
if hasattr(sys, "_MEIPASS"): | ||
base_path = sys._MEIPASS | ||
else: | ||
base_path = os.path.abspath(".") | ||
return os.path.join(base_path, relative_path) | ||
|
||
def app_pause(systray): | ||
global is_stop | ||
is_stop = False if is_stop is True else True | ||
# print ("Is Pause: " + str(is_stop)) | ||
if is_stop is True: | ||
systray.update( | ||
hover_text=app + " - On Pause") | ||
else: | ||
systray.update( | ||
hover_text=app) | ||
|
||
def app_destroy(systray): | ||
# print("Exit app") | ||
sys.exit() | ||
|
||
def app_about(systray): | ||
# print("github.com/YECHEZ/wow-fish-bot") | ||
webbrowser.open('https://github.com/YECHEZ/wow-fish-bot') | ||
|
||
if __name__ == "__main__": | ||
is_stop = True | ||
flag_exit = False | ||
lastx = 0 | ||
lasty = 0 | ||
is_block = False | ||
new_cast_time = 0 | ||
recast_time = 40 | ||
wait_mes = 0 | ||
app = "WoW Fish BOT by YECHEZ" | ||
link = "github.com/YECHEZ/wow-fish-bot" | ||
app_ico = resource_path('wow-fish-bot.ico') | ||
menu_options = (("Start/Stop", None, app_pause), | ||
(link, None, app_about),) | ||
systray = SysTrayIcon(app_ico, app, | ||
menu_options, on_quit=app_destroy) | ||
systray.start() | ||
toaster = ToastNotifier() | ||
toaster.show_toast(app, | ||
link, | ||
icon_path=app_ico, | ||
duration=5) | ||
while flag_exit is False: | ||
if is_stop == False: | ||
if GetWindowText(GetForegroundWindow()) != "World of Warcraft": | ||
if wait_mes == 5: | ||
wait_mes = 0 | ||
toaster.show_toast(app, | ||
"Waiting for World of Warcraft" | ||
+ " as active window", | ||
icon_path='wow-fish-bot.ico', | ||
duration=5) | ||
# print("Waiting for World of Warcraft as active window") | ||
systray.update( | ||
hover_text=app | ||
+ " - Waiting for World of Warcraft as active window") | ||
wait_mes += 1 | ||
time.sleep(2) | ||
else: | ||
systray.update(hover_text=app) | ||
rect = GetWindowRect(GetForegroundWindow()) | ||
if self.is_stop == False: | ||
if self.is_block == False: | ||
self.lastx = 0 | ||
self.lasty = 0 | ||
pyautogui.press('1') | ||
#print("Fish on !") | ||
self.icon.setToolTip("Fish on !") | ||
self.new_cast_time = time.time() | ||
self.is_block = True | ||
time.sleep(2) | ||
else: | ||
fish_area = (0, rect[3] / 2, rect[2], rect[3]) | ||
|
||
img = ImageGrab.grab(fish_area) | ||
img_np = np.array(img) | ||
|
||
frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB) | ||
frame_hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) | ||
|
||
h_min = np.array((0, 0, 253), np.uint8) | ||
h_max = np.array((255, 0, 255), np.uint8) | ||
|
||
mask = cv2.inRange(frame_hsv, h_min, h_max) | ||
|
||
moments = cv2.moments(mask, 1) | ||
dM01 = moments['m01'] | ||
dM10 = moments['m10'] | ||
dArea = moments['m00'] | ||
|
||
b_x = 0 | ||
b_y = 0 | ||
|
||
if dArea > 0: | ||
b_x = int(dM10 / dArea) | ||
b_y = int(dM01 / dArea) | ||
if self.lastx > 0 and self.lasty > 0: | ||
if self.lastx != b_x and self.lasty != b_y: | ||
self.is_block = False | ||
if b_x < 1: b_x = self.lastx | ||
if b_y < 1: b_y = self.lasty | ||
pyautogui.moveTo(b_x, b_y + fish_area[1], 0.3) | ||
pyautogui.keyDown("shiftleft") | ||
pyautogui.mouseDown(button='right') | ||
pyautogui.mouseUp(button='right') | ||
pyautogui.keyUp("shiftleft") | ||
#print("Catch !") | ||
self.icon.setToolTip("Catch !") | ||
time.sleep(5) | ||
self.lastx = b_x | ||
self.lasty = b_y | ||
|
||
# cv2.imshow("fish_mask", mask) | ||
# cv2.imshow("fish_frame", frame) | ||
|
||
if time.time() - self.new_cast_time > self.recast_time: | ||
#print(time.time(), self.new_cast_time) | ||
#print("New cast if something wrong") | ||
self.icon.setToolTip("New cast if something wrong") | ||
self.is_block = False | ||
|
||
if is_block == False: | ||
lastx = 0 | ||
lasty = 0 | ||
pyautogui.press('1') | ||
# print("Fish on !") | ||
new_cast_time = time.time() | ||
is_block = True | ||
time.sleep(2) | ||
else: | ||
#print("Pause") | ||
self.icon.setToolTip("Pause") | ||
fish_area = (0, rect[3] / 2, rect[2], rect[3]) | ||
|
||
img = ImageGrab.grab(fish_area) | ||
img_np = np.array(img) | ||
|
||
frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB) | ||
frame_hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) | ||
|
||
h_min = np.array((0, 0, 253), np.uint8) | ||
h_max = np.array((255, 0, 255), np.uint8) | ||
|
||
mask = cv2.inRange(frame_hsv, h_min, h_max) | ||
|
||
moments = cv2.moments(mask, 1) | ||
dM01 = moments['m01'] | ||
dM10 = moments['m10'] | ||
dArea = moments['m00'] | ||
|
||
b_x = 0 | ||
b_y = 0 | ||
|
||
if dArea > 0: | ||
b_x = int(dM10 / dArea) | ||
b_y = int(dM01 / dArea) | ||
if lastx > 0 and lasty > 0: | ||
if lastx != b_x and lasty != b_y: | ||
is_block = False | ||
if b_x < 1: b_x = lastx | ||
if b_y < 1: b_y = lasty | ||
pyautogui.moveTo(b_x, b_y + fish_area[1], 0.3) | ||
pyautogui.keyDown('shiftleft') | ||
pyautogui.mouseDown(button='right') | ||
pyautogui.mouseUp(button='right') | ||
pyautogui.keyUp('shiftleft') | ||
# print("Catch !") | ||
time.sleep(5) | ||
lastx = b_x | ||
lasty = b_y | ||
|
||
# show windows with mask | ||
# cv2.imshow("fish_mask", mask) | ||
# cv2.imshow("fish_frame", frame) | ||
|
||
if time.time() - new_cast_time > recast_time: | ||
# print("New cast if something wrong") | ||
is_block = False | ||
if cv2.waitKey(1) == 27: | ||
break | ||
QtWidgets.QApplication.quit() | ||
|
||
def stop(self): | ||
self.flag_exit = False | ||
|
||
|
||
if __name__ == '__main__': | ||
#print("Fish bot Vanilla by YECHEZ started !") | ||
|
||
app = QtWidgets.QApplication(sys.argv) | ||
tray = QtWidgets.QSystemTrayIcon( | ||
QtGui.QIcon("wow-fish-bot.png") | ||
) | ||
fish_bot = FishBotTray(tray) | ||
menu = QtWidgets.QMenu() | ||
quit_action = menu.addAction('Quit') | ||
quit_action.triggered.connect(fish_bot.stop) | ||
tray.setContextMenu(menu) | ||
tray.show() | ||
tray.setToolTip("Fish bot Vanilla by YECHEZ started !") | ||
fish_bot.start() | ||
cv2.destroyAllWindows() | ||
app.exec_() | ||
else: | ||
# print("Pause") | ||
systray.update(hover_text=app + " - On Pause") | ||
time.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
|
||
block_cipher = None | ||
|
||
|
||
a = Analysis(['wow-fish-bot.py'], | ||
pathex=['YOURPATH'], | ||
binaries=[], | ||
datas=[], | ||
hiddenimports=[], | ||
hookspath=[], | ||
runtime_hooks=[], | ||
excludes=[], | ||
win_no_prefer_redirects=False, | ||
win_private_assemblies=False, | ||
cipher=block_cipher, | ||
noarchive=False) | ||
pyz = PYZ(a.pure, a.zipped_data, | ||
cipher=block_cipher) | ||
exe = EXE(pyz, | ||
a.scripts, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
[('wow-fish-bot.ico', r'YOURPATH\wow-fish-bot.ico' ,'file'),], | ||
name='wow-fish-bot', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
runtime_tmpdir=None, | ||
console=False , icon='wow-fish-bot.ico') |