The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Default window doesn't open after running Applescript Thread Tools Search this Thread Display Modes
I'm having an issue with OmniFocus's behavior after running an Applescript. Here's what happens to me on multiple machines:

1) Open an Omnifocus window. Close it with Command-W or the red button. Note that clicking on the dock icon brings your Omnifocus window back to the foreground.

2) Execute the following Applescript with the Omnifocus window closed. This is the simplest Applescript that I can reproduce the problem with:

Code:
tell application "OmniFocus"
	tell the default document to tell the front document window
		set perspective name to "Inbox"
	end tell
end tell
3) Click on the Omnifocus icon in the dock. The document no longer opens and I need to open a new window with File->New Window or Command-Option-N to use the app again. Quitting the application and relaunching fixes the behavior until the script is run again.

Am I doing something wrong in my Applescript, or is this a bug in Omnifocus? Is there any sort of workaround? I want to be able to use this to periodically export data, so running it with the window open isn't always possible.
 
I'm not positive that's a bug, but I can reproduce the behavior and it's certainly not helpful, so I'm going to write it up that way. :-)

Suggested workaround in the meantime would be to make a new window with the "visible" property set to False, do the export, then close the hidden window. Does that help?

I'll give this a stab, but I have more experience scripting OmniOutliner or OmniGraffle, so just in case you beat me to it, I thought I'd post the suggestion before I had a script together...

Last edited by Brian; 2010-10-29 at 03:06 PM.. Reason: "hidden" -> "visible"; "property set" -> "property set to false"
 
Hmmm... okay, I'm able to work around the bug in the following while visible is set to true, but once I run the script with that set back to false, I get the same 'no window' response to a click on the dock icon.

Code:
tell application "OmniFocus"
	tell the default document
		set theWindow to make new document window with properties {visible:false, perspective name:"Inbox"}
		close theWindow
	end tell
end tell

It may be that the best option is a script that opens the window, does the export, then closes the window for the time being. Apologies!

(Attaching this info to the bug I filed, as well.)
 
Quote:
Originally Posted by Brian View Post
Hmmm... okay, I'm able to work around the bug in the following while visible is set to true, but once I run the script with that set back to false, I get the same 'no window' response to a click on the dock icon.
)
Thanks for your help. I can reproduce it with visible set either way. Setting visible to true pops up the window, the export is completed, then the dock icon no longer works. Interestingly, the export doesn't appear to be happening if visible is set to false.

Code:
tell application "OmniFocus"
	tell default document		
		set theWindow to make new document window with properties {visible:true}
		tell theWindow
			set perspective name to "Home"
			save in "Users:username:Dropbox:HomeContextExportForMobile" as "HTML"
			close
		end tell
	end tell
end tell
 
Quote:
Originally Posted by ryans View Post
Interestingly, the export doesn't appear to be happening if visible is set to false.
When a window is made invisible, the Applescript interface to it is destroyed and has to be recreated. This is a bug which I reported [OG #556132] when writing my Where in OF script, which resorts to workarounds at more than one point. (Likewise the 'Home Page' toolbar button)

I think Tim indicated that he had some insight into why this might occur. My guess is that it is relevant to the problems described in this thread.

A simple illustration:
Code:
tell application id "com.omnigroup.omnifocus"
	tell default document
		set oWin to make new document window
		display dialog (id of oWin) as string with title "id of new Window"
		
		set visible of oWin to false
		display dialog (id of oWin) as string with title "id of new Window once invisible" -- fails.
		
	end tell
end tell

Last edited by RobTrew; 2012-07-17 at 07:13 AM.. Reason: Updated link to Where in OF
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ: Installing & running an OF applescript RobTrew OmniFocus Extras 33 2013-05-19 12:36 AM
Can All Notes Always be Open by Default themothertucker OmniFocus 1 for Mac 10 2009-03-29 10:57 PM
Open Perspective by Default Shutter OmniFocus 1 for Mac 8 2008-10-31 03:51 PM
How to open OF with a default Perspective? GreenLorax OmniFocus 1 for Mac 5 2008-01-14 12:14 PM
How to set default window location? migueld OmniWeb General 5 2006-11-20 10:57 AM


All times are GMT -8. The time now is 10:06 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.