• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Was gibt es Schöneres als den Mai draußen in der Natur mit allen Sinnen zu genießen? Lasst uns teilhaben an Euren Erlebnissen und macht mit beim Thema des Monats Da blüht uns was! ---> Klick

Fensterlayout

fyysh

Schweizer Glockenapfel
Registriert
25.01.10
Beiträge
1.386
hmm.

Und jEdit zeigt bei dir nicht die Hilfe an beim Start?
Und die Tipps of the Day haste auch aus?

Ich glaub da fehlt nur ne doofe Verzögerung, dann klappt's.
Und nicht cmd+n an jEdit senden... schon gar nicht so oft... *g

Also sooo
Code:
set fancyApps to {¬
	{appBI:"com.apple.Terminal", sendCMDN:true, wPos:{1280 / 2, 0}, wSize:{1280 / 2, 800 / 2}}, ¬
	{appBI:"com.apple.finder", sendCMDN:true, wPos:{1280 / 2, 800 / 2 + 17}, wSize:{1280 / 2, 800 / 2 - 17}}, ¬
	{appBI:"org.gjt.sp.jedit", sendCMDN:false, wPos:{0, 0}, wSize:{1280 / 2, 800}} ¬
		}



repeat with aApp in fancyApps
	mvWin(appBI of aApp, sendCMDN of aApp, wPos of aApp, wSize of aApp)
end repeat

return



on mvWin(procBI, sendCMDN, wPos, wSize)
	tell application "System Events"
		repeat with i from 1 to 5
			try
				set aProc to (some process whose bundle identifier is procBI)
				set the frontmost of aProc to true --bring to front
				exit repeat
			on error
				--tell me to tell application procName to activate
				tell me to do shell script "open -b " & procBI
				delay 5
			end try
		end repeat
		
		--check wincount
		repeat until (count of windows of aProc) > 0
			if (count of windows of aProc) < 1 then
				tell aProc
					set its frontmost to true
					if sendCMDN then keystroke "n" using {command down}
				end tell
			end if
			delay 0.5
		end repeat
		
		tell aProc
			tell window 1 of aProc
				set position to wPos
				set size to wSize
			end tell
		end tell
	end tell
end mvWin

oder à la Sedna, aber mit Fischgeruch :D
Code:
tell application "Finder"
	activate
	try
		close every Finder window
		set x to make new Finder window to folder "Documents" of home
	end try
	set bounds of x to {640, 444, 1280, 844}
end tell


tell application "Terminal"
	activate
	set bounds of window 1 to {640, 0, 1280, 400}
end tell


set jEditBI to "org.gjt.sp.jedit"
do shell script "open -b " & jEditBI
delay 5


tell application "System Events"
	
	set nRetry to 0
	set wCount to 0
	
	set jEProc to some process whose bundle identifier is jEditBI
	
	repeat until wCount > 0 or nRetry = 10
		set wCount to count of windows of jEProc
		set nRetry to nRetry + 1
		delay 2
	end repeat
	
	if nRetry = 10 then error "WTF! Klappt nicht mit jEdit"
	
	tell window 1 of jEProc
		set position to {0, 0}
		set size to {1280 / 2, 800}
	end tell
	
	
end tell
 

-hacki-

Alkmene
Registriert
16.08.09
Beiträge
33
Hallo nochmal,

danke jetzt klappt es mit dem Öffnen einwandfrei. Wenn ich anschließend aber jEdit schließe, dann springt die Menü leiste immer wieder auf jEdit. Also wenn ich auf den "Desktop" klicke springt es auf Finder, dann von selber wieder auf jEdit. Da läuft noch irgendeine Schleife ab oder?

edit: wenn ich jEdit mit rechtsklick, beenden im Dock schließe kommt manchmal die Fehlermeldung "application process "jEdit"" kann nicht gelesen werden.


MfG Felix
 

fyysh

Schweizer Glockenapfel
Registriert
25.01.10
Beiträge
1.386
Welches von den Scripten hast du benutzt?
 

-hacki-

