2013-02-23 2 views
1

이전에 발견 한 일부 AppleScript를 수정하여 화면의 가장 자리에서부터 화면/도킹/메뉴 바 가장자리까지 각면에 10 픽셀의 여백이 있습니다.AppleScript로 모든 창에 대해 창 경계 설정

set front_app to (path to frontmost application as Unicode text) 

tell application "Finder" 
    set _b to bounds of window of desktop 
    set scrn_width to item 3 of _b 
    set scrn_height to item 4 of _b 
end tell 

tell application front_app 
    activate 
    set bounds of window 1 to {10, 35, (scrnWidth - 10), (scrnHeight - 80)} 
end tell 

문제는 각 창마다 개별적으로해야한다는 것입니다. 한 번 실행하고 각 응용 프로그램의 모든 창에서 작동하도록하고 싶습니다.

약 5 개의 스크립트를 수정하려고 시도했지만 오류가 발생했습니다. 여기에 내가 무엇을 가지고 있습니다 :

tell application "System Events" 
    tell application "Finder" 
     set _b to bounds of window of desktop 
     set scrn_width to item 3 of _b 
     set scrn_height to item 4 of _b 
    end tell 
    set _windows to get windows of (application processes whose visible is true) 
    repeat with this_window in (items of _windows) 
     set bounds of this_window to {10, 35, (scrn_width - 10), (scrn_height - 80)} 
    end repeat 
end tell 

어떤 도움을 주실 수 있습니다!

답변

2

약간의 작업을 마친 다음 여기에 나와 있습니다.

tell application "System Events" 
    set frontmostApps to every process whose frontmost is true 
    if ((count of frontmostApps) = 0) then return 
    set frontmostAppAlias to application file of (item 1 of frontmostApps) 
end tell 

tell application "Finder" to set desktopBounds to bounds of window of desktop 

set screenWidth to item 3 of desktopBounds 
set screenHeight to item 4 of desktopBounds 

tell application (frontmostAppAlias as string) 
    set resizableAppWindows to every window whose resizable is true 
    repeat with i from 1 to (count of resizableAppWindows) 
     set appWindow to item i of resizableAppWindows 
     set bounds of appWindow to {10, 35, (screenWidth - 10), (screenHeight - 80)} 
    end repeat 
end tell 

나는 원래 tell app "System Events" 블록 내에서 모든 일을하려고 시작했다, 그러나 application process ES의 window들, 정상 window의 같은 호출을 허용하지 않는 것 발견 심지어 스크립트 정의에서 비록 그들이 할까요. 이로 인해 tell 블록이 앱 자체에 직접 연결되었습니다.

try 블록에 set bounds을 두는 것이 좋습니다. 최대 크기 제한이 설정되어있는 크기 조정 가능한 윈도우가있는 앱이 있기 때문에 오류가 발생할 수 있습니다.

+0

고마워요! 나는 오픈 애플 리케이션을 반복 할 수 있도록 약간 수정했다. (어느 정도 시간이 걸렸지 만, 하하 - 나는 애플 스크립트에별로 좋지 않다.) https://gist.github.com/anonymous/5020503 –