defaults-system

K

kay101011

hi

hab hier mein erstes kleines script geschrieben ... drumm
& habe noch ein kleines problem damit, erstmal das script:

tell application "Finder"
display dialog "Show system files and folders?" buttons {"Yes", "No"} default button 1 with icon caution
if button returned of result = "Yes" then
tell application "Terminal"
do script "defaults write com.apple.finder AppleShowAllFiles Yes"
end tell
display dialog "Now U can see it!" buttons "Cool!" default button 1
else
tell application "Terminal"
do script "defaults write com.apple.finder AppleShowAllFiles No"
end tell
display dialog "It's magic!" buttons "Wow!!" default button 1
end if
display dialog "You have to restart the Finder-Application to see new settings" buttons {"later", "restart"} default button "restart" with icon caution
if button returned of result = "later" then
display dialog "kay says god bye!" buttons {"Visit palsecam", "bye"} default button "bye" with icon note
if button returned of result = "Visit palsecam" then
tell application "Terminal"
do script "open http://www.palsecam.de"
end tell

end if
else
quit
run
display dialog "kay says god bye!" buttons {"Visit palsecam", "bye"} default button "bye" with icon note
if button returned of result = "Visit palsecam" then
tell application "Terminal"
do script "open http://www.palsecam.de"
end tell

end if
end if
end tell

was bewirkt es?? es macht, das man die systemdateien & ordner im finder sieht. so nun mein problem, danach würde ich gerne ein wenig aufräumen, aber da versagt die kunst! ich habe es so versucht:

tell application "Terminal"
run
count windows
repeat with i from 1 to result
display dialog i buttons {"OK"} default button 1
if busy of window i = false then
display dialog "This window is inactive! Close??" buttons {"No", "Yes"} default button 2
if the button returned of the result is "Yes" then
close window i
end if
else
display dialog "This window is active!" buttons {"OK"} default button 1
end if
end repeat
count windows
if result = 0 then
quit
end if
end tell

die dialogs sind nur zum debuggen. mit wenig fenstern funzt es ganz gut aber ab 4 kommen einfach fehlermeldungen die ich nicht verstehe!
 
...

Hallo kay101011,

versuch mal

repeat with i from 0 to result-1

Gruß Andi
 
Hallo kay101011,

du musst die Schleife rückwärts laufen lassen, sonst erhöht sich die Zählvariable i bei jedem Schleifendurchlauf wogegen die Anzahl der Fenster immer weniger wird.

tell application "Terminal"
___
run
___
count windows
___
repeat with i from result to 1 by -1
______
set Windex to index of window i
______
display dialog Windex buttons {"OK"} default button 1
______
if busy of window Windex = false then
_________
display dialog "this window is inactive! Close??" buttons {"No", "Yes"} default button 2
_________
if the button returned of the result is "Yes" then
____________
close window Windex
_________
end if
______
else
_________
display dialog "This window is active!" buttons {"OK"} default button 1
______
end if
___
end repeat
___
count windows
___
if result = 0 then
______
beep 2
___
end if
end tell


Gruß
 
Sorry, sieht etwas seltsam aus.

Dass ich extra noch mit "index of window i" gearbeitet habe, diente übrigens nur zu Testzwecken.

Du könntest übrigens zuerst auch eine Liste der Fenster erstellen, diese Liste dann mit "reverse" umkehren und sie dann in Vorwärtsreihenfolge abarbeiten.

tell application "Terminal"
___
___
set WinList to (index of every window)
___
set WinList to the reverse of WinList
___
repeat with i in WinList
______
if busy of window index i = false then
_________
display dialog "Window " & i & " is inactive! Close??" buttons {"No", "Yes"} default button 2
_________
if the button returned of the result is "Yes" then
____________
close window index i
_________
end if
______
else
_________
display dialog "This window is active!" buttons {"OK"} default button 1
______
end if
___
end repeat
___
count windows
___
if result = 0 then
______
beep 2
___
end if
___

end tell


Gruß
 
cool die zweite variante machts clap ...
sehr cool, danke snow!!
 
Zurück
Oben Unten