【发布时间】:2012-06-02 09:59:27
【问题描述】:
我最近切换到 Ubuntu,我想念 autohotkey。我正在使用autokey 重新创建我的热键环境。我使用Xmodmap 将CapsLock 重新映射到F13。
我需要做的:
当F13 被点击时,返回<Esc>。
当F13 与键一起使用时,触发热键。
当F13 被按住超过 1 秒并且没有热键释放时,什么也不返回。
Autokey 使用 Python 环境。这是我的计划:
F13 is pressed
Start a timer
Start a thread listening for <CapsLock up> and if true,
if timer is less than 1 second && no hotkey was pressed
exit script after returning <Esc>
exit script
Start a thread that loops forever
Listen for hotkey
Play hotkey's function
脚本在CapsLock 发布时结束。
示例:我按CapsLock,然后按j,输出为Down arrow。
在我开始编码之前我的问题是,我真的需要为此使用多个线程(并发)吗?这是最好的方法吗?我觉得有一种更简单的方法,而且我也从未使用并发编码。
编辑:我愿意接受任何方法来实现这一点,即使它不是使用 autokey 或 python。
【问题讨论】:
标签: python ubuntu concurrency hotkeys autokey