asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.5k stars 1.27k forks source link

closing the application if it finds an image #798

Open Dif05 opened 1 year ago

Dif05 commented 1 year ago

I use Python 3.11, I wrote a simple program in pyautogui for the game, the essence is just to click on the "picture cookies", but every time the game starts, the program clicks on the icon in the taskbar (there is no problem in full-screen mode), and here I have a question, how can I fix the "exit" from the game. I used Python 3.9 before and there was no such problem

romaklym commented 1 year ago

Can you provide code that you using @Dif05 ?

Dif05 commented 1 year ago

I do not know how to send the code correctly, I apologize in advance for the inconvenience

import pyautogui as pag import keyboard as kb

while kb.is_pressed('alt') == False:

effect = pag.locateOnScreen('effect.png', confidence=0.95)
magic = pag.locateOnScreen('magic.png', confidence=0.95)
stats = pag.locateOnScreen('stats.png', confidence=0.99)
open1 = pag.locateOnScreen('open.png', confidence=0.97)
nastr = pag.locateOnScreen('nastr.png', confidence=0.99)
info = pag.locateOnScreen('info.png', confidence=0.99)
text = pag.locateOnScreen('text.png', confidence=0.97)

gc = pag.locateOnScreen('gc.png', confidence=0.7)
gc2 = pag.locateOnScreen('gc2.png', confidence=0.7)
gc3 = pag.locateOnScreen('gc3.png', confidence=0.7)
gc4 = pag.locateOnScreen('gc4.png', confidence=0.7)
gc5 = pag.locateOnScreen('gc5.png', confidence=0.7)
gc6 = pag.locateOnScreen('gc6.png', confidence=0.7)
gc7 = pag.locateOnScreen('gc7.png', confidence=0.7)
gc8 = pag.locateOnScreen('gc8.png', confidence=0.7)
gc9 = pag.locateOnScreen('gc9.png', confidence=0.7)
gc10 = pag.locateOnScreen('gc10.png', confidence=0.8)

if gc:
    pag.click(gc)

if gc2:
    pag.click(gc2)

if gc3:
    pag.click(gc3)

if gc4:
    pag.click(gc4)

if gc5:
    pag.click(gc5)

if gc6:
    pag.click(gc6)

if gc7:
    pag.click(gc7)

if gc8:
    pag.click(gc8)

if gc9:
    pag.click(gc9)

if gc10:
    pag.click(gc10)

if info:
    pag.click(info)
    pag.click(x=170, y=220)

if stats:
    pag.click(stats)
    pag.click(x=170, y=220)

if nastr:
    pag.click(nastr)
    pag.click(x=170, y=220)

if effect:
    pag.click(magic)

if open1:
    pag.click(open1)
    pag.click(x=170, y=220)

if text:
    pag.click(text)

пн, 28 авг. 2023 г. в 06:32, Roman Klym @.***>:

Can you provide code that you using @Dif05 https://github.com/Dif05 ?

— Reply to this email directly, view it on GitHub https://github.com/asweigart/pyautogui/issues/798#issuecomment-1694951495, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBY73DKH2DW5QEP3E5FUM7DXXQGLLANCNFSM6AAAAAA3HVHBFQ . You are receiving this because you were mentioned.Message ID: @.***>

jtranquilli commented 1 year ago

To clarify the issue that you're facing, the program is mistakenly clicking on an icon in the task bar? Have you been able to isolate which of gc, gc1, ..., gc10 it is identifying as being in the task bar? Has debugging revealed any further insight into the problem?

Dif05 commented 1 year ago

the point is that the photos of the "gc" are not at all connected with the application icon, I will also say that the bot collapses any application that opens on top Pycharm

пн, 25 сент. 2023 г., 21:16 jtranquilli @.***>:

To clarify the issue that you're facing, the program is mistakenly clicking on an icon in the task bar? Have you been able to isolate which of gc, gc1, ..., gc10 it is identifying as being in the task bar? Has debugging revealed any further insight into the problem?

— Reply to this email directly, view it on GitHub https://github.com/asweigart/pyautogui/issues/798#issuecomment-1734243707, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBY73DLQZNJWAOUWBYWCYL3X4HC6FANCNFSM6AAAAAA3HVHBFQ . You are receiving this because you were mentioned.Message ID: @.***>