RINCODE
@RINCODE
Я новичок, еще учусь

Почему pyscreenshot при компиляции в exe не хочет делать скриншот?

В консоли от имени админа запускал, работает. При компиляции в exe оно не хочет работать не от имени админа, никак...
import numpy as np
import pyscreenshot as ImageGrab
from PIL import Image
import pytesseract,pyperclip,time,cv2
import translators as ts
import threading
from AutoHotPy import AutoHotPy
from InterceptionWrapper import *
import pymysql, random, keyboard
#filename = 'Image.png'
x = 0
def exitAutoHotKey(autohotpy, event):
    autohotpy.stop()
def bot(autohotpy, event):
    global x
    print('Запуск цикла')
    while True:
        print('Цикл запущен')
        #try:
        print('Блок try пройден')
        time.sleep(1)
        screen = np.array(ImageGrab.grab(bbox=(713, 550, 1400, 586)))
        print('Скрин сделан')
        #cv2.imwrite(filename, screen)
        x = x + 1
        print(x)
        if x == 2:
        cv2.destroyAllWindows()
        x = 0
                ####################################
        pytesseract.pytesseract.tesseract_cmd = "Tesseract-OCR\\tesseract.exe"
        tessdata_dir_config = r'--tessdata-dir "Tesseract-OCR\tessdata"'
        #img = Image.open(filename)
        print('Ожидается Преобразование в текст')
        text = pytesseract.image_to_string(screen, lang='rus', config=tessdata_dir_config)
        print('Текст', text)
        text = text.replace('', '')
        text = text.replace('ь!', 'ы')
        text = text.replace('„', '')
        text = text.replace('—', ' is')
        text = text.replace('Онвыше, чемя', ' Он выше, чем я')
        endtext = ts.google(text, from_language='ru', to_language='en')
        endtext = endtext.replace("'", '')
        endtext = endtext.replace(".", '')
        print(endtext)
        pyperclip.copy(endtext)
            autohotpy.LEFT_CTRL.down()
                autohotpy.sleep(0.17669177055358887)
                autohotpy.V.down()
                autohotpy.sleep(0.11204981803894043)
                autohotpy.V.up()
                autohotpy.sleep(0.03889870643615723)
                autohotpy.LEFT_CTRL.up()
                autohotpy.sleep(0.6170032024383545)
                autohotpy.ENTER.down()
                autohotpy.sleep(0.1360323429107666)
                autohotpy.ENTER.up()
                time.sleep(1)
        except TypeError:
            print('Попытка краша программы была предотвращена! \n ^_^ работаем дальше!')
auto = AutoHotPy()
auto.registerExit(auto.F12,exitAutoHotKey)
auto.registerForKeyDown(auto.ENTER, bot)
auto.start()

Помогите пж)
PS: Не обращайте внимание на сдвиги просто пытаюсь понять в чем ошибка, по этому код откатываю немного
  • Вопрос задан
  • 325 просмотров
Пригласить эксперта
Ответы на вопрос 1
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы