I’m using OopsieFocus by Shawn Blank. I was regularly clicking my Quick Entry shortcut and sitting there waiting for something to happen…only to notice OF wasn’t open.
This script uses a launcher app (I’m using Keyboard Maestro) using the same keyboard shortcut as used in OF to launch Quick Entry to trigger the script. If OF is open, the default Quick Entry panel opens. If OF isn’t running, it launches OF, and then opens a Quick Entry panel.
My problem is that the Quick Entry panel isn’t active after opening OF and launching a Quick Entry panel. It is active if OF is already open (default behavior). I asked Shawn about this, and he sent me an updated script that is working for him. Same behavior. I played around with it to no avail.
Any advice would be greatly appreciated. Here’s the script I’m using:
– This script allows the opening of OmniFocus and a Quick Entry panel using the Quick Entry keyboard shortcut in OF in the event OF is not open.
– If OF is open, a Quick Entry pane is activated.
– Launch using a launcher app with the same keyboard shortcut as OF Quick Entry.
– This was written by Shawn Blanc
on appIsRunning(Omnifocus)
tell application “System Events”
return (count of (application processes whose name is Omnifocus)) is not 0
end tell
end appIsRunning
if appIsRunning(“OmniFocus”) then
null
else
tell application “OmniFocus”
activate
tell quick entry
make new inbox task
open
end tell
tell application “System Events”
keystroke tab
end tell
end tell
end if
Thanks…Brett
ps…how do I post this so my script structure remains?
I got this working last night. (Or, more accurately, I read and applied the work of others ;) last night.)
First, I saved this script to my ~/Library/Scripts folder:
-- This script allows the opening of OmniFocus and a Quick Entry panel using the Quick Entry keyboard shortcut in OF in the event OF is not open.
-- If OF is open, a Quick Entry pane is activated.
-- Launch using a launcher app with the same keyboard shortcut as OF Quick Entry.
-- This was written by Shawn Blanc
on appIsRunning(Omnifocus)
tell application "System Events"
return (count of (application processes whose name is Omnifocus)) is not 0
end tell
end appIsRunning
if appIsRunning("OmniFocus") then
null
else
tell application "OmniFocus"
activate
tell quick entry
make new inbox task
open
end tell
tell application "System Events"
keystroke tab
end tell
end tell
end if
Then I installed FastScripts because I can set a global hotkey to the script. I set the hotkey to the same combination as the Quick Entry combination in OmniFocus 2’s preferences.
If OF isn’t running, banging the combo starts up OmniFocus and launches the Quick Entry panel. If OF is running, then the script ceases and allows the OF combo to work as advertised.
BTW I figured out how to post code to these forums after trial and error. Type your whole post, pasting the code as plain text. When you are done, select the lines of code and click the </> icon in the toolbar of the post composer.
Thanks for the info @TheWart. I’m able to fire the script successfully. That was never the problem. When OF is open, the script halts and the QE shortcut to OF fires successfully…opening a QE panel that is active (blinking cursor in the QE subject field).
My problem is that when OF isn’t open and the script runs, when the QE panel opens, the QE panel isn’t active (the cursor isn’t in the QE subject field). I have to manually tab or click in the field to make it active. Now this is a minor extra task I readily acknowledge…but Shawn Blanc tells me the normal behavior on HIS system is the QE panel being active at the end of the script without additional keystrokes.
I’m anal about these things…when something isn’t working the way it’s ‘supposed’ to, I want to know why! :)
Thanks @TheWart for educating me about posting code.
-- This script allows the opening of OmniFocus and a Quick Entry panel using the Quick Entry keyboard shortcut in OF in the event OF is not open.
-- If OF is open, a Quick Entry pane is activated.
-- Launch using a launcher app with the same keyboard shortcut as OF Quick Entry.
-- This was written by Shawn Blanc
on appIsRunning(Omnifocus)
tell application "System Events"
return (count of (application processes whose name is Omnifocus)) is not 0
end tell
end appIsRunning
if appIsRunning("OmniFocus") then
null
else
tell application "OmniFocus"
activate
tell quick entry
make new inbox task
open
end tell
tell application "System Events"
keystroke tab
end tell
end tell
end if
I’ll try to think of something to troubleshoot. My system launches the script and activates the QE panel properly.
Any chance your clippings shortcut for OF is the same as the combination for the script? Any other system-wide services have the same shortcut?
Is OmniFocus set to launch in a separate OS X space? [I still do not understand all the ins and outs of Spaces, but know that the little I DID know changed with every OS version update!]
You might try one more “activate” after the System Events line, à la:
tell application id "OFOC"
activate
tell quick entry
open
set oTask to make new inbox task
tell application "System Events" to keystroke tab
activate
end tell
end tell
My guess is that the issue here is very similar to this one:
It looks like you have to arrow down first and then hit tab. Like so:
tell application "OmniFocus"
activate
tell quick entry
set theTask to make new inbox task
open
end tell
end tell
tell application "System Events"
key code 125
key code 48
end tell