Subject: Re: [Witch Talk] system app switcher sometimes shows up

From: Rob Griffiths <[email-masked]>
Date: Tue, 7 Mar 2017 12:25:39 -0800

On Mar 6, 2017, at 7:37 AM, Shoshanna <[email-masked] <mailto:[email-masked]>> wrote:

> a number key to select something in the Witch window, but the keystroke also triggers the KM macro. So I'd love to find a programmatic way to deactivate the relevant KM macros in the presence of a Witch window. (I know you use KM, or I wouldn't be yammering here about what's doubtless an edge case... :) )

We're talking about it; the problem right now is that Witch is basically invisible - you'll notice your frontmost app doesn't even change when you activate the switcher. But we're talking!

-rob.

---

From: Shoshanna <[email-masked]>
Date: Mon, 6 Mar 2017 07:37:25 -0800 (PST)

On Sunday, March 5, 2017 at 6:40:09 PM UTC-5, Many Tricks wrote:
>
> Yea, I think it's just that no app can reliably trap that key when the CPU 
> gets in the way of the request. However, we're trying something, so we'll 
> see if it changes anything here. 
>

Crossing my fingers!

> Or you could switch to Option-Tab, which should always work

Oh, I have Witch switchers bound to option-tab, control-tab, *and* command-tab. 
The reason I asked about ways for the system to determine whether a Witch 
switcher window is present is that I can't define command, control, or 
option in combination with a number key as a Keyboard Maestro macro 
trigger, because once I've summoned a Witch switcher with 
[command|control|option]-tab I want to be able to use a number key to 
select something in the Witch window, but the keystroke also triggers the 
KM macro. So I'd love to find a programmatic way to deactivate the relevant 
KM macros in the presence of a Witch window. (I know you use KM, or I 
wouldn't be yammering here about what's doubtless an edge case... :) )

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 5 Mar 2017 15:40:07 -0800

On Mar 5, 2017, at 1:38 PM, Shoshanna <[email-masked]> wrote:

> Aw, phooey; the same glitch just happened with the KM workaround. Another beautiful theory shot down by fact.

Yea, I think it's just that no app can reliably trap that key when the CPU gets in the way of the request. However, we're trying something, so we'll see if it changes anything here.

> I guess I'll have to be satisfied with your awesome tool working only 99.5% of the time (and the remaining 0.5% being utterly predictable; it's not as though I don't know that if I just wait half a second to trigger the app switcher it'll work fine).

Or you could switch to Option-Tab, which should always work, even under load, because of how we can trap it. I know, not as convenient as the Command key.

regards;
-rob.

---

From: Shoshanna <[email-masked]>
Date: Sun, 5 Mar 2017 13:38:39 -0800 (PST)

On Sunday, March 5, 2017 at 9:01:12 AM UTC-5, Shoshanna wrote:
>
> 2) could I set up a KM macro triggered by command-tab that would emulate 
> an obscure keystroke that would in turn trigger Witch? Yes, indeed, in 
> quick initial testing that appears to work; I didn't get Witch to stumble 
> even when triggered during computationally expensive tasks. If this holds 
> true, I may have found my workaround! 
>

Aw, phooey; the same glitch just happened with the KM workaround. Another 
beautiful theory shot down by fact.

I guess I'll have to be satisfied with your awesome tool working only 99.5% 
of the time (and the remaining 0.5% being utterly predictable; it's not as 
though I don't know that if I just wait half a second to trigger the app 
switcher it'll work fine).

---

From: Shoshanna <[email-masked]>
Date: Sun, 5 Mar 2017 06:01:12 -0800 (PST)

On Sunday, March 5, 2017 at 8:24:56 AM UTC-5, Many Tricks wrote:
>
> We're aware of the issue, but we're not sure if we can do anything about 
> it—basically, when the CPU is busy, Witch isn't catching the Command-Tab. 
> Because Command-Tab is a reserved keystroke, we have to capture it 
> differently than we do, for example, Option-Tab.

Makes sense, and that's pretty much what I figured.

I find, in initial testing, that Keyboard Maestro can capture command-tab 
(and eats the keystroke rather than passing it on); if I set up a KM macro 
to be triggered by it, then the macro runs and neither Witch's switcher nor 
the native switcher is triggered, even in the same circumstances where I 
got Witch to stumble. Which leads me to two thoughts: 1) could whatever 
mechanism KM is using work for you? and 2) could I set up a KM macro 
triggered by command-tab that would emulate an obscure keystroke that would 
in turn trigger Witch? Yes, indeed, in quick initial testing that appears 
to work; I didn't get Witch to stumble even when triggered during 
computationally expensive tasks. If this holds true, I may have found my 
workaround!

