mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
wait for eso window active, stop engine when window becomes inactive
This commit is contained in:
parent
6440ec1000
commit
b0a8db7528
@ -22,7 +22,7 @@ from fishy.engine.common.IEngine import IEngine
|
|||||||
from pynput import keyboard, mouse
|
from pynput import keyboard, mouse
|
||||||
|
|
||||||
from fishy.helper import hotkey, helper
|
from fishy.helper import hotkey, helper
|
||||||
from fishy.helper.helper import sign, log_raise
|
from fishy.helper.helper import sign, log_raise, wait_until, is_eso_active
|
||||||
from fishy.helper.config import config
|
from fishy.helper.config import config
|
||||||
|
|
||||||
mse = mouse.Controller()
|
mse = mouse.Controller()
|
||||||
@ -74,6 +74,12 @@ class FullAuto(IEngine):
|
|||||||
elif FullAutoMode(config.get("full_auto_mode", 0)) == FullAutoMode.Recorder:
|
elif FullAutoMode(config.get("full_auto_mode", 0)) == FullAutoMode.Recorder:
|
||||||
self.mode = Recorder(self)
|
self.mode = Recorder(self)
|
||||||
|
|
||||||
|
if not is_eso_active():
|
||||||
|
logging.info("Waiting for eso window to be active...")
|
||||||
|
wait_until(is_eso_active)
|
||||||
|
logging.info("starting in 2 secs...")
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
if self.window.get_capture() is None:
|
if self.window.get_capture() is None:
|
||||||
@ -90,6 +96,7 @@ class FullAuto(IEngine):
|
|||||||
fishing_event.unsubscribe()
|
fishing_event.unsubscribe()
|
||||||
if self.show_crop:
|
if self.show_crop:
|
||||||
self.start_show()
|
self.start_show()
|
||||||
|
self.stop_on_inactive()
|
||||||
|
|
||||||
self.mode.run()
|
self.mode.run()
|
||||||
|
|
||||||
@ -109,6 +116,12 @@ class FullAuto(IEngine):
|
|||||||
self.window.show(self.show_crop, func=image_pre_process)
|
self.window.show(self.show_crop, func=image_pre_process)
|
||||||
Thread(target=func).start()
|
Thread(target=func).start()
|
||||||
|
|
||||||
|
def stop_on_inactive(self):
|
||||||
|
def func():
|
||||||
|
wait_until(lambda: not is_eso_active())
|
||||||
|
self.start = False
|
||||||
|
Thread(target=func).start()
|
||||||
|
|
||||||
def get_coods(self):
|
def get_coods(self):
|
||||||
img = self.window.processed_image(func=image_pre_process)
|
img = self.window.processed_image(func=image_pre_process)
|
||||||
return get_values_from_image(img)
|
return get_values_from_image(img)
|
||||||
|
@ -19,6 +19,8 @@ from fishy.helper.config import config
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from fishy.helper.helper import is_eso_active
|
||||||
|
|
||||||
|
|
||||||
class FishEvent:
|
class FishEvent:
|
||||||
fishCaught = 0
|
fishCaught = 0
|
||||||
@ -46,7 +48,7 @@ def _fishing_sleep(waittime, lower_limit_ms = 16, upper_limit_ms = 2500):
|
|||||||
|
|
||||||
def if_eso_is_focused(func):
|
def if_eso_is_focused(func):
|
||||||
def wrapper():
|
def wrapper():
|
||||||
if GetWindowText(GetForegroundWindow()) != "Elder Scrolls Online":
|
if not is_eso_active():
|
||||||
logging.warning("ESO window is not focused")
|
logging.warning("ESO window is not focused")
|
||||||
return
|
return
|
||||||
func()
|
func()
|
||||||
|
@ -17,6 +17,7 @@ from hashlib import md5
|
|||||||
|
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
from win32comext.shell import shell, shellcon
|
from win32comext.shell import shell, shellcon
|
||||||
|
from win32gui import GetForegroundWindow, GetWindowText
|
||||||
|
|
||||||
import fishy
|
import fishy
|
||||||
import winshell
|
import winshell
|
||||||
@ -215,6 +216,10 @@ def update():
|
|||||||
restart()
|
restart()
|
||||||
|
|
||||||
|
|
||||||
|
def is_eso_active():
|
||||||
|
return GetWindowText(GetForegroundWindow()) == "Elder Scrolls Online"
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyProtectedMember,PyUnresolvedReferences
|
# noinspection PyProtectedMember,PyUnresolvedReferences
|
||||||
def _get_id(thread):
|
def _get_id(thread):
|
||||||
# returns id of the respective thread
|
# returns id of the respective thread
|
||||||
|
Loading…
Reference in New Issue
Block a user