PDA

View Full Version : Activate broken in 92632


curt.clifton
10-11-2007, 07:05 AM
The Applescipt activate command is broken in build 92632.

The code:

tell application "OmniFocus" to activate


yields:

OmniFocus got an error: Some parameter wasn't understood.

RobTrew
10-11-2007, 01:58 PM
Yes, this has, inter alia, broken the iGTD importer.

curt.clifton
10-11-2007, 04:14 PM
And my OmniOutliner exporters. Thankfully my Mail script still works, so my inbox isn't filling up with frantic emails from users. (Which, ironically, I wouldn't be able to create actions for. :-)

Tim Wood
10-11-2007, 07:20 PM
'activate' is working fine for me (and it is something I specifically tested while making the changes to QE). It was hitting this problem for Ken until he restarted Script Editor & OmniFocus, so maybe there is a need to restart to get the sdef reloaded.

curt.clifton
10-12-2007, 03:41 PM
Rob,

Activate started working for me somewhat mysteriously. (I've been troubleshooting this with Tim off-forum.) One thing that was odd in one of my scripts was that I had an activate inside a 'tell document'. Pulling that out to the 'tell application' level work fixed that script, though it doesn't explain the oddness from my original post.

Craig
10-12-2007, 05:39 PM
A script with an "activate" command for me was working when run from Script Editor, but it was causing my Automator routine to fail when run from within it. I'll try extracting it from the "tell" block as Curt described...

Tim Wood
10-14-2007, 06:16 PM
This should be working inside window and document blocks now. Additionally, activating a document will bring its front window in front of all other normal windows and activating a specific window will bring that window front.

I'm still not sure why Cocoa wasn't percolating this event up to the app. Anyway, this will work in window/document contexts now (though it might fail in other contexts that don't explicitly handle activate).

scb
10-18-2007, 03:13 PM
I am able to activate OmniFocus from Script Editor, but I have a script assigned to a hot key via Keyboard Maestro, and in that script "activate" no longer works, nor do any other OF commands.

I am using OF 93011.

Craig
10-18-2007, 03:41 PM
I am able to activate OmniFocus from Script Editor, but I have a script assigned to a hot key via Keyboard Maestro, and in that script "activate" no longer works, nor do any other OF commands.

I am using OF 93011.

Yes, my Automator problem described above persists in that same build.

curt.clifton
10-18-2007, 05:54 PM
I had to "re-compile" my scripts by editing them. You may try opening the old script in ScriptEditor, copying the full text, and pasting it into a new script window. There's something funky there with old scripts, but I can't reproduce it.

Tim Wood
10-18-2007, 10:16 PM
I'm not a fan of shipping compiled scripts, but then if I'd quit breaking the suite, this wouldn't be a problem... :)

Just as a data point, is there a disadvantage to shipping scripts in source form? I guess the biggest problem that comes to mind is that the compiler would launch all the target applications to get their dictionaries, but as long as you don't compile until you need the script this isn't an issue.

curt.clifton
10-19-2007, 03:02 PM
Tim,

I may be misunderstanding, but to be clear, I wasn't advocating for shipping compiled scripts and I don't do so myself. But it appears to me that Script Editor does, in fact, compile scripts when they are saved as "script" format, storing both the text and the compiled form. I'm taking "compiled" very liberally here; it may simply be tokenizing and mapping to class codes from the application dictionaries. I haven't read the AppleScript developer notes. The problem with activate appeared to be related to a broken mapping of some sort, but it went away for me before we could get any reliable log data.

All the scripts I share live in my ~/Library/Scripts folder, or its descendants. And they're all stored as "scripts" from Script Editor so that I can run them and edit them. The shared versions are just zipped up with their instructions. The first disadvantage of shipping scripts saved in "text" mode is that I have a bunch of extra work to do to share the scripts. Frankly, maintaining my RSS feed and web page are at, or just slightly beyond, what I can rationalize in terms of support for the scripts. The second disadvantage is that users have to use Script Editor to run the scripts.

keshalyi
11-20-2007, 05:35 AM
Downloaded the newest build, this morning, I still have this issue. Is there any consistent workarounds? It's driving me crazy! I love OmniFocus, but I need my automation... (twitch, twitch)

Tim Wood
11-20-2007, 07:31 PM
Both of these work for me:


tell app "OmniFocus" to activate

tell app "OmniFocus"
activate
end


Do both fail for you, or only the first one?

Craig
11-20-2007, 08:45 PM
Both of those work for me when run from Script Editor.

However, both of them fail for me when run from a "Run AppleScript" step in an Automator workflow. ("OmniFocus got an error: Some parameter wasn't understood.")

scb
11-21-2007, 10:29 AM
Both of these work for me:


tell app "OmniFocus" to activate

tell app "OmniFocus"
activate
end


Do both fail for you, or only the first one?
Both of the above scripts work for me from Script Editor, the script menu, and from Quicksilver. However, they do not work for me from Keyboard Maestro.

Thanks for looking into this.

Tim Wood
11-23-2007, 10:07 PM
However, both of them fail for me when run from a "Run AppleScript" step in an Automator workflow. ("OmniFocus got an error: Some parameter wasn't understood.")

This works fine for me under Automator on both 10.4 and 10.5. Could you try running OmniFocus from Terminal with something like this (assuming you are using bash or zsh):

AEDebugReceives=1 /path/to/OmniFocus.app/Contents/MacOS/OmniFocus

and then invoke your (minimal) script. This will spew a ton of output, so just do the 'activate' bit :)

Craig
11-24-2007, 08:12 AM
This works fine for me under Automator on both 10.4 and 10.5. Could you try running OmniFocus from Terminal with something like this (assuming you are using bash or zsh):

AEDebugReceives=1 /path/to/OmniFocus.app/Contents/MacOS/OmniFocus

and then invoke your (minimal) script. This will spew a ton of output, so just do the 'activate' bit :)

