20260428

Finderウィンドウを同じサイズ再作成して、ちょっとずらして新規WIndowで開く

Finderウィンドウを同じサイズ再作成して、ちょっとずらして新規WIndowで開く

NOTE記事一覧ですnote.com

【スクリプトエディタで開く】 |

Clone Window.app.scpt
ソース
001#!/usr/bin/env osascript
002use AppleScript version "2.8"
003use scripting additions
004
005
006tell application "Finder"
007   set numCntWindow to (count of every window) as integer
008end tell
009if numCntWindow = 0 then
010   return "Windowがありません"
011end if
012tell application "Finder"
013   set listSelection to selection
014   tell front Finder window
015      #      properties
016      try
017         set aliasFolderPath to (its target) as alias
018      on error
019         set aliasFolderPath to (path to desktop folder from user domain) as alias
020      end try
021      set listPosition to position as list
022      set listBounds to bounds as list
023      set objCurrentView to current view
024      set boolToolbar to toolbar visible as boolean
025      set boolStatusbar to statusbar visible as boolean
026      set boolPathbar to pathbar visible as boolean
027      set numSidebarWidth to sidebar width as integer
028   end tell
029end tell
030
031set {pL, pT} to listPosition as list
032set {bL, bT, bR, bB} to listBounds as list
033
034set listPosition to {(pL + 25), (pT + 25)} as list
035set listBounds to {(pL + 25), (pT + 25), (bR + 25), (bB + 25)} as list
036
037
038tell application "Finder"
039   make new Finder window
040   tell front Finder window
041      set target to aliasFolderPath
042      set position to listPosition
043      set bounds to listBounds
044      set current view to objCurrentView
045      set toolbar visible to boolToolbar
046      set statusbar visible to boolStatusbar
047      set pathbar visible to boolPathbar
048      set sidebar width to numSidebarWidth
049   end tell
050   set selection to listSelection
051end tell
052return
AppleScriptで生成しました