Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make a script that scrolls all the opened PDF documents at the same time. The problem is that I can not get it to work unless I specifically name each window that has to be scrolled and send the actions to it. Also, in the current state I need to catch the scroll event in another window (ex: Notepad) but this is actually ok since I may also want to scroll some of the PDFs manually and then resume synchronous scrolling.

Here's my workflow:

  1. Open 2 or more PDF documents.
  2. Open a Notepad file and start scrolling into the notepad file.

Result: All opened PDFs start scrolling.

Here's my code (borrowed from the interwebz :)

WheelDown::
SetTitleMatchMode, 2
IfWinActive, Notepad ; Replace 'SafariTitle' by the title of the safari windows
{
        CoordMode, Mouse, Screen
        WinGet, active_id, ID, A
        IfWinExist, Adobe
        {
                Send {WheelDown}
                WinActivate ; Automatically uses the window found above.
                Send {WheelDown}
                Send {WheelDown}
                WinActivate, ahk_id %active_id%
        }

}
Else
{
        Send {WheelDown}
}
return

WheelUp::
SetTitleMatchMode, 2
IfWinActive, Notepad ; Replace 'SafariTitle' by the title of the safari windows
{
        CoordMode, Mouse, Screen
        WinGet, active_id, ID, A
        IfWinExist, Adobe
        {
                Send {WheelUp}
                WinActivate ; Automatically uses the window found above.
                Send {WheelUp}
                Send {WheelUp}
                WinActivate, ahk_id %active_id%
        }
        }
        Else
        {
                Send {WheelUp}
        }
return

Right now it works for scrolling only one PDF.

How can I get it to look and scroll through all of them?

share|improve this question

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

}
share|improve this answer
up vote 1 down vote accepted

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.

share|improve this answer

Just wanted to mention that I tried the Brett Bymaster Feb 28 2014 script and it worked perfectly.

Then I made a modification, changing "WheelDown" to "PgDn" and "WheelUp" to "PgUp" throughout - this let me use the PgUp and PgDn keys to scroll a page at a time, rather than the mouse wheel to scroll a few lines at a time - which is exactly what I was looking for. I was able to fly through a pair of PDFs very quickly and visually verify that they pretty much identical, and spot where they differed.

The ability this approach providess to click on the individual Adobe windows to scroll the documents separately is great, because (1) I had some cases where the sync scrolling got off by a page (probably pushing the key too fast :) and this allowed me to get it back in sync, and (2) you can select similar sections from 2 different PDFs that don't necessarily line up on the same page and compare them.

Good stuff and thanks!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .