From c05705b9fadeeef30187bed88bc808900937369a Mon Sep 17 00:00:00 2001 From: Artem Lavrenov Date: Thu, 29 Oct 2020 17:59:09 +0300 Subject: [PATCH] Fix bug show captcha --- changelist.md | 3 +++ plugin/pyppeteeradd.py | 8 +++++--- plugin/show_chrome.bat | 2 +- plugin/show_chrome.py | 30 ------------------------------ 4 files changed, 9 insertions(+), 34 deletions(-) delete mode 100644 plugin/show_chrome.py diff --git a/changelist.md b/changelist.md index fa87bd1..f8951c0 100644 --- a/changelist.md +++ b/changelist.md @@ -140,3 +140,6 @@ __Автономная версия__: Очередная попытка починить плагин mosenergosbyt для ряда случаев (при участии dimon_s2020) Для плагинов через хром исправлена работа с другими браузерами на движке cromium (edge, yandex, brave и т.п., опера хоть и на хромиуме но нормально не заработала) Плагин yota теперь тоже через хром + +## mbplugin 0.99.24 (28.10.20) Fix bug show captcha +Исправление ошибки показа браузера (багрепорт comr) diff --git a/plugin/pyppeteeradd.py b/plugin/pyppeteeradd.py index 781fba2..c5d2ea8 100644 --- a/plugin/pyppeteeradd.py +++ b/plugin/pyppeteeradd.py @@ -14,12 +14,14 @@ def hide_chrome(hide=True): 'Прячем или показываем окно хрома' def enumWindowFunc(hwnd, windowList): """ win32gui.EnumWindows() callback """ - text = win32gui.GetWindowText(hwnd) - className = win32gui.GetClassName(hwnd) + text = win32gui.GetWindowText(hwnd).lower() + className = win32gui.GetClassName(hwnd).lower() _, pid = win32process.GetWindowThreadProcessId(hwnd) try: # ??? text.lower().find('chrome')>=0 - if text != '' and 'remote-debugging-port' in ''.join(psutil.Process(pid).cmdline()): + if (text != '' and 'remote-debugging-port' in ''.join(psutil.Process(pid).cmdline()) + and not text.startswith('msct') and not text.startswith('default') and 'восстановить' not in text): windowList.append((hwnd, text, className)) + logging.debug(f'enumWindowFunc:{text=}, {className=}') except Exception: pass myWindows = [] diff --git a/plugin/show_chrome.bat b/plugin/show_chrome.bat index c0a2c65..a9ec359 100644 --- a/plugin/show_chrome.bat +++ b/plugin/show_chrome.bat @@ -2,4 +2,4 @@ %~d0 cd "%~dp0" -..\python\python.exe ..\plugin\show_chrome.py +..\python\python -c "import pyppeteeradd;pyppeteeradd.hide_chrome(hide=False)" diff --git a/plugin/show_chrome.py b/plugin/show_chrome.py deleted file mode 100644 index 6875bde..0000000 --- a/plugin/show_chrome.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf8 -*- -import asyncio, time, subprocess, logging, shutil, os -import win32gui, win32process, psutil -import pyppeteer -from pyppeteer import launch # PYthon puPPETEER -import pprint; pp = pprint.PrettyPrinter(indent=4).pprint - -logging.getLogger().setLevel(logging.INFO) -user_data_dir = './clean_profile' -profile_directory = 'Profile 1' - - - -def hide_chrome(hide=True): - def enumWindowFunc(hwnd, windowList): - """ win32gui.EnumWindows() callback """ - text = win32gui.GetWindowText(hwnd) - className = win32gui.GetClassName(hwnd) - _, pid = win32process.GetWindowThreadProcessId(hwnd) - if text.find("Chrome")>=0 and 'remote-debugging-port' in ''.join(psutil.Process(pid).cmdline()): - windowList.append((hwnd, text, className)) - myWindows = [] - # enumerate thru all top windows and get windows which are ours - win32gui.EnumWindows(enumWindowFunc, myWindows) - for hwnd, text, className in myWindows: - win32gui.ShowWindow(hwnd, not hide) # True-Show, False-Hide - win32gui.MoveWindow(hwnd, 0, 0, 1000, 1000, True) - -hide_chrome(False) \ No newline at end of file