Reputation: 18010
I used following AutoHotKey code to display the "Go to page" dialog in Adobe Reader:
SetTitleMatchMode, 2
#ifWinActive Adobe Reader
p:: Send ^+n
#ifWinActive
The problem is that it prevents me from typing the P key in find text box. How can I disable that shortcut while typing?
Upvotes: 0
Views: 390
Reputation: 7953
This will allow you to press p in Acrobat Reader and jump to the next page. When you press ^f to search, pressing p will just result is a p being sent, until you press Enter, which will return the pressing p behavior into sending ^N again.
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.
I have NOT tested this with Acrobat Reader, as I use Foxit, but I tested it with Notepad, where it performed as expected.
Upvotes: 2
Reputation: 9925
This is based on your comment that you use Ctrl+F to open the search box, type the text, and end by pressing enter:
Edited the code based on the OPs comment:
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
I have added an ESC hotkey to do the same thing as Enter, because you might use ESC to quit the find dialog. Additionally, in my version of Adobe Reader pressing Enter is also used as a shortcut for Find Next, so if I were you I would disable the Enter hotkey and use only ESC to escape the find dialog.
Finally, a general tip: It is usually easier to use hotkeys like Ctrl+P than just p to avoid complications like these. In fact if you don't use the print command which Ctrl+P triggers, you might consider using Ctrl+P instead of p as your hotkey (or even if you do print, but only rarely, since you would still be able to still access the print command from the menu)
Upvotes: 2