LoginSignup
1
0

More than 5 years have passed since last update.

ApplescriptでPDFに保管

Last updated at Posted at 2014-12-25

VitalSourseのBookShelfからPDFにする方法です。
面倒臭かったのでスクリプト化してみました。備忘録がてら投稿してみます。
はじめての投稿はまさかのApplescriptとは。

そもそもVitalSourseBookshelfなるものが
印刷したいのに10枚ずつしか出力できないのを
少しでも楽しようと思って、開始ページを入力すれば10ページ先まで印刷するScriptを応用しました。
ただ、決まりきったキーを押していくだけなんですが、
かなり楽になりました。

きっと印刷部分を繰り返しにして10ページごとに繰り返してくれるのが理想なんだけど。

PDFsave
--開始のページを取得
set Start_val to text returned of ¬
    (display dialog ¬
        "最初のページを入力してください" with title ¬
        "印刷ページの先頭指定" default answer ¬
        "1" buttons {"OK", "Cancel"} ¬
        default button 1 cancel button 2)

--一度に出力できる枚数
set Incriment_Val to 10

tell application "VitalSource Bookshelf"
    activate
    delay 1

    --プリントのショートカットキー
    tell application "System Events" to keystroke "p" using command down
    delay 1

    --開始ページの指定
    tell application "System Events" to keystroke Start_val as string
    tell application "System Events" to keystroke tab

    --終了ページの指定
    tell application "System Events" to keystroke Start_val + Incriment_Val - 1 as string
    tell application "System Events" to keystroke tab
    tell application "System Events" to keystroke return
    tell application "System Events" to keystroke return
    delay 3
end tell

activate application "VitalSource Bookshelf"
tell application "System Events"
    tell process "Bookshelf"
        click menu button "PDF" of window "プリント"
        click menu button "PDF" of window "プリント"
        delay 1

        --キー下を2回押下してPDFで保管...を選択
        tell application "System Events" to keystroke (ASCII character 31)
        tell application "System Events" to keystroke (ASCII character 31)
        tell application "System Events" to keystroke return

        delay 2

        --ここは文字の選択を解除するため
        tell application "System Events" to keystroke (ASCII character 31)
        tell application "System Events" to keystroke (ASCII character 31)

        --ファイル名の入力
        tell application "System Events" to keystroke Start_val as string
        tell application "System Events" to keystroke "-" as string
        tell application "System Events" to keystroke Start_val + Incriment_Val - 1 as string
        delay 1
        tell application "System Events" to keystroke return

    end tell
end tell
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0