Both now seem to be working for me in 95008. Let me know if that output would be useful to you regardless.

scb
11-25-2007, 09:31 AM
You didn't ask for Keyboard Maestro output, but activate does not work from Keyboard Maestro as of OmniFocus 95014. Here is the debug output:
AE2000 (584): Received an event:
------oo start of event oo------
{ 1 } 'aevt': misc/actv (i386){
return id: 13238293 (0xca0015)
transaction id: 0 (0x0)
interaction level: 112 (0x70)
reply required: 1 (0x1)
remote: 0 (0x0)
for recording: 0 (0x0)
reply port: 40743 (0x9f27)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x19019 } (Keyboard Maestro)
}
fEventSourcePSN: { 0x0,0x19019 } (Keyboard Maestro)
optional attributes:
{ 1 } 'reco': - 2 items {
key 'subj' -
{ -1 } 'null': null descriptor
key 'csig' -
{ 1 } 'magn': 4 bytes {
65536l (0x10000)
}
}

event data:
{ 1 } 'aevt': - 0 items {
}
}

------oo end of event oo------


In comparison, here's the output when the script is invoked from the Script Menu:
AE2000 (584): Received an event:
------oo start of event oo------
{ 1 } 'aevt': misc/actv (i386){
return id: 38469634 (0x24b0002)
transaction id: 0 (0x0)
interaction level: 96 (0x60)
reply required: 1 (0x1)
remote: 0 (0x0)
for recording: 0 (0x0)
reply port: 40967 (0xa007)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x4f04f } (AppleScript Runner)
}
fEventSourcePSN: { 0x0,0x4f04f } (AppleScript Runner)
optional attributes:
{ 1 } 'reco': - 2 items {
key 'subj' -
{ -1 } 'null': null descriptor
key 'csig' -
{ 1 } 'magn': 4 bytes {
65536l (0x10000)
}
}

event data:
{ 1 } 'aevt': - 1 items {
key '----' -
{ -1 } 'null': null descriptor
}
}

------oo end of event oo------

Tim Wood
11-25-2007, 10:24 AM
Hrm; Keyboard Maestro does seem to have a few differences. I'm not sure how they could arrange that unless they are building their own AppleEvents w/o using Apple's compiler.

They have the right codes though (misc/actv), but the Cocoa scripting support seems to want the 'null' they dropped out of the 'event data'. It might work if I stopped specifying a 'direct-parameter' in my sdef, but then 'activate quick entry' wouldn't work.

Could you try this to see if this is even the right track:

- Quit OmniFocus and Keyboard Maestro
- Use Finder's context menu to "Show Package Contents" on OmniFocus
- Navigate to Contents/Resources and open OmniFocus.sdef in your favorite text editor

Look for:


<command name="activate" code="miscactv" description="Activates the application or window.">
<direct-parameter type="specifier" description="the object(s) to activate."/>
</command>


and replace it with:


<command name="activate" code="miscactv" description="Activates the application or window."/>


Note the '/>' at the end of this line instead of just '>'.

Then relaunch and try your script.

Even if this does fix the problem in Keyboard Maestro, it will break scripting Quick Entry...

scb
11-26-2007, 06:06 PM
Even if this does fix the problem in Keyboard Maestro, it will break scripting Quick Entry...

This does fix the problem, thanks. I will forward this thread to the KM developers- perhaps they can fix it on their end.

Craig
11-28-2007, 03:12 PM
Both now seem to be working for me in 95008. Let me know if that output would be useful to you regardless.

