Autohotkey - 将剪贴板格式的文本转换为纯文本

时间:2016-03-16 22:34:30

标签: autohotkey

如何仅在几个程序中使用Autohotkey将剪贴板格式的文本转换为纯文本?让我们说谷歌Chrome?

OnClipboardChange:
if (A_EventInfo = "1") {
  Clipboard=%Clipboard%
}
return

这很完美,但是如何将它限制为仅限铬?如果我用#IfWinActive包装不做任何限制,那就随处可见。

#IfWinActive ahk_class Chrome_WidgetWin_1
  code goes here
#IfWinActive

2 个答案:

答案 0 :(得分:1)

我尝试创建一个小的单独脚本,这个就像你描述的那样适用于我(当我从Chrome浏览器中复制内容时剥离格式化):

#SingleInstance
#Persistent

SetTitleMatchMode, 2

OnClipboardChange:
if (A_EventInfo = 1) and (WinActive("Chrome")) {
  Clipboard=%Clipboard%
}
return

您当然可以使用WinActive("ahk_class Chrome_WidgetWin_1")代替WinActive("Chrome"),就像您在示例中所做的那样,这也有效。

答案 1 :(得分:1)

完整代码以删除chrome和firefox上的文本格式:

#SingleInstance
#Persistent

SetTitleMatchMode, 2

OnClipboardChange:
if (A_EventInfo = 1) and WinActive("ahk_class Chrome_WidgetWin_1") or WinActive("ahk_class MozillaWindowClass") {
 Clipboard=%Clipboard%
}
return