ahk 在 bash 脚本中发送备选方案

ahk send alternative in bash script

我想在 bash 脚本中实现,当我按下任意键(例如 F5)然后输入任何单词(例如“hello world”)时,无论我是否定位在终端中,或文本编辑器或浏览器...

当我使用 Windows 时,我使用了 Autohotkey。

如何使用 Linux 中的 bash 脚本实现该目标?

虽然正如@Socowi 提到的那样,您可能无法单独使用 bash 来完成此操作,但您可以使用 AutoHotkey Linux 替代方法,例如 AutoKey。

对于您的具体问题,请参阅 this guide 在 Linux 上设置和配置 AutoKey。

更具体地说,向下滚动到标有“使用热键插入重复文本”的部分,了解如何配置文本键入热键:

Inserting repetitive text using a hotkey

Abbreviations is only one way of inserting text using AutoKey. If you prefer, you can also insert text using a keyboard shortcut, which doesn't require typing an abbreviation.

To insert some text that you need to type frequently using a keyboard shortcut, click the Set button next to Hotkey, then click Press to Set in the newly opened window, and press the key combination you want to use for this phrase:

Make sure you use a hotkey that's not already in use or else it may not work / it will interfere with the already set hotkey. To try this out, set it to something like Ctrl + F1 (which shouldn't be set by the system at least).

Remember to click the Save button in the AutoKey toolbar after setting the phrase hotkey, or else the changes won't have any effect. Now try it out: focus a text editor, some text field in a web form, etc., and press the hotkey you've set in AutoKey - the Testing AutoKey text expansion on Linux phrase should be automatically inserted as soon as you press the keyboard shortcut.