首页 > 解决方案 > 如何使用 PyWinAuto 在后台发送密钥?

问题描述

这是我当前的代码:

from pywinauto.application import Application
from pywinauto.keyboard import send_keys
from time import sleep

app = Application(backend="uia").start('notepad.exe')


textsend = input("What do you want to send? ")

def send(text):
  app.send_keys(text, with_spaces = True, with_newlines = True, with_tabs = True)

sleep(2)

while True:
  send(f"{textsend}\n")


input("")

它工作正常,但问题是,我必须让记事本保持专注。有没有办法在记事本最小化时发送密钥?

标签: pythonpython-3.xpywinauto

解决方案


推荐阅读