View Single Post
Hello, this may come a little bit late, but I have had the same problems with scripting for Quicksilver, which I believe is similar to Launchbar. I have some other fixes.

I have tasted my ways of doing stuff for everything, but a helpwindow on top.

I execute dialogs within the realm of SystemUIServer, because SystemUIserver is faster, since it knows both which screen, and space you are on, I think SystemEvents and Finder are as smart, but not as fast.

Code:
		tell application "SystemUIServer"
			activate
			try
				set failed to false
				display dialog theTime & " will be copied to the Clipboard!" with title procName with icon file clockIcon buttons {"Cancel", "Ok"} default button 2
				set the clipboard to theTime
			on error
				set failed to true
			end try
		end tell
(There is one detail to note here, that I don't process the errors from the dialog within the scope of SystemUiServer, I postpone that until I'm back into the scope of my script! )

However, since those scripts are in the middle of workflows, I'm pretty picky about specifying default buttons, and cancel buttons, so the script is fully operationable from the keyboard.

When the script is finished, I prefer My screen to be in the same state that I left it, with the same window fully active, without Me having to do anything.
I have this little hack with systemevents pressing down ctrl-F4 for Me, to do that, this will work with every app I think, since it is an OS-function, at least it works with Preview.

Code:
	tell application "System Events" to tell application process frontapp
			key down control
			key code 118
			key up control
		end tell
(There is one caveat with this, your screen is exactly as you left it, but! If your first action is to hit return, then you have to hit it twice, I consider this more a feature, than a bug. )