Alkmene
Registriert
16.08.09
Beiträge
33
Deines, also das erste. Das zweite funktioniert aber auch nicht... -.-

Und noch zu deinem Posting oben. Hilfe beim Start wird nicht gezeigt und die Tipps des Tages sind deaktiviert.

LG
 

fyysh

Schweizer Glockenapfel
Registriert
25.01.10
Beiträge
1.386
Pass auf, log mal. Dazu paste folgendes Script in den Scripteditor (ist das selbe wie oben aber mit log-Befehlen zum mal gucken, was passiert):

Code:
set fancyApps to {¬
	{appBI:"com.apple.Terminal", sendCMDN:true, wPos:{1280 / 2, 0}, wSize:{1280 / 2, 800 / 2}}, ¬
	{appBI:"com.apple.finder", sendCMDN:true, wPos:{1280 / 2, 800 / 2 + 17}, wSize:{1280 / 2, 800 / 2 - 17}}, ¬
	{appBI:"org.gjt.sp.jedit", sendCMDN:false, wPos:{0, 0}, wSize:{1280 / 2, 800}} ¬
		}



repeat with aApp in fancyApps
	log logTime() & "info(me): calling mvwin with appBI:" & appBI of aApp & ", sendCMDN:" & sendCMDN of aApp & ", wPos:" & wPos of aApp & ", wSize" & wSize of aApp
	mvWin(appBI of aApp, sendCMDN of aApp, wPos of aApp, wSize of aApp)
end repeat

return



on mvWin(procBI, sendCMDN, wPos, wSize)
	tell application "System Events"
		log my logTime() & "info(mvwin): starting 1st loop"
		repeat with i from 1 to 5
			try
				set aProc to (some process whose bundle identifier is procBI)
				log my logTime() & "info(mvwin): got process whose bi is " & procBI
				set the frontmost of aProc to true --bring to front
				exit repeat
			on error
				log my logTime() & "warn(mvwin): error getting process whose bi is " & procBI
				--tell me to tell application procName to activate
				log my logTime() & "info(mvwin): opening " & procBI
				tell me to do shell script "open -b " & procBI
				delay 5
			end try
		end repeat
		log my logTime() & "info(mvwin): left 1st loop"
		
		--check wincount
		log my logTime() & "info(mvwin): starting 2nd loop"
		repeat until (count of windows of aProc) > 0
			if (count of windows of aProc) < 1 then
				log my logTime() & "info(mvwin): wincount of aProc < 1"
				tell aProc
					set its frontmost to true
					log my logTime() & "info(mvwin): set frontmost of aProc to true"
					if sendCMDN then
						keystroke "n" using {command down}
						log my logTime() & "info(mvwin): send cmd+n to aProc"
					end if
				end tell
			end if
			delay 0.5
		end repeat
		log my logTime() & "info(mvwin): left 2nd loop"
		
		
		log my logTime() & "info(mvwin): sizing & moving 1st window of aProc"
		tell aProc
			tell window 1 of aProc
				log my logTime() & "info(mvwin): position: " & item 1 of wPos & ":" & item 2 of wPos
				set position to wPos
				log my logTime() & "info(mvwin): size: " & item 1 of wSize & ":" & item 2 of wSize
				set size to wSize
			end tell
		end tell
	end tell
	
end mvWin


on logTime()
	return (hours of (current date) & ":" & minutes of (current date) & ":" & seconds of (current date) & space) as string
end logTime

Dann machst du, dass der Event Log angezeigt wird und klickst 2x auf Events, damit nur die ausgaben vom Log angezeigt werden. Vielleicht reicht das schon.

2011-02-15_1738.png

Und ein bisschen selber beobachten, wa? Ist das Script bspw. noch am Laufen, wenn es schon alle Fenster an ihre Position geschoben hat? (sollte es nämlich nicht).

Check ma.
 

-hacki-

Alkmene
Registriert
16.08.09
Beiträge
33
Hallo,

alles gemacht wie du gesagt hast :)

Also wenn dei Fenster verschoben wurden und ich jEdit schließe, dann tritt das oben beschriebene Problem auf (Wechsel jEdit - Klick auf Desktop --> Finder - jEdit usw.).
Im Eventlog wird dies durch eine "Endlos"schleife dargestellt

(*18:7:46 info(mvwin): wincount of aProc < 1*)
(*18:7:46 info(mvwin): set frontmost of aProc to true*)
... [diese beiden Zeilen wiederholen sich die ganze Zeit]
(*18:7:47 info(mvwin): wincount of aProc < 1*)
(*18:7:47 info(mvwin): set frontmost of aProc to true*)
[jetzt hab ich jEdit per Rechtsklick -> Beenden im Dock geschlossen]
Ergebnis:
error "„System Events“ hat einen Fehler erhalten: „application process \"jedit\"“ kann nicht gelesen werden." number -1728 from application process "jedit"

Grüße Felix
 

fyysh

Schweizer Glockenapfel
Registriert
25.01.10
Beiträge
1.386
Dachte ich's mir doch, dass der am endlos-loopen ist. Der erkennt das jEdit Fenster bei dir nicht. Warum nicht?

Und wenn das Script da rumloopt, dann kann es nicht sein, dass das jEdit-Fenster an die richtige Stelle gebracht/gesized wird. Die Position hat sich jEdit gemerkt - das ist nicht das Skript.

Und warum kann ich mit SysEvents das Fenster finden und du nicht!? Hast du da noch irgendwelche Helferlein im Hintergrund laufen, die das Erkennen des Fensters evtl. verhindern könnten? (BTT (aktuell) kann's nicht sein, das läuft bei mir auch... Cinch vielleicht? Irgendwas in der Art?) Schließ die mal alle.

Du musst mal sicherstellen, dass das:
tell app "system events"
set aProc to some process whose bundle identifier is "org.gjt.sp.jedit"
set wcount to count of windows of aProc
end

return wcount

>0 zurückgibt. Sonst geht das Script nicht. Kein Fenster da => Nix resizen/moven.

Oder du nimmst jalt jEdit raus, das merkt sich seine Position eh, und lässt nur Terminal & Finder drumrum anordnen.

Ich hab kein Plan, warum das bei dir nicht geht.

Samma, ist das an bei dir (müsste eigentlich, sonst hätte das Script bei count of windows nen Fehler zurückgegeben)?
2011-02-15_1834.png
 

-hacki-

Alkmene
Registriert
16.08.09
Beiträge
33
Also der Haken ist drin.

Grad nochmal versucht. Wenn ich jEdit verschiebe und das Skript starte macht er alles einwandfrei. Beim nächsten Start springt aber jEdit gleich an die richtige Stelle, weil es sich ja seine Position merkt und dann geht das Spielchen von oben wieder los... Das würde ja quasi bedeuten, dass der Loop stattfindet, wenn sich das jEdit Fenster bereits an der richtigen Stelle befindet oder passiert das bei dir auch nicht?

edit: Hmmm ich glaube ich war beim testen einfach nur zu schnell mit dem Schließen von jEdit. Da ist wohl eine Zeitverzögerung zwischen jEdit öffnen und Fenster verschieben oder? Und wenn ich zwischendrin das Fenster schließe, findet's das Skript nichtmehr. Kann das der Fehler sein?

LG
 

fyysh

Schweizer Glockenapfel
Registriert
25.01.10
Beiträge
1.386
Hmmm ich glaube ich war beim testen einfach nur zu schnell mit dem Schließen von jEdit.
Vergewissere dich doch mal in der Aktivitätsanzeige, dass jEdit auch wirklich beendet wurde und starte das Script erst dann nochmal, mehrmals*.

Dass beim ersten Loop der Prozess noch gefunden wird, beim zweiten aber dann nicht mehr existiert bzw. keine Fenster mehr hat und auch keine mehr haben wird, ist ein mehr als plausibler Grund für das beschriebene Verhalten. Und das fängt das Script in keinster Weise ab...


*
Also nicht mehrfach starten, sondern mehrmals vergewissern, dass jEdit tatsächlich beendet ist und dann erst das Script ausführen.
 
Zuletzt bearbeitet: