Hello.
Good morning everyone :)
I warn you in advance that this is just the beginning of my adventure with "programming", so I ask for understanding and above all patience for my stupidity
Due to the fact that for some time I'm terribly interested in python, I decided to try to write a program that could be useful to me and at the same time gain some knowledge.
To the point:
I would like to create a program that will detect a given image and perform certain actions. I've made myself a list of all the "rules" that must apply to it, i.e:
I've also created code that theoretically works and does what it wants to do, but it only does it once and I want it to do it indefinitely or until I stop it myself.
Can someone give me some advice?
Can someone give me some advice?
Good morning everyone :)
I warn you in advance that this is just the beginning of my adventure with "programming", so I ask for understanding and above all patience for my stupidity
Due to the fact that for some time I'm terribly interested in python, I decided to try to write a program that could be useful to me and at the same time gain some knowledge.
To the point:
I would like to create a program that will detect a given image and perform certain actions. I've made myself a list of all the "rules" that must apply to it, i.e:
I've also created code that theoretically works and does what it wants to do, but it only does it once and I want it to do it indefinitely or until I stop it myself.
Can someone give me some advice?

##### RULES #### #x1, y1 = specific part of my screen #x2, y2 = next specfic part of my screen #"OPEN" picture always appear in x2,y2 # Searching for picture "Open" in x2,y2 # if find, then: # Start searching for picture "Short" or "Long" in [(x1,y1) both are in the same area] # if find "Long", then: # click (100,100) # then wait for next picutre appears in (x2.y2) # If appears "XL" or "Short" then: # click (215,191) # if find "Short", then: # click (215,191) # then wait for next picutre appears in (x2.y2) # If appears "XS" or "Long" then: # click (137,191) #if not find "OPEN", then searching until find #repeat until i stoped. #repeat until I turn it off #red = 137,191 #Blue = 215,191I've also created code that theoretically works and does what it wants to do, but it only does it once and I want it to do it indefinitely or until I stop it myself.
Can someone give me some advice?

from asyncore import loop
from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
while 1: #Main loop, if true go to next / if Not True, repeat until true
if pyautogui.locateOnScreen('Open1.png', region=(460,988,28,12), grayscale=True, confidence=0.8) != None:
print("FOUND")
time.sleep (1)
break
else:
print("NOT FOUND")
time.sleep(1)
continue
while 1: #Second loop
if pyautogui.locateOnScreen('Short1.png', region=(459,1022,30,12), grayscale=True, confidence=0.8) != None:
print("SELL")
# pyautogui.click(137, 191)
break
if pyautogui.locateOnScreen('Long1.png', region=(459,1023,27,12), grayscale=True, confidence=0.8) != None:
print("LONG")
# pyautogui.click(215, 191)
break
else:
print("NOT FOUND")
time.sleep(1)
continue
while 1: #Third loop
if pyautogui.locateOnScreen('XL1.png', region=(460,987,13,12), grayscale=True, confidence=0.8) != None:
print("XL")
# pyautogui.click(137, 191)
break
if pyautogui.locateOnScreen('Long1.png', region=(459,988,27,12), grayscale=True, confidence=0.8) != None:
print("LONG1")
# pyautogui.click(215, 191)
break
if pyautogui.locateOnScreen('XS1.png', region=(460,987,13,12), grayscale=True, confidence=0.8) != None:
print("XS")
# pyautogui.click(215, 191)
break
if pyautogui.locateOnScreen('Short1.png', region=(459,987,30,12), grayscale=True, confidence=0.8) != None:
print("xSHORT1")
# pyautogui.click(137, 191)
break
else:
print("NOT FOUND")
time.sleep(1)
continue
