0

我使用以下 AutoHotKey 代码在 Adob​​e Reader 中显示“转到页面”对话框:

SetTitleMatchMode, 2

#ifWinActive Adobe Reader
    p:: Send ^+n
#ifWinActive

问题是它阻止我P在查找文本框中键入密钥。如何在键入时禁用该快捷方式?

4

2 回答 2

2

这将允许您在 Acrobat Reader 中按 p 并跳转到下一页。当您按 ^f 进行搜索时,按p只会导致 ap 被发送,直到您按 Enter,这将返回按p行为再次发送 ^N。

SetTitleMatchMode, 2 ; Put this line in the beginning of your script to allow flexible searching in the window title.

#ifWinActive Adobe Reader ; The following lines ONLY work inside Acrobat Reader.
    ~^f::ARSearchActive = 1 ; Let ^f go through to the O/S and set a variable.
    ~Enter::ARSearchActive = 0 ; Let Enter go through to the O/S and reset the variable.

    p:: ; Action to do when p is pressed
    If (ARSearchActive = 1) ; This is true AFTER you pressed ^f.
        Send, p ; If search has been activated, just send p
    else ; This is true after you pressed Enter.
        Send, ^+n ; If search is not activated, send ^N
    Return
#ifWinActive ; End of Adobe Reader specific portion.

我没有使用 Acrobat Reader 对此进行测试,因为我使用的是 Foxit,但我使用记事本对其进行了测试,并按预期执行。

于 2012-10-06T18:32:55.917 回答
2

这是基于您使用Ctrl+F打开搜索框、键入文本并按 Enter 键结束的评论:

根据 OPs 注释编辑了代码:

SetTitleMatchMode, 2

mode := "hotkey_mode"

#If, WinActive("Adobe Reader") && mode = "hotkey_mode"
    p:: Send ^+n

    ~^f::
        Hotkey If, WinActive("Adobe Reader") && mode = "hotkey_mode"
        Hotkey p, off
    return

    ~Enter::
    ~Esc::
        Hotkey IfWinActive, Adobe Reader
        Hotkey p, on
    return

    ^t::mode := "typing_mode"   

#If, WinActive("Adobe Reader") && mode = "typing_mode"
    ^t::mode := "hotkey_mode" 
#If

我添加了一个ESC热键来做同样的事情Enter,因为你可能会用它ESC来退出查找对话框。此外,在我的 Adob​​e Reader 版本中,按下Enter也用作Find Next的快捷方式,所以如果我是你,我会禁用Enter热键并仅ESC用于转义查找对话框。

Ctrl最后,一般提示:使用+之类的热键通常Pp避免此类并发症更容易。实际上,如果您不使用Ctrl+P触发的打印命令,您可能会考虑使用Ctrl+P而不是p作为您的热键(或者即使您打印,但很少,因为您仍然可以从菜单)

于 2012-10-07T16:49:22.040 回答