Is it possible to trigger Witch's app->windows switcher (or another one) 
with Applescript or other lower-level calls, rather than a(n emulated) 
keystroke? That might be a bit faster, when routing through Keyboard 
Maestro. (And -- changing the subject a bit, sorry, this is a minor 
edge-case question -- is it possible to determine by such methods whether a 
Witch switcher window is present, other than by having System Events count 
the windows belonging to the witchdaemon process?)

Thanks!

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 5 Mar 2017 05:24:54 -0800

On Mar 4, 2017, at 6:14 AM, Shoshanna Green <[email-masked]> wrote:

> switcher. I can't be very technical about this, unfortunately, but I can say that this definitively happens only when the system is, hm, distracted, in the middle of doing something else -- for instance, when Word is trying to save a file, or some similarly computationally expensive task. This happens on both my Late 2009 iMac (3.06 gig Core 2 Duo, 4 gig RAM) and my Mid 2010 MacBook Pro (2.4 gig Core 2 Duo, 4 gig RAM).

We're aware of the issue, but we're not sure if we can do anything about it—basically, when the CPU is busy, Witch isn't catching the Command-Tab. Because Command-Tab is a reserved keystroke, we have to capture it differently than we do, for example, Option-Tab. But we're trying to see if we can't find a way to get the keys even when the CPUs are busy.

regards;
-rob.

---

From: "Shoshanna Green" <[email-masked]>
Date: Sat, 04 Mar 2017 09:14:39 -0500

Hi,

I'm still seeing the native app switcher appear sometimes when I hit 
command-tab, which I've bound to Witch's Cycle Apps->Windows switcher. I 
can't be very technical about this, unfortunately, but I can say that 
this definitively happens only when the system is, hm, distracted, in 
the middle of doing something else -- for instance, when Word is trying 
to save a file, or some similarly computationally expensive task. This 
happens on both my Late 2009 iMac (3.06 gig Core 2 Duo, 4 gig RAM) and 
my Mid 2010 MacBook Pro (2.4 gig Core 2 Duo, 4 gig RAM).

What happens is, I hit command-tab, and the Witch window doesn't appear 
for a moment, presumably because the system is preoccupied with some 
other task. (I've got a 0.1 second delay in Witch, but this is longer 
than that; I can tell the difference.) Then, before Witch catches up and 
shows its switcher window, the system app switcher appears, and -- I'm 
still holding down the command key here, though I've tapped and released 
the tab key -- the selection in the native app switcher runs madly along 
the row. I pretty much have to just let go of everything, and I have 
little or no control over which app ends up being activated. When I try 
again, Witch works fine, because whatever other task the system was 
distracted by is finished.

I presume that what's going on is that Witch is too far down the 
processing queue when it asks the system for the info it needs with 
which to build its switcher window, and times out, leaving the field to 
the native switcher? I haven't seen both Witch and the native switcher 
appear simultaneously in several versions, though I did occasionally see 
that very early on.

I've just succeeded in deliberately triggering this failure, with the 
following sequence: while in this mail program (MailMate) I typed a 
keystroke that triggers a Keyboard Maestro macro to open a specific Word 
file. Then I immediately hit command-tab, before the Word file had 
appeared. Nothing happened for a moment -- more than 0.1 second -- and 
then the Word file appeared and so did the system app switcher. The 
selection ran along the switcher window until it reached the far right 
end. I let go of the tab key, and the app that activated was not the one 
that was now selected at the far right of the native switcher window, 
but MailMate again.

And I just closed the Word file in question and tried the same sequence 
again, and -- I'm guessing because the file is now cached and opens more 
quickly -- everything worked fine. The file opened, Witch's switcher 
opened, and the selection in it held steady on MailMate, the second item 
from the left, with Word as the first since Word was the active app when 
I hit command-tab. So when I let go of the tab key, here I was again. I 
find it interesting that I was returned to MailMate the first time as 
well, even though MailMate wasn't actually the selected app in the 
native switcher window that was showing.

Anyway, that's a very longwinded way of saying that Witch doesn't seem 
to be able to catch up if it starts off flatfooted. I hope it's helpful!

Shoshanna Green
[email-masked]