KM & TextExpander keyboard freeze

Weird problem that may be unique to me. I am under Yosemite 10.0.1 on a late-2013 iMac and using the latest KM and TextExpander (TE). I use Citrix Viewer (CV) to access my institution’s MedRec system, and since it’s not very customizable, I’ve been happily using KM to make useful macros for myself. I also use TE to expand a lot of text shortcuts.

I’ve been seeing a problem where I get a keyboard freeze in CV while in the midst of typing. I can “unfreeze” the keyboard in three ways that I’ve discovered so far:

(1) Disable and re-enable TE;
(2) Quit and relaunch KM Engine.
(3) Enter some text in Notepad, then return to CV (which seems unaffected by the freeze).

As far as I can tell, both KM and TE need to be running behind CV for the freeze to occur. That’s why I’m wondering whether there is some weird contention issue between them.

Very hard to figure what is happening here. Any ideas as to how to troubleshoot this further?

Oh yes, one more thing. I’ve kept KM Debug console open during these, and there isn’t any indication of a stalled macro. However, check-then-uncheck “Pause New Macros” seems to frequently (not always, perhaps) unfreeze the keyboard input in CV.

I have a similar setup (10.0.1, KM, TE, CV for EMR) but have not encountered that. I use both KM/TE constantly including calling macros from one app using the other app.

Michael, that’s great to hear (and an amazingly fast response!). At first I thought KM might be hanging up on some “Pause until X” actions, but now I doubt that for various reasons. Do you have “Pause until X” actions in any of your KM macros?


P.S. What’s your EMR? Mine is Epic with Epic/Beaker lab module. Hard to imagine it matters, but just wondering; the RTF editor in Epic/Beaker is a strange piece of work.

No pause untils, except when logging in.

I have to use Epic, NextGen, and Cerner.

Pause actions wont have anything to do with this - pausing can’t affect the keyboard events flowing through the event queue.

I have no idea what exactly is happening, but I suspect the problem is something “tapping” the keyboard event queue.

To have an idea of what is going on, there are two parts to understand.

The first is the event queue. Whenever you perform a UI action like clicking/moving the mouse, pressing or releasing a key), the event is not sent directly anywhere, it is added to an event queue. This is what allows, for example, you to type as fast as you want, and even if the application is slow, it will process all the keys in order in its own good time (it might not be necessary with modern hardware, but this system remains largely unchanged since the dawn of time).

The second this is that the system allows applications to “tap” this queue. Basically, when the system reads an event off the front of the queue, it has a list of applications that have said they want to see/interact with events. So in turn, it passes the event to the application, which may modify it, and then returns it to the system, which then passes it to the next event tapping application, and so on, until all the event taps have been handled, and then the event is handed to the front application to deal with.

Keyboard Maestro taps the event queue in order to steal the Command-Tab from the system (as it does not provide any override for this) and to handle capturing keys for the hot key entry in the editor.

Now imagine what happens if an application’s tap fails for some reason and does not return. Your events would start failing. There is a timeout on this system that disables a tap in this case. But a tap could also start failing by killing every event, and the system would be ok with that. Something like that might be going on.

Relaunching Keyboard Maestro Engine or TextExpander will cause them to remove themselves from the tap queue and then add themselves back, and its possible that action is what is unsticking whatever is stuck.

You could try disabling Keyboard Maestro’s Application Switcher and see if that stops relaunching Keyboard Maestro having an affect on it, but its hard to know for sure that you’ve managed to avoid any case where Keyboard Maestro will be adding its event tap.

So my guess, and its a pretty wild guess, is something in the tap system or something tapping the event queue is messed up. To tap the event queue you need accessibility permissions, so in theory the only apps you need to think about are the ones listed there, but in practice that system is so broken itself, including sometimes allowing access to apps that are not shown, that it’s hard to have much faith in it. And the problem could also be some corruption in the system related to the event processing (which is somewhat likely given that other apps should not be able to tell if another app is added or removed from the event tap queue.

Sorry, none of this really helps to find the problem I’m afraid.

Fascinating information, Peter. Thanks.

The information is on the event queue is interesting. Most EMRs these days are run on servers remotely accessed through VPNs. I can feel the speed difference between 0530 when no one is working and 0830 when the whole hospital logs in. I’ll have often typed a lot and done a few KM macros to manipulate my location and then sit and wait for things to happen.

I do not have KM Application Switcher enabled, so that might be a difference between me and madde001, that explains the difference in behavior.

Peter, yes thank you so much for the detailed explanation. I noticed that if I ctrl-alt-del my Citrix session without touching KM or TE at all, it also restores the keyboard responsiveness. So, given that CV is kind of a “strange” application to begin with, I postulate to myself that perhaps CV is not returning to the event queue; and KM and TE (which are robust in all other circumstances that I’ve used them) are victims of CV’s (?bad?) behavior. I’ll log an issue on the Citrix board and see what comes of it. BTW, I’m using Citrix Receiver/Viewer 11.9.0 tech preview.

Apropos Michael’s idea about KM Application Switcher, no actually I have that off too.

The other thing is, I don’t want to necessarily “blame” Citrix for this. As Michael points out, our EMR is run on remote servers, and of course CV is sessioning on this remote box. It’s entirely possible that our EMR team has set something up in a nonstandard way on the server. (They’re known for this.)

I have perhaps a similar problem. I have KM and TE running (Yosemite) and I use Citrix Viewer to access my hospital’s Meditech medical record system. Whenever I do a clipboard-intensive operation in Excel over Citrix (I manipulate census data from home in the morning on my Mac) my system freezes up with the spinning beach ball for as long as 10 minutes at a stretch. If I open the Activity Monitor, I see Citrix Viewer using>100% of CPU. System responsiveness is restored when the CPU usage finally drops down. If I scroll down the list in Activity Monitor, it tells me that KM Engine is frozen and if I force-kill it, system response is restored. TE is not frozen but sometimes if I kill it I can get somewhere as well. Even with KM and TE killed, I get briefer periods, when I do a clipboard operation, of 100% CPU usage and system non responsiveness. Far more brief, maybe 30-60 sec.

If I do the same spreadsheet operations at the hospital, in Excel over the network on a Windows machine, there are no freezes, of course.

Oh yeah, so my point is that I think it IS a Citrix problem, regardless of which EMR system is being accessed at the server end. And my IT people have not set things up in any idiosyncratic way.

I am using KM script to go to a citrix website and login. I am trying to activate an icon to start my EMR, but seem to be stuck. Any thoughts