Okay, I spoke too soon, and I do have that output for you.

Note that the simple activate script wasn't triggering the workflow crash, but this is the script that was:

tell application "iCal" to quit
tell application "OmniFocus"
activate
tell default document
tell front document window
set perspective name to "starting soon"
end tell
end tell
end tell
tell application "end of the day" to activate

Here's what results from your procedure when the workflow containing this script is run (and crashes):

user$ AEDebugReceives=1 /Applications/OmniFocus.app/Contents/MacOS/OmniFocus
OCCCrashCatcher: Not enabling crash catching since we're connected to a tty (and thus presumably in gdb)
2007-11-28 17:07:09.382 OmniFocus[1768] linkPath /Users/user/Library/Mail/Bundles/OmniMailMessageServiceEnabler.mailbundle
2007-11-28 17:07:09.383 OmniFocus[1768] bundledPath /Applications/OmniFocus.app/Contents/Resources/OmniMailMessageServiceEnabler.mailbundle
2007-11-28 17:07:09.383 OmniFocus[1768] doesExist = 0, shouldExist = 0
AE2000 (1768): Received an event:
------oo start of event oo------
{ 1 } 'aevt': ascr/gdte (ppc ){
return id: 113967135 (0x6cb001f)
transaction id: 0 (0x0)
interaction level: 64 (0x40)
reply required: 1 (0x1)
remote: 0 (0x0)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x13a0001 } (end of the day)
}
optional attributes:
< empty record >
event data:
{ 1 } 'aevt': - 1 items {
key '----' -
{ 1 } 'long': 4 bytes {
0 (0x0)
}
}
}

------oo end of event oo------
2007-11-28 17:07:25.779 OmniFocus[1768] .sdef warning for part of complex type 'color | text | file | point | real | integer | boolean | point | missing value' used in suite 'OmniStyle Scripting': 'missing value' is not a valid type name.
AE2000 (1768): Received an event:
------oo start of event oo------
{ 1 } 'aevt': misc/actv (ppc ){
return id: 113967139 (0x6cb0023)
transaction id: 0 (0x0)
interaction level: 96 (0x60)
reply required: 1 (0x1)
remote: 0 (0x0)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x13a0001 } (end of the day)
}
optional attributes:
{ 1 } 'reco': - 2 items {
key 'subj' -
{ -1 } 'null': null descriptor
key 'csig' -
{ 1 } 'magn': 4 bytes {
65536l (0x10000)
}
}

event data:
{ 1 } 'aevt': - 0 items {
}
}

------oo end of event oo------

Hope that helps your bug-hunting!

scb
12-21-2007, 06:52 AM
On my system, activate appears to be broken again in build 96394. It's only broken for OmniFocus and only for my account.

Executing the following in "Script Editor" tell application "OmniFocus" to activate
or
tell application "OmniFocus"
activate
end tell
generates the error "OmniFocus got an error: Some parameter is missing for activate."

If it helps, heres the AEDebug output:
~ b% AEDebugReceives=1 /Applications/OmniFocus.app/Contents/MacOS/OmniFocus
OCCCrashCatcher: Not enabling crash catching since we're connected to a tty (and thus presumably in gdb)
AE2000 (6463): Received an event:
------oo start of event oo------
{ 1 } 'aevt': misc/actv (i386){
return id: 407830626 (0x184f0062)
transaction id: 0 (0x0)
interaction level: 64 (0x40)
reply required: 1 (0x1)
remote: 0 (0x0)
for recording: 0 (0x0)
reply port: 36875 (0x900b)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x125125 } (Script Editor)
}
fEventSourcePSN: { 0x0,0x125125 } (Script Editor)
optional attributes:
{ 1 } 'reco': - 2 items {
key 'subj' -
{ -1 } 'null': null descriptor
key 'csig' -
{ 1 } 'magn': 4 bytes {
65536l (0x10000)
}
}

event data:
{ 1 } 'aevt': - 0 items {
}
}

------oo end of event oo------
AE2000 (6463): Received an event:
------oo start of event oo------
{ 1 } 'aevt': aevt/rapp (i386){
return id: 15139455 (0xe7027f)
transaction id: 0 (0x0)
interaction level: 112 (0x70)
reply required: 0 (0x0)
remote: 0 (0x0)
for recording: 0 (0x0)
reply port: 34567 (0x8707)
target:
{ 1 } 'psn ': 8 bytes {
{ 0x0, 0x15015 } (LiteSwitch X)
}
fEventSourcePSN: { 0x0,0x15015 } (LiteSwitch X)
optional attributes:
< empty record >
event data:
{ 1 } 'aevt': - 0 items {
}
}

------oo end of event oo------