# [メタ情報] # 識別子: マイライブラリ画面2分割applescript_exe # システム名: 未分類 # 技術種別: Misc # 機能名: Misc # 使用言語: AppleScript # 状態: 実行用 # [/メタ情報] 要約:SafariでAppSheetの2つのURLを左右に並べて表示するAppleScript。メインディスプレイのサイズを取得し、画面を左右に分割して各URLをそれぞれの位置に開く。Safariを起動後、左側に1つ目のURLを新規ウインドウで開き、続いて右側に2つ目のURLを開く。もし新規ウインドウが作成されずタブ化された場合は、システムイベント経由で新規ウインドウを強制的に生成し、右側に配置する。 AppleScript use framework "AppKit" use scripting additions -- ====== 左右に並べたいURL ====== set leftURL to "<任意のURLアドレス>" set rightURL to "<任意のURLアドレス>" -- ====== メインディスプレイのフレームを取得({{x,y},{w,h}})→分解 ====== set mainFrame to (current application's NSScreen's mainScreen()'s frame()) set {{ox, oy}, {screenW, screenH}} to (mainFrame as list) -- メイン画面内で左右 1/2 のウインドウ座標(bounds は {left, top, right, bottom}) set leftBounds to {ox, oy, ox + (screenW / 2), oy + screenH} set rightBounds to {ox + (screenW / 2), oy, ox + screenW, oy + screenH} -- ====== Safariで2ウインドウを用意して左右に配置 ====== tell application "Safari" activate -- 左 make new document with properties {URL:leftURL} set bounds of front window to leftBounds delay 0.5 -- 右(タブ化されたらフォールバック) make new document with properties {URL:rightURL} delay 0.2 if (count of windows) < 2 then tell application "System Events" to tell process "Safari" -- 初回のみ アクセシビリティの許可が必要 click menu item 1 of menu 1 of menu bar item "ファイル" of menu bar 1 end tell delay 0.3 set URL of front document to rightURL end if set bounds of front window to rightBounds end tell