AutoHotkey - 捲動兩個 PDF 文檔

AutoHotkey - 捲動兩個 PDF 文檔

我正在嘗試製作一個腳本來同時滾動所有開啟的 PDF 文件。問題是,除非我專門命名每個必須滾動的視窗並向其發送操作,否則我無法讓它工作。另外,在當前狀態下,我需要在另一個視窗(例如:記事本)中捕獲滾動事件,但這實際上沒問題,因為我可能還想手動滾動一些 PDF,然後恢復同步滾動。

這是我的工作流程:

  1. 開啟 2 個或更多 PDF 文件。
  2. 開啟記事本文件並開始捲動到記事本文件。

結果:所有開啟的 PDF 開始捲動。

這是我的程式碼(從 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

目前它僅適用於滾動一個 PDF。

我怎樣才能讓它查看並滾動所有這些?

答案1

找到了解決方案:

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

現在可以了。您需要 Adob​​e Acrobat Reader(或 acrobat Pro,帶有 acrobat 的東西)和記事本。

怎麼運作的:

  1. 開啟您想要同步捲動的 PDF。

  2. 開啟一個記事本視窗(這將是控制窗口,因此您也可以自主捲動 PDF(每個單獨)。記事本視窗的大小可以調整得非常小。

  3. 點擊記事本視窗並滾動。

當您在記事本視窗中滾動時,每個 PDF 都會被選中並滾動。如果您想單獨捲動每個 PDF,請手動選擇它。

答案2

這是一個更簡單的解決方案,不需要記事本視窗。您可能需要將視窗標題從「Adobe Reader」變更為 acrobat 視窗的標題。這將循環遍歷所有名為“Adobe Reader”的窗口,並按 CTRL-SHIFT-N 增加頁碼

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

}

答案3

只是想提一下,我嘗試了 Brett Bymaster Feb 28 2014 腳本,效果非常好。

然後我進行了修改,將“WheelDown”更改為“PgDn”,將“WheelUp”更改為“PgUp” - 這讓我可以使用 PgUp 和 PgDn 鍵一次滾動一頁,而不是使用滑鼠滾輪滾動幾頁一次一行- 這正是我正在尋找的。我能夠非常快速地瀏覽一對 PDF,並直觀地驗證它們是否幾乎相同,並找出它們的差異。

這種方法提供的單擊各個AdAdobe 視窗來單獨滾動文檔的功能非常棒,因為(1) 我遇到過一些情況,同步滾動會偏離一頁(可能按鍵太快:),這使我能夠使其恢復同步,(2) 您可以從 2 個不同的 PDF 中選擇相似的部分(這些部分不一定排列在同一頁上)並進行比較。

好東西,謝謝!

相關內容