Тема: проблема
Показать сообщение отдельно

  #2  
Старый 02.02.2024, 17:57
Dickson
Участник форума
Регистрация: 31.12.2022
Сообщений: 201
С нами: 1774087

Репутация: 33
По умолчанию

о, я писал похожий код для поиска картинки, затем нажатие на нее. ща кину

da.py:





Код:
import
pyautogui
import
telebot
import
keyboard
import
time

bot
=
telebot
.
TeleBot
(
''
)
chat_id
=
''
active
=
False
def
find_and_click
(
button_image
)
:
if
active
:
button_location
=
None
while
button_location
is
None
:
button_location
=
pyautogui
.
locateOnScreen
(
button_image
,
grayscale
=
True
,
confidence
=
0.9
)
button_x
,
button_y
=
pyautogui
.
center
(
button_location
)
time
.
sleep
(
1
)
pyautogui
.
click
(
button_x
,
button_y
)
bot
.
send_message
(
chat_id
,
f'Нажата кнопка{button_image}'
)
def
toggle_activation
(
)
:
global
active
    active
=
not
active
if
active
:
bot
.
send_message
(
chat_id
,
'Код активирован'
)
else
:
bot
.
send_message
(
chat_id
,
'Код деактивирован'
)
keyboard
.
add_hotkey
(
'insert'
,
toggle_activation
)
# активация -  "insert"
while
True
:
try
:
time
.
sleep
(
1
)
find_and_click
(
'accept.png'
)
except
pyautogui
.
ImageNotFoundException
:
pass
try
:
time
.
sleep
(
1
)
find_and_click
(
'ready.png'
)
except
pyautogui
.
ImageNotFoundException
:
pass
 
Ответить с цитированием