I am trying to stop the loop after 1 go through, and the next time through the loop i want it to hit the other button, but right now its stuck in the first if bid_balance%2 == 0
def market_search(self):
bid_balance = 0
player_found = False
while player_found is False:
if self.stopped:
break
print("BOT looking for players .....")
if (bid_balance%2 == 0):
# Edit bid price
pyautogui.moveTo(1300, 798)
sleep(0.500)
#pyautogui.click()
else:
pyautogui.moveTo(828, 798)
sleep(0.500)
#pyautogui.click()
# Serching knap
pyautogui.moveTo(1622, 1281)
sleep(0.500)
#pyautogui.click()
# time for Site to load
sleep(self.SITLOADINGTIME_SECONDS)
bid_balance += 1
player_found = True
return player_found
The multithreading and the logic controller for the bot
# threading methods
def update_target(self, rectangles):
self.lock.acquire()
self.rectangles = rectangles
self.lock.release()
def update_screenshot(self, screenshot):
self.lock.acquire()
self.screenshot = screenshot
self.lock.release()
def start(self):
self.stopped = False
t = Thread(target=self.run)
t.start()
def stop(self):
self.stopped = True
# main logic controller
def run(self):
while not self.stopped:
if self.state == BotState.INITIALIZING:
# do no bot actions until the startup waiting period is complete
if time() > self.timestamp + self.INITIALIZING_SECONDS:
# start searching when the waiting period is over
self.lock.acquire()
self.state = BotState.SEARCHING
self.lock.release()
elif self.state == BotState.SEARCHING:
# Call the market searching function
self.market_search()
# start buying when the waiting period is over
self.lock.acquire()
self.state = BotState.BUYING
self.lock.release()
elif self.state == BotState.BUYING:
# Call the buyer when serching is over
self.buyer()
# Start seaching again
self.lock.acquire()
self.state = BotState.SEARCHING
self.lock.release()
error i recive:
BOT looking for players .....
BOT looking for players .....
BOT looking for players .....
BOT looking for players .....
BOT looking for players .....
BOT looking for players .....
Exception in thread Thread-3 (run):
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Program Files\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\nickl\Desktop\Code\Projekt Fifa 23\bot.py", line 198, in run
self.market_search()
File "c:\Users\nickl\Desktop\Code\Projekt Fifa 23\bot.py", line 73, in market_search
pyautogui.moveTo(1622, 1281)
File "C:\Users\nickl\AppData\Roaming\Python\Python310\site-packages\pyautogui\__init__.py", line 597, in wrapper
failSafeCheck()
File "C:\Users\nickl\AppData\Roaming\Python\Python310\site-packages\pyautogui\__init__.py", line 1722, in failSafeCheck
raise FailSafeException(
pyautogui.FailSafeException: PyAutoGUI fail-safe triggered from mouse moving to a corner of the screen. To disable this fail-safe, set pyautogui.FAILSAFE to False. DISABLING FAIL-SAFE IS NOT RECOMMENDED.
Screen Capture FPS: 53
Done.
I cant stop it either, even thoug i made a stop fucntion under the main python file, so i have to use the Fail Safe Exception from pyautogui