Pyautogui 键盘命令不适用于菜单栏分配



我正在整理一个脚本来自动执行SAP GUI中的某些管理任务。我可以单击以导航,使用制表符,输入字符串,然后在表单中按回车键。

问题:当我使用 pyautogui 发送菜单键分配时,它们似乎不起作用(例如:pyautogui.press('F12'((。这迫使我不得不使用其他替代方案(错误的鼠标点击等等(。知道为什么这些不起作用吗?

我可以在没有的情况下工作 - 但我想知道是否有人了解到底发生了什么......如果可以的话,那就太好了!

pyautogui.press 区分大小写,或者至少在 Windows 上是这样。所以你需要说

pyautogui.press('f12')

下面是密钥列表。

定义此存根可能很方便

show_trivial_nags = True #maybe be able to toggle this on the command line
def ci_press(x):
if x != x.lower() and show_trivial_nags:
print("WARNING: press commands should be in lower case.")
pyautogui.press(x.lower())

我使用的测试用例是,Firefox 接下来在 alt-tab 中,

import pyautogui
pyautogui.hotkey('alt', 'tab')
# Comment out the first, and the search bar still appears. Comment out the second, and it doesn't.
pyautogui.press('F3')
pyautogui.press('f3')
exit()

最新更新