2015-11-03 91 views
1

我需要Apple腳本的幫助。我不擅長這件事。腳本是這樣的:更改窗口的邊界

(* 

This Apple script will resize any program window to an exact size and the window is then moved to the center of your screen. 
Specify the program name, height and width below and run the script. 

Written by Amit Agarwal on December 10, 2013 

*) 

set theApp to "Finder" 
set appHeight to 412 
set appWidth to 678 

tell application "Finder" 
    set screenResolution to bounds of window of desktop 
end tell 

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

tell application theApp 
    activate 
    reopen 
    set yAxis to (screenHeight - appHeight)/2 as integer 
    set xAxis to (screenWidth - appWidth)/2 as integer 
    set the bounds of the first window to {xAxis, yAxis, appWidth + xAxis, appHeight + yAxis} 
    tell application "Finder" to set the sidebar width of every Finder window to 142 
end tell 

我想調整Finder的大小,但沒有將它置於屏幕中央。可能嗎?

回答

0

邏輯是,你得到前窗的當前範圍。邊界中的前兩項是x軸上的起始水平點和y軸上的起始垂直點。 (換句話說,前兩個項目是左上角的座標) 一旦你有了這些,你設置了新的界限,保持邊界描述中的前兩個項目相同,然後將所需的寬度和高度添加到第二個要點調整窗口大小。

set theApp to "Finder" 
set appHeight to 412 
set appWidth to 678 

tell application theApp 
    activate 
    set {startHoriz, startVert, endHoriz, endVert} to bounds of the first window 
    set the bounds of the first window to {startHoriz, startVert, startHoriz + appWidth, startVert + appHeight} 
end tell 
tell application "Finder" to set the sidebar width of every Finder window to 142 

如果你想將窗口移動一直到左邊,你可以設置窗口的範圍之前更改startHoriz爲1。

+0

感謝您的回覆,但我這樣sloved:<設置該app爲「發現者」 集appHeight到412 集appWidth至678 告訴應用該app \t激活 \t重新 \t告訴應用程序「發現者」到設置的每個搜索窗口142 的側邊欄寬度端告訴 告訴應用程序「系統事件」 \t告訴處理該app \t窗1的\t集大小爲{appWidth,appHeight} \t end tell end tell>最後,我只需在System Preferences面板中添加Apple Script Editor.app:安全和隱私➡隱私➡輔助功能。 ︎ – user5520752

+0

這很好,如果它適合你。這在您切換應用程序時不起作用。如果應用程序可編寫腳本,最好避免使用UI腳本。 – jweaks