有没有办法在pyautogui或python中通过硬编码按下numpad 7键?

2024-05-15 22:15:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试编写一个程序,在UNIX模拟器(WRQ反射)中自动填写表单,这要求我按numlock键,然后按num7进入。但是,当我运行以下代码时,我的程序只是在字段中键入数字7,而不是像我实际按下两个按钮一样继续:

pyautogui.press('1')
time.sleep(0.1)
pyautogui.press('enter')
time.sleep(0.1)
pyautogui.press('5')
time.sleep(0.1)
pyautogui.press('enter')
time.sleep(0.1)
pyautogui.press('1')
time.sleep(0.1)
pyautogui.press('enter')
time.sleep(0.1)

pyautogui.typewrite(['tab','tab'],0.1)

Product_Class = list('MERGE[enter image description here][1]')
Product_Code = list('1A309')
Vessel_Number = list('14X')
# Fills the product class field (usually MERGE)
i = 0
PCend = len(Product_Class) - 1
while i<=PCend:
    pyautogui.typewrite([Product_Class[i]])
    i+=1
time.sleep(0.4)
pyautogui.press('tab')
# Fills the product code field (This is the user entered merge number)
i = 0
Mend = len(Product_Code) - 1
while i<=Mend:
    pyautogui.typewrite([Product_Code[i]])
    i+=1
time.sleep(0.4)
pyautogui.press('tab')
# Fills the vessel number field (This is the user entered spinning machine)
i = 0
VNend = len(Vessel_Number) - 1
while i<=VNend:
    pyautogui.typewrite([Vessel_Number[i]])
    i+=1
time.sleep(0.4)
pyautogui.press('tab')
# Prints the SOC to screen
pyautogui.keyDown('numlock')
pyautogui.press('num7')

Tags: thenumbertimecodesleepproducttablist