我如何用pyautoguii按alt <numpad>?

问题描述 投票:1回答:1

这是我的脚本。

import pyautogui
import subprocess
import time

#notepad is in the file path
programma = "Notepad"

#opening notepad
subprocess.Popen(programma)

#gives time to open notepad, ie I've also tried with higher numbers
time.sleep(1)

pyautogui.keyDown('NumLock')
#I've also tried with 
pyautogui.hotkey('alt', 'num3')

我试过了,Numpad的工作原理是:如果我注释掉 "alt",只写上 pyautogui.press('num3')虽然如果我在代码中输入alt,它给出了一个错误,就像我在没有设置光标的情况下输入一样。

pyautogui.keyDown('alt')
pyautogui.keyDown('num3')
pyautogui.keyUp('num3')
pyautogui.keyUp('alt')

有人知道该怎么做吗?

python pyautogui numpad
1个回答
0
投票

对我来说是可行的。

pyautogui.keyDown('alt')
pyautogui.press("num3")
pyautogui.keyUp('alt')

如果你尝试 .keyDown('num3') pyautogui会认为你想在你的组合中使用第三个键。

© www.soinside.com 2019 - 2024. All rights reserved.