AutoHotKey:合并监视Firefox和其他程序中选择的脚本

时间:2016-02-12 12:38:48

标签: autohotkey

我正在努力使用一个脚本来监视FireFox,Adobe Acrobat和另外一个程序中的鼠标选择,然后将此选择复制到剪贴板并根据正则表达式进行更改。对于每个程序,需要另一个正则表达式。每个脚本都作为一个单独的程序工作,但是当我合并它们时,复制的文本不会根据我的正则表达式进行更改。

Adob​​e Acrobat脚本:

#ifWinActive ahk_class MozillaWindowClass
~LButton::
now := A_TickCount
while GetKeyState("LButton", "P")
    continue
if (A_TickCount-now > 600 )
{   
    Send ^c
    copied := true
}
return

OnClipboardChange2:
if !copied
    return

copied := false
ToolTip % Clipboard := RegExReplace(Clipboard, "[0-9]\.\s*|\s?\([^)]*\)|\.")
SetTimer, ToolTipOff1, -1000
return

ToolTipOff1:
ToolTip
return

并剥离Firefox:

-- CREATE VIEW contributors AS
TABLE  current_campaign
UNION ALL
TABLE  last_campaign   -- assuming matching row type
LIMIT  1;              -- applies to the whole query

1 个答案:

答案 0 :(得分:1)

#If仅适用于热键,不适用于标签。使用OnClipboardChange似乎是不必要的。当您按ctrl + c时,您已经知道剪贴板已更改 我还建议为热键和#If语句设置缩进 我将如何做到这一点:

#If WinActive("ahk_class AcrobatSDIWindow") || WinActive("ahk_class MozillaWindowClass")
    ~LButton::
        now := A_TickCount
        while GetKeyState("LButton", "P")
            continue
        if (A_TickCount-now > 600 )
        {   
            Send ^c
            if WinActive("ahk_class AcrobatSDIWindow")
            {
                regex := "\r\n"
                replace := " "
            }
            else if WinActive("ahk_class MozillaWindowClass")
            {
                regex := "[0-9]\.\s*|\s?\([^)]*\)|\."
                replace := ""
            }
            ToolTip % Clipboard := RegExReplace(Clipboard, regex, replace)
            SetTimer, ToolTipOff, -1000
        }
    return
#If

ToolTipOff:
    ToolTip
return

(未测试的)

编辑:

.....
    ~Left::
    ~Right::
    ~Up::
    ~Down::
        now := A_TickCount
        while GetKeyState("Shift", "P")
            continue
        if (A_TickCount-now > 600 )
        {   
            oldShiftState := GetKeyState("Shift", "P")
            Send, {Shift Up}
            Send ^c
            If (oldShiftState)
                Send, {Shift Down}
            .....

(未测试的)

相关问题