2014-02-26 2 views
1

정확히 어떻게했는지 기억이 나지 않지만 여러 AppleScript 덕분에 일부 소스 코드 덕분에 AppleScript를 실행 한 버틀러와 매핑 된 키보드 단축키를 사용했습니다.Finder 윈도우 목록 저장 및 복원

하나의 스크립트는 모든 Finder 윈도우 속성을 텍스트 파일 (이름에 대한 프롬프트)에 저장하고 다른 하나는 파일 (이름에 대한 프롬프트)을 읽고 그에 따라 Finder 윈도우를 복원하는 데 사용되었습니다. 그렇게 보일 것이다

텍스트 파일 : 거기에서

{ 
    { 
     folder "Desktop" 
     of folder "Me" 
     of folder "Users" 
     of startup disk of application "Finder", { 
      0, 0, 1200, 315 
     }, column view, 192 
    }, { 
     folder "Backups" 
     of disk "SAFE" 
     of application "Finder", { 
      0, 380, 1200, 685 
     }, column view, 192 
    } 
} 

, 나는 창문을 복원하는 방법을 알고있다. 난 그냥

이 창을 복원하려면 ... 그 모든 값을 검색, 내가 만든 스크립트를 분실 :

tell application "Finder" 

set windowList to { 
    { 
     folder "Desktop" 
     of folder "Me" 
     of folder "Users" 
     of startup disk of application "Finder", { 
      0, 0, 1200, 315 
     }, column view, 192 
    }, { 
     folder "Backups" 
     of disk "SAFE" 
     of application "Finder", { 
      0, 380, 1200, 685 
     }, column view, 192 
    } 
} 
close every window 

    repeat with i from 1 to count of windowList 
     set theseProps to item i of windowList 
     make new Finder window at front to item 1 of theseProps 
     tell window 1 
      set bounds to item 2 of theseProps 
      set current view to item 3 of theseProps 
      set sidebar width to item 4 of theseProps 
     end tell 
    end repeat 
end tell 

내 질문 : 어떻게 AppleScript로 모든 Finder 윈도우와 속성을 얻는 방법? 파일에 저장하는 방법은 무엇입니까?

[편집] 여기

어떻게 모든 속성이 필요 얻을 수 있습니다 :

set windowsList to {} 
tell application "Finder" 
    set theWindows to windows 
    repeat with theWindow in theWindows 
     set t to target of theWindow 
     set b to bounds of theWindow 
     set v to current view of theWindow 
     set w to sidebar width of theWindow 
     copy {t, b, v, w} to end of windowsList 
    end repeat 
end tell 

지금 나중에 목록으로로드 할 수있는, 파일이 저장 방법이 필요합니다 에 ...

[편집] I 파일이 w에 쓸 수 있어요

ay :

set prefs_folder to path to preferences folder as string 
set prefs_file to prefs_folder & "finderwindows" 
try 
    set open_file to ¬ 
     open for access file prefs_file with write permission 
    -- erase current contents of file: 
    set eof of open_file to 0 
    write windowList to open_file starting at eof 
    close access open_file 
on error 
    try 
     close access file prefs_file 
    end try 
end try 

그러나 파일은 비어 있습니다. 이 스크립트는

내 질문은 지금 ... 오류 -10004 함께 종료된다

는 어떻게 다음 다른 스크립트에서 읽고 검색 할 수있는 파일 저장 가능한 형식으로 windowList를 변환 ??

답변

2

FYI : 정확히이 작업을 수행하는 Simple WindowSet이라는 프로그램이 있습니다 ... Finder 윈도우를 저장하고 복원하십시오. 그것은 매우 인기가 있습니다. 그래서 당신이 애플 스크립트를 사용하여 질문 할 때 당신이 할 수는 있지만, 아마도 당신은 흥미를 가질 것입니다. 찾아보십시오 here.

귀하의 특정 질문에 대답하기 위해, 여기 파일에 쓰기 위해 사용하는 처리기가 있습니다. 행운을 빕니다.

on writeTo(targetFile, theData, dataType, apendData) 
    -- targetFile is the path to the file you want to write 
    -- theData is the data you want in the file. 
    -- dataType is the data type of theData and it can be text, list, record etc. 
    -- apendData is true to append theData to the end of the current contents of the file or false to overwrite it 
    try 
     set targetFile to targetFile as text 
     if targetFile does not contain ":" then set targetFile to POSIX file targetFile as text 
     set openFile to open for access file targetFile with write permission 
     if apendData is false then set eof of openFile to 0 
     write theData to openFile starting at eof as dataType 
     close access openFile 
     return true 
    on error 
     try 
      close access file targetFile 
     end try 
     return false 
    end try 
end writeTo