Autohotkey 将复制的文本转换为超链接格式文本

Autohotkey 将复制的文本转换为超链接格式文本,autohotkey,Autohotkey,这不是一个非常愚蠢、简单的问题,就是一个棘手的问题。就我个人而言,我无法理解。我为我的工作定期复制/粘贴需要超链接的网站URL。有时我从记事本复制链接,有时直接从浏览器的地址栏复制链接。从internet浏览器地址栏复制网站URL时,当我粘贴到某个位置(如电子邮件、语法等)时,它会被复制并粘贴为超链接文本>这就是我想要的 当从我的记事本档案中复制URL时,它会将URL粘贴为纯文本,我必须手动将其超链接。我很想以某种方式实现自动化。我希望它能像添加html标签一样简单,但我没有任何运气 所以我想和

这不是一个非常愚蠢、简单的问题,就是一个棘手的问题。就我个人而言,我无法理解。我为我的工作定期复制/粘贴需要超链接的网站URL。有时我从记事本复制链接,有时直接从浏览器的地址栏复制链接。从internet浏览器地址栏复制网站URL时,当我粘贴到某个位置(如电子邮件、语法等)时,它会被复制并粘贴为超链接文本>这就是我想要的

当从我的记事本档案中复制URL时,它会将URL粘贴为纯文本,我必须手动将其超链接。我很想以某种方式实现自动化。我希望它能像添加html标签一样简单,但我没有任何运气


所以我想和你们谈谈,看看你们是否有幸完成同样的任务。

这几句话对我帮助很大:

这是我的脚本

F3:: ;Change this hotkey to what you want

; copy text
; if https* 
;   >paste as html formatted hyperlink
;   >else; paste untouched

If InStr(Clipboard, "https://")=1
  {
    ;Clipboard contents starts with https:// routed here.
      text1 := "<a href="
      text2 := """"
      text3 := Clipboard
      text4 := """"
      text5 := ">"
      text6 := Clipboard
      text7 := "</a>"
      fullStr := text1 . text2 . text3 . text4 . text5 . text6 . text7
      ;MsgBox % fullStr ;String check.
      WinClip.Clear()
      ;WinClip.SetText("www.ahkscript.org") ;not sure I ever need this for my purposes.
      WinClip.SetHTML(fullStr)
      WinClip.Paste()
      return
  } Else {
    ;Clipboard contents does not start w/ https:// routed here.
    Send, ^v
  }
#Include C:\PathToWinClip\WinClipAPI.ahk
#Include C:\PathToWinClip\WinClip.ahk
F3::;将此热键更改为所需
; 复制文本
; 如果https*
;   >粘贴为html格式的超链接
;   >其他的原封不动地粘贴
如果InStr(剪贴板,“https:/”)=1
{
;剪贴板内容以https://routed here开头。
text1:=“”
fullStr:=text1.text2.text3.text4.text5.text6.text7
;MsgBox%fullStr;字符串检查。
WinClip.Clear()
;WinClip.SetText(“www.ahkscript.org”);我不确定我是否需要它来实现我的目的。
WinClip.SetHTML(fullStr)
WinClip.Paste()
返回
}否则{
;剪贴板内容不以w/https://routed here开头。
发送,^v
}
#包括C:\PathToWinClip\WinClipAPI.ahk
#包括C:\PathToWinClip\WinClip.ahk

这几行对我帮助很大:

这是我的脚本

F3:: ;Change this hotkey to what you want

; copy text
; if https* 
;   >paste as html formatted hyperlink
;   >else; paste untouched

If InStr(Clipboard, "https://")=1
  {
    ;Clipboard contents starts with https:// routed here.
      text1 := "<a href="
      text2 := """"
      text3 := Clipboard
      text4 := """"
      text5 := ">"
      text6 := Clipboard
      text7 := "</a>"
      fullStr := text1 . text2 . text3 . text4 . text5 . text6 . text7
      ;MsgBox % fullStr ;String check.
      WinClip.Clear()
      ;WinClip.SetText("www.ahkscript.org") ;not sure I ever need this for my purposes.
      WinClip.SetHTML(fullStr)
      WinClip.Paste()
      return
  } Else {
    ;Clipboard contents does not start w/ https:// routed here.
    Send, ^v
  }
#Include C:\PathToWinClip\WinClipAPI.ahk
#Include C:\PathToWinClip\WinClip.ahk
F3::;将此热键更改为所需
; 复制文本
; 如果https*
;   >粘贴为html格式的超链接
;   >其他的原封不动地粘贴
如果InStr(剪贴板,“https:/”)=1
{
;剪贴板内容以https://routed here开头。
text1:=“”
fullStr:=text1.text2.text3.text4.text5.text6.text7
;MsgBox%fullStr;字符串检查。
WinClip.Clear()
;WinClip.SetText(“www.ahkscript.org”);我不确定我是否需要它来实现我的目的。
WinClip.SetHTML(fullStr)
WinClip.Paste()
返回
}否则{
;剪贴板内容不以w/https://routed here开头。
发送,^v
}
#包括C:\PathToWinClip\WinClipAPI.ahk
#包括C:\PathToWinClip\WinClip.ahk

您应该使用regexmatch,而不是
instr(剪贴板,“https://”)
类似于
regexmatch(剪贴板,“https?”:\/\”)
您应该使用regexmatch,而不是
instr(剪贴板,“https://”
类似于
regexmatch(剪贴板,“https?”:\/\”)