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

Autohotkey - convert clipboard formatted text to plain text

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

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

这很完美,但如何将其限制为仅 chrome?如果我用#IfWinActive 包装,则不做任何限制,随处可用。

#IfWinActive ahk_class Chrome_WidgetWin_1
  code goes here
#IfWinActive

我尝试创建一个单独的小脚本,正如您所描述的那样,这个脚本对我有用(当我从 Chrome 浏览器复制内容时去除格式):

#SingleInstance
#Persistent

SetTitleMatchMode, 2

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

您当然可以使用 WinActive("ahk_class Chrome_WidgetWin_1") 而不是您在示例中所做的 WinActive("Chrome"),这也有效。

删除 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