- Registriert
- 15.12.08
- Beiträge
- 3.545
Hi!
Zu aller erst möchte ich mal sagen, dass ich bei weitem kein AppleScript Guru bin, eher als Anfänger einzuordnen.
Ich will endlich mal ein bisschen automatische Fensterpositionierung haben, wie z.B. die Programme Cinch oder Divvy das machen.
Also dachte mir, dass man so ein ähnliches Fenstermanagement, zumindest vorerst für den Finder, bestimmt auch mit AppleScript erledigen könnte. So hab ich mal ein AppleScript geschrieben, das tatsächlich zu funktionieren scheint...
Jetzt geht es mir dabei vor allem um die Performance, d.h. wie führt man das Teil möglichst schnell aus?
Ich hab es schon als Service probiert - zu langsam. Als Applikation gespeichert - schon schneller, aber wie startet man diese möglichst schnell und wenn es geht per Shortcut ? Das Teil ins Dock legen will ich auch nicht und Spotlight is auch nich so mein Ding.
Daher bin ich für alle Arten von Verbesserungsvorschlägen dankbar, d.h. falls No-Gos drin sind, gravierende Fehler oder einfach nicht performante Befehle. Auch Tipps zum AppleScript Stil oder wie ich die Applikation möglichst schnell starte wären sehr hilfreich.
Danke und Gruß,
Guy.brush
Zu aller erst möchte ich mal sagen, dass ich bei weitem kein AppleScript Guru bin, eher als Anfänger einzuordnen.
Ich will endlich mal ein bisschen automatische Fensterpositionierung haben, wie z.B. die Programme Cinch oder Divvy das machen.
Also dachte mir, dass man so ein ähnliches Fenstermanagement, zumindest vorerst für den Finder, bestimmt auch mit AppleScript erledigen könnte. So hab ich mal ein AppleScript geschrieben, das tatsächlich zu funktionieren scheint...

Code:
-- ordnet 2 Finderfenster am oberen Rand an
-- für eine Auflösung von 1920x1200
set screen_width to 1920
set screen_height to 1200
set dock_height to 150 -- mit etwas Freiraum
set margin_west to 150 -- Seitenabstand links
set margin_east to 230 -- Seitenabstand rechts
-- Maße für Fenster
set finder_width to (screen_width - (margin_west + margin_east)) / 2
set finder_height to ((screen_height - dock_height) / 2)
tell application "Finder"
-- kein Finderfenster vorhanden
if not (the first window exists) then
set window1 to make new Finder window
set sidebar width of window1 to 100
set the target of window1 to (folder (path to home folder))
set the bounds of window1 to {margin_west, 0, margin_west + finder_width, finder_height}
set window2 to make new Finder window
set the target of window2 to (folder (path to home folder))
set the bounds of window2 to {margin_west + finder_width, 0, margin_west + finder_width * 2, finder_height}
-- ein Finderfenster vorhanden
else if not (the second window exists) then
set the bounds of the first window to {margin_west, 0, margin_west + finder_width, finder_height}
set window3 to make new Finder window
set the target of window3 to (folder (path to home folder))
set the bounds of window3 to {margin_west + finder_width, 0, margin_west + finder_width * 2, finder_height}
-- beide vorhanden
else
set the bounds of the first window to {margin_west, 0, margin_west + finder_width, finder_height}
set the bounds of the second window to {margin_west + finder_width, 0, margin_west + finder_width * 2, finder_height}
end if
activate
end tell
Jetzt geht es mir dabei vor allem um die Performance, d.h. wie führt man das Teil möglichst schnell aus?
Ich hab es schon als Service probiert - zu langsam. Als Applikation gespeichert - schon schneller, aber wie startet man diese möglichst schnell und wenn es geht per Shortcut ? Das Teil ins Dock legen will ich auch nicht und Spotlight is auch nich so mein Ding.
Daher bin ich für alle Arten von Verbesserungsvorschlägen dankbar, d.h. falls No-Gos drin sind, gravierende Fehler oder einfach nicht performante Befehle. Auch Tipps zum AppleScript Stil oder wie ich die Applikation möglichst schnell starte wären sehr hilfreich.
Danke und Gruß,
Guy.brush