"Cannot Activate Application" error with Evernote and KM 7

Since upgrading to KM 7, a normally bulletproof macro has started occasionally throwing an error that it can’t activate Evernote. Here’s what it says in the console:

8/12/15 8:47:40.300 AM Keyboard Maestro Engine[366]: Keyboard Maestro Engine: Switch failed for Evernote <KBMRunningApplication “Evernote” <0x608000667f80> pid=5560 bid=com.evernote.Evernote abht>

8/12/15 8:47:40.305 AM Keyboard Maestro Engine[366]: Keyboard Maestro Engine: Activate Application cannot activate application Evernote In macro ‘Link Log: Katexic’ (while executing Activate Evernote).

I’ve checked the macro, which is failing at the simple:

Activate Evernote. Notify on failure.

With the “All Windows” option checked. and “If already at the front” set to “Leave it at the front”

Any way to troubleshoot or ideas what might cause this intermittent error?

FYI, I am running: OS X 10.10.4, Evernote 6.0.16, KM 7.0

I just upgraded to Yosemite and KM7, and I’m an avid Evernote user.
So I’m definitely interested in this topic. :smile:

Have you tried, as a test, to create a simple macro that:

  1. Activates Finder
  2. Activates Evernote

Yep, that works. And my macro that uses this step works most of the time! I’d guess it fails about 20% of the time…I just can’t figure out the condition(s) triggering the failure.

You might try adding a small Pause (like ~0.3) before and/or after the Activate Evernote action. I’ve noticed this can sometimes make a big difference.

There are some issues with activating and tracking running applications in 7.0 which should be resolved in 7.0.1 (in beta testing now).

Hey Guys,

Hopefully Peter has ironed this out in KM 7.0.1, but there is some general flakiness in Yosemite when it comes to activating applications. I’ve been hearing this since 10.10 came out, and now I’ve upgraded I’ve seen it. Unfortunately I haven’t established any pattern as yet.

One of the accepted workarounds is:

tell application "System Events"
  if quit delay ≠ 0 then set quit delay to 0
  tell application process "BBEdit"
    set frontmost to true
  end tell
end tell

Be sure to note the difference between application “System Events” and application process “BBEdit”. Many people forget to add “process” and wonder why it fails to work.


1 Like

The flakyness I have seen happens in the cocoa NSRunningApplication objects, and this is pretty much the definitive modern way to access running applications, so it would not surprise me at all to see a lot of issues around this in various applications.

I have reported numerous bugs for this, and eventually had to resort to my own object with minimal interaction with NSRunningApplication objects. I missed a case which I think explains some or all of the issues in Keyboard Maestro 7.0 relating to activating applications.

The fact that my log has a stream of entries “Ignoring NSRunningApplication with pid -1” is indicative of the NSRunningApplication mess. These are for NSRunningApplication that come directly from [[NSWorkspace sharedWorkspace] runningApplications] or [[NSWorkspace sharedWorkspace] frontmostApplication], so they cannot have quit and no longer have a pid, or they should not be in the runningApplications list or be the frontmostApplication. Sigh.

1 Like

Thanks. I’ll try this bit of script for now and see what happens when KM 7.0.1 is out.