使用 Autokey 模拟 Home+Shift+End
Emulating Home+Shift+End with Autokey
我只是想做这样的事情Home+Shift(down)+End+Shift(up)(上下代表Shift键被按住)。这使得 select 光标所在的整行成为可能(在复制、删除等时很有用)。
对于 AHK,这是通过使用:
Send {Home}
Send {blind}+{END}
但现在我在 Linux,我不知道如何做这么简单的事情。
keyboard.send_keys("<home>+<shift>+<end>")
根本行不通。感谢任何帮助。
您要控制哪种应用程序?您可能想按照此处所述使用 xdotool:https://github.com/autokey/autokey/wiki/Known-limitations
下面做类似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>')
我只是想做这样的事情Home+Shift(down)+End+Shift(up)(上下代表Shift键被按住)。这使得 select 光标所在的整行成为可能(在复制、删除等时很有用)。
对于 AHK,这是通过使用:
Send {Home}
Send {blind}+{END}
但现在我在 Linux,我不知道如何做这么简单的事情。
keyboard.send_keys("<home>+<shift>+<end>")
根本行不通。感谢任何帮助。
您要控制哪种应用程序?您可能想按照此处所述使用 xdotool:https://github.com/autokey/autokey/wiki/Known-limitations
下面做类似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>')