Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

ubuntu - Reading numbers with AutoKey is slow

i want get pressed number via AutoKey. My Script works but is really slow and looks not very good.

May you know a faster way? I need hold down a key some seconds before its recognized.

import os, time, subprocess 
def popupNotify(text):
    subprocess.Popen(['notify-send', text])  # will be showed right top
pressed_key = 999999999999
for x in range(0, 150):
    retCode1 = keyboard.wait_for_keypress('<np_end>',modifiers=[],timeOut=0.01) # <== works
    retCode2 = keyboard.wait_for_keypress('<np_down>',modifiers=[],timeOut=0.01) # <== works
    retCode3 = keyboard.wait_for_keypress('<np_page_down>',modifiers=[],timeOut=0.01) # <== works
    retCode4 = keyboard.wait_for_keypress('<np_left>',modifiers=[],timeOut=0.001) # <== works
    #retCode5 = keyboard.wait_for_keypress('5',modifiers=[],timeOut=0.001) # <== works
    #retCode5 = keyboard.wait_for_keypress('<code84>',modifiers=[],timeOut=0.001) # <== not works, no error
    if retCode1:
        pressed_key = 1
    if retCode2:
        pressed_key = 2
    if retCode3:
        pressed_key = 3
    if retCode4:
        pressed_key = 4
    if pressed_key != 999999999999:
        break

popupNotify(str(pressed_key))
popupNotify("END END END END ")

I read here:

System

AutoKey (Qt) 0.95.10
Python 3.8.5
Operating System: Kubuntu 20xx
KDE Plasma Version

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...