简体   繁体   English

如何在python中按下暂停键

[英]How to press pause key in python

I am creating a pyautogui automation that connect to a W3270 terminal (really old :)) this terminal is expecting pause key to be pressed, Apart pyautogui, I also tried Keyboard library, but i am unable to send pause我正在创建一个连接到 W3270 终端的 pyautogui 自动化(真的很旧:))这个终端期待按下暂停键,除了 pyautogui,我也尝试过键盘库,但我无法发送暂停

import pyautogui
import keyboard
import constants as const

locateOnScreen(const.IPAIRE_TERMINAL_CONNECTED)

command = '/FOR SIGNON'
pause = '\u0019'
pyautogui.write(command)
time.sleep(1)
keyboard.send('pause')

Am I suppose to use keyboard to simulate 'pause' button?我想使用键盘来模拟“暂停”按钮吗? 在此处输入图片说明

I found a solution using pynput我找到了一个使用 pynput 的解决方案

import pyautogui
import constants as const
from pynput.keyboard import Key, Controller

locateOnScreen(const.IPAIRE_TERMINAL_CONNECTED)

command = '/FOR SIGNON'
pyautogui.write(command)
time.sleep(1)
keyboard = Controller()
keyboard.press(Key.pause)
keyboard.release(Key.pause)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM