AutoHotkey - Scrolling two PDF documents

Solution 1:

Found the solution:

WheelDown::
SetTitleMatchMode, 2
IfWinActive, Notepad ;
{
        CoordMode, Mouse, Screen
    WinGet, active_id, ID, A        
    WinGet, id, list, Adobe,, Program Manager
        Loop, %id%
    {
        Send {WheelDown}
            this_id := id%A_Index%
            WinActivate, ahk_id %this_id%
            Send {WheelDown}
            Send {WheelDown}
            WinActivate, ahk_id %active_id%
        }

}
Else
{
        Send {WheelDown}
}
return

WheelUp::
SetTitleMatchMode, 2
IfWinActive, Notepad ;
{
        CoordMode, Mouse, Screen
        WinGet, active_id, ID, A
        WinGet, id, list, Adobe,, Program Manager
        Loop, %id%
    {
        Send {WheelUp}
            this_id := id%A_Index%
            WinActivate, ahk_id %this_id%
            Send {WheelUp}
            Send {WheelUp}
            WinActivate, ahk_id %active_id%
        }
        }
        Else
        {
                Send {WheelUp}
        }
return

Now it works. You need Adobe Acrobat Reader (or acrobat Pro, something with acrobat) and Notepad.

How it works:

  1. Open the PDFs that you want to scroll synchronously.

  2. Open one Notepad window (this will be the control window so you can also scroll the PDFs autonomously (each separately). The Notepad window can be re-sized really small.

  3. Click the Notepad window and scroll away.

Each PDF gets selected and scrolled as you scroll in the Notepad window. Select each PDF manually if you want to scroll it alone.

Solution 2:

Here's a simpler solution that doesn't require a notepad window. You might need to change the window title from "Adobe Reader" to however an acrobat window is titled. This loops through all the windows called "Adobe Reader", and hits CTRL-SHIFT-N to increment the page number

SetTitleMatchMode 2 ; Match anything with Adobe Reader anywhere in the title
WinGet, id, list,Adobe Reader,, Program Manager

    this_id := id1 ; Activate the first window, and find the current page number
    WinActivate, ahk_id %this_id%
    WinWaitActive, ahk_id %this_id%


Send, {CTRLDOWN}N{CTRLUP}
Sleep, 30
WinGetText, text  ; 

StringSplit, word_array, text, `n  ; The current page number is on the 3rd line of returned text
nextpage := word_array3
nextpage += 1  ; Increment and store the current page number

Send, %nextpage%{ENTER}
Sleep, 30


Loop, %id%  ; now loop through the rest of the windows and set each to the same page.
{
    this_id := id%A_Index%
    WinActivate, ahk_id %this_id%
    WinWaitActive, ahk_id %this_id%
    Send, {CTRLDOWN}N{CTRLUP}
    Sleep, 30
    Send, %nextpage%{ENTER}
    Sleep, 30

}