【发布时间】:2022-01-19 05:16:30
【问题描述】:
所以我在使用 pygetwindow 的 getWindowsWithTitle 函数时遇到问题。当我在 getWindowsWithTitle 调用之前要求输入时,我收到以下错误:
Traceback (most recent call last):
File "*****\main.py", line 79, in <module>
handle.activate()
File "*****\venv\lib\site-packages\pygetwindow\_pygetwindow_win.py", line 246, in activate
_raiseWithLastError()
File "*****\venv\lib\site-packages\pygetwindow\_pygetwindow_win.py", line 99, in _raiseWithLastError
raise PyGetWindowException('Error code from Windows: %s - %s' % (errorCode, _formatMessage(errorCode)))
pygetwindow.PyGetWindowException: Error code from Windows: 0 - The operation completed successfully.
如果我注释掉我的 Input 调用,getWindowsWithTitle 就可以正常工作。以下是我目前的代码
import win32gui
import time
from pynput.keyboard import Key, Controller
import pygetwindow as window
target = input("** Instance Name Is The Title When You Hover Over The Application ** \nSelect Instance Name: ")
handle = window.getWindowsWithTitle('Command')[0]
keyboard = Controller()
handle.activate()
handle.maximize()
time.sleep(2)
keyboard.press('a')
keyboard.release('a')
我正在尝试获取输入以选择要选择的窗口,但即使将“目标”放在 getWindowsWithTitle 中,它也会给我同样的错误。有谁知道为什么我在输入后会收到此错误?
【问题讨论】:
-
有人能帮忙吗?