#🔒 Q, E Detection
19 messages · Page 1 of 1 (latest)
@long python
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
here is my code
Hey @long python!
It looks like you pasted Python code without syntax highlighting.
Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
import interception
import cv2
import numpy as np
import pyautogui
import time
def find_image_on_screen(template_path, threshold=0.8):
# Zrzut ekranu
screen = pyautogui.screenshot()
screen = cv2.cvtColor(np.array(screen), cv2.COLOR_RGB2BGR)
# Wczytanie szablonu
template = cv2.imread(template_path, 0)
screen_gray = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
# Wymiary ekranu i szablonu
h, w = template.shape[:2]
sh, sw = screen_gray.shape[:2]
# Wykrycie szablonu na ekranie
res = cv2.matchTemplate(screen_gray, template, cv2.TM_CCOEFF_NORMED)
loc = np.where(res >= threshold)
for pt in zip(*loc[::-1]):
# Sprawdzenie, czy znalezione dopasowanie mieści się w ekranie
if pt[0] + w <= sw and pt[1] + h <= sh:
return True
# Spróbuj odwrócić szablon i ponownie wyszukać
template_flipped = cv2.flip(template, -1)
res_flipped = cv2.matchTemplate(screen_gray, template_flipped, cv2.TM_CCOEFF_NORMED)
loc_flipped = np.where(res_flipped >= threshold)
for pt in zip(*loc_flipped[::-1]):
if pt[0] + w <= sw and pt[1] + h <= sh:
return True
return False
def press_key(key):
interception.press(key)
time.sleep(0.1)
# Główna pętla
def main():
interception.auto_capture_devices(keyboard=True, mouse=False)
# Ścieżki do obrazów
q_image_path = 'q.png'
e_image_path = 'e.png'
while True:
# Sprawdzenie obrazów na ekranie
q_found = find_image_on_screen(q_image_path)
e_found = find_image_on_screen(e_image_path)
if q_found:
print("Znaleziono podobny do Q na ekranie - klikam Q")
press_key('q')
if e_found:
print("Znaleziono podobny do E na ekranie - klikam E")
press_key('e')
time.sleep(0.1)
if __name__ == "__main__":
main()
that's the image of q and e
it's changing every click
so for example there is - on E
or on q
can someone help make me script which gonna detect if that's q or e
when i did with that the script was clicking Q when E was
or E when Q was on screen
i don't know how to make good detection system
even without images
what is this for?
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.