2

我只是想做这样的事情Home+ Shift(down)+ End+ Shift(up)(上下代表按住 Shift 键)。这使得可以选择光标所在的整行(在复制、删除等时很有用)。

使用 AHK,这是通过以下方式完成的:

Send {Home}
Send {blind}+{END}

但是现在我在 Linux 上,我不知道如何做这么简单的事情。

keyboard.send_keys("<home>+<shift>+<end>")

根本行不通。任何帮助表示赞赏。

4

2 回答 2

2

以下做类似的事情Home+Shift(down)+End+Shift(up)

# if you want select select a line:

keyboard.send_keys('<home>')
keyboard.send_keys("<shift>+<end>")

# keyboard.send_keys('<home><shift>+<end>")  # <= this gives an error
# keyboard.send_keys('<home>+<shift>+<end>")  # <= this gives an error and has a different meaning.

# if you want select the word under your cursor you could do the following:
def select_text(keyboard, len_clipboardBackup = 0):  #  0 if dont know the clipboard/text but try select anyway
    keyboard.release_key('<ctrl>')
    if not len_clipboardBackup or len_clipboardBackup > 100:
        keyboard.send_keys('<ctrl>+<shift>+<left>')  # faster but not as exact. forgets special letters.
    else:
        for i in range(0, len_clipboardBackup):
            keyboard.send_keys('<shift>+<left>')
于 2020-09-01T11:08:06.713 回答
1

你想控制什么样的应用程序?您可能希望按照此处所述使用 xdotool:https ://github.com/autokey/autokey/wiki/Known-limitations

于 2020-03-04T09:41:10.833 回答