Autohotkey 如何使用Autokey抓取突出显示的文本+;url,然后插入所述突出显示的文本+;短语占位符中的url?

Autohotkey 如何使用Autokey抓取突出显示的文本+;url,然后插入所述突出显示的文本+;短语占位符中的url?,autohotkey,ubuntu-18.04,autokey,Autohotkey,Ubuntu 18.04,Autokey,我正在尝试让Autokey像在Windows中为我工作的Autohotkey一样工作 在Autohotkey中可以设置的一个非常有用的功能是分配一个键盘键来抓取突出显示的文本,然后转到url,抓取该url,然后将突出显示的文本和url插入预定短语中的特定位置 创建带有不同格式链接的文本非常有用 我所描述的自动热键脚本如下所示: insert:: clipboard = Send, ^c ClipWait myText = %clipboard% Send, !d clipboard = Send

我正在尝试让Autokey像在Windows中为我工作的Autohotkey一样工作

在Autohotkey中可以设置的一个非常有用的功能是分配一个键盘键来抓取突出显示的文本,然后转到url,抓取该url,然后将突出显示的文本和url插入预定短语中的特定位置

创建带有不同格式链接的文本非常有用

我所描述的自动热键脚本如下所示:

insert::
clipboard =
Send, ^c
ClipWait
myText = %clipboard%
Send, !d
clipboard =
Send, ^c
ClipWait
myURL = %clipboard%
myLink = <a href="%myURL%">%myText%</a>
clipboard = %myLink%
return
insert::
剪贴板=
发送,^c
克里普韦特
myText=%剪贴板%
发送!D
剪贴板=
发送,^c
克里普韦特
myURL=%剪贴板%
myLink=
剪贴板=%myLink%
返回
有没有办法将其转换为可工作的自动键脚本?

#将键盘键分配给
# assigning a keyboard key to
# `hotkey - a key or combination of keys that, when pressed, will trigger AutoKey to do something; run a script, insert a phrase or display a menu. A hotkey can be created using any key on the keyboard (within reason), with or without one or more modifier keys. The modifier keys are Shift, Control, Alt and Super (a.k.a. Windows).`
# [Guide](https://github.com/autokey/autokey/wiki/Beginners-Guide)

import os, time

# grab highlighted text
myText = clipboard.get_selection()

# then go to url
myCmd = "/usr/bin/firefox --new-window http://www. your site .biz/"
os.system(myCmd)
time.sleep(0.25)

# grab that url, and then
keyboard.send_keys('<F6>')
time.sleep(0.25)
myURL = clipboard.get_selection()

# insert the highlighted text and URL in specific places within a predetermined phrase.
# run a window wait, then paste the texts there. Following example opens a msgbox2sec.ahk (create it first):
myCmd = 'wine ~/.wine/drive_c/Program\ Files/AutoHotkey/AutoHotkey.exe /home/administrator/Desktop/msgbox2sec.ahk'
os.system(myCmd)
time.sleep(0.25)

active_class = window.get_active_class()
if not active_class == "your class name":  # for example: "autokey-gtk.Autokey-gtk":
    time.sleep(0.25)  # sleep longer

myLink = "<a href = \"" + myURL + "\">" + myText + "</a>"
# paste your link, then copy it:
keyboard.send_keys(myLink)

# select select a line:
keyboard.send_keys('<home>')
keyboard.send_keys("<shift>+<end>")

# copy line to clipboard:
keyboard.send_keys('<ctrl>+c')

# or copy line to variable:
c = clipboard.get_selection()
#`热键-一个键或多个键的组合,当按下时,将触发自动键来执行某项操作;运行脚本、插入短语或显示菜单。可以使用键盘上的任意键(在合理范围内)创建热键,包括或不包括一个或多个修改键。修改键是Shift、Control、Alt和Super(也称为Windows)` #[指南](https://github.com/autokey/autokey/wiki/Beginners-Guide) 导入操作系统,时间 #抓取突出显示的文本 myText=clipboard.get_selection() #然后转到url myCmd=“/usr/bin/firefox——新窗口http://www. 您的站点。biz/“ 操作系统(myCmd) 睡眠时间(0.25) #抓取该url,然后 键盘。发送_键(“”) 睡眠时间(0.25) myURL=剪贴板。获取\u选择() #在预定短语内的特定位置插入突出显示的文本和URL。 #运行窗口等待,然后将文本粘贴到那里。以下示例打开一个msgbox2sec.ahk(首先创建它): myCmd='wine~/.wine/drive_c/Program\Files/AutoHotkey/AutoHotkey.exe/home/administrator/Desktop/msgbox2sec.ahk' 操作系统(myCmd) 睡眠时间(0.25) 活动类=窗口。获取活动类() 如果未激活,则类==“您的类名”:#例如:“autokey gtk.autokey gtk”: 时间。睡眠(0.25)#多睡一会儿 myLink=“” #粘贴链接,然后复制: 键盘。发送_键(myLink) #选择一行: 键盘。发送_键(“”) 键盘。发送_键(“+”) #将行复制到剪贴板: 键盘。发送_键(“+c”) #或将行复制到变量: c=剪贴板。获取_选择()