Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.