Things Quick Entry window?

I want to build a KM macro to intercept the ESC key when the Things Quick Entry window is open.

(This is because when using Things, you can close the When, Tags And Project pop-ups with the ESC key, but doing so in Quick Entry will close and discard the entire contents of the QE window. I often do this by mistake, and there is much cursing.)

KM can't see the QE window, but I used the Window Discovery Tool macro to get this info on the Quick Entry window:

minimum value = missing value
orientation = missing value
position = 817, 215
class = window
role description = system dialog
accessibility description = missing value
focused = false
title = Quick Entry
size = 926, 648
value = missing value
help = missing value
enabled = missing value
maximum value = missing value
role = AXWindow
entire contents
subrole = AXSystemDialog
selected = missing value
name = Quick Entry
description = system dialog
-----
minimum value = missing value
orientation = missing value
position = 618, 23
class = window
role description = standard window
accessibility description = missing value
focused = false
title = Today
size = 1504, 1408
value = missing value
help = missing value
enabled = missing value
maximum value = missing value
role = AXWindow
entire contents = [entry was blank]
subrole = AXStandardWindow
selected = missing value
name = Today
description = standard window
-----

I tried using some of the Applescripts posted on the forum for determining if the QE window is open, but the syntax of the scripts no longer works.

Please point me in a direction, or show me how it's done. Many thanks.

Hey @anamorph,

Here you go.

You may or may not need to disable the IF action at the bottom. I've attempted to pass-through the Escape keystroke IF the Quick Entry window is NOT the frontmost window.

It works properly on my system using Safari as a test platform (since I don't have Things), but you'll have to test it out on your system with Things.

NOTE – You'll have to change the macro association from Safari to Things manually.

-Chris


Things ⇢ Intercept Escape Key.kmmacros (7.0 KB)

Chris, thanks very much for this.

It works, but it turns out the situation is a little bit more complex than I realized.

Because it's checking to see if the front window is named "Quick Entry," the macro doesn't work when the Quick Entry When/Tag/Deadline pop-ups are open. Unfortunately, they are not named.

I found some AppleScript code on StackOverflow, and edited your AppleScript. I have Things check all its windows and toggle the abortEntry variable to true if it finds Quick Entry.

I don't know enough about AppleScript to know if there's a more elegant way to do this, but it seems to work for now.

Thanks - this is going to make my life a little better every day!

Things ⇢ Intercept Escape Key+ .kmmacros (6.8 KB)

2018-07-17_09-16-53

Hey @anamorph,

There's nothing wrong with the way you've done it, but this will be a trifle more efficient most of the time.

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/07/16 23:19
# dMod: 2018/07/20 08:10
# Appl: Things, Keyboard Maestro Engine, System Events
# Task: Prevent Escape Key from Dismissing the Quick Entry Window
# Libs: None
# Osax: None
# Tags: @ccstone, @Applescript, @Script, @Keyboard_Maestro_Engine, @System_Events, @Things, @Prevent, @Escape, @Key, @Dismiss, @Quick, @Entry, Quick_Entry, @Window
----------------------------------------------------------------

set abortEscape to false

tell application "System Events"
   
   tell application process "BBEdit"
      
      if (get name of windows) contains "Quick Entry" then
         set abortEscape to true
         display notification "Click Cancel Button" with title "ESC key deactivated" sound name "Tink"
      end if
      
   end tell
end tell


if abortEscape = false then
   
   set kmInstance to system attribute "KMINSTANCE"
   
   tell application "Keyboard Maestro Engine"
      setvariable "local_AbortEscape" instance kmInstance to "FALSE"
   end tell
   
end if

----------------------------------------------------------------

-Chris

Nice, thanks. As I said, a more elegant way to do this.

P.S. - this kind of macro is also useful when calling the Things Quick Entry over an app that has KM macros for common keys like tab or return. You just use the same structure to intercept the macro key if the Quick Entry window is present.

1 Like

Hmm. For some reason, when I substitued your

if (get name of windows) contains "Quick Entry" then

it worked fine, but I found if I hit the ESC key in Safari when the Things Quick Entry window was closed, the macro responded as though the Quick Entry window was open. When I put back my own clunkier code, it did not exhibit that problem.

Any ideas? When I checked Things, it definitiely didn't have the Quick Entry window open.

Hey @anamorph,

Hmm...

I thought I'd fixed the issue in v1.00 (now deleted).

Hopefully this new version (1.10) will work properly.

-Chris


Things ⇢ Intercept Escape Key v1.10.kmmacros (7.9 KB)

Thanks.

Trapping the ESC and putting up the alert/User Input Window now works.

I've been trying to set it up to dismiss the KM User Input Window and the Things Quick Entry Window with a second press of the ESC key.

IOW, I call up the Things QE window, press ESC, the KM User Input Window comes up, I press ESC again, and both windows close.

I've tried numerous approaches, but can't get it to work. I've tried testing KM to see if the UIW exists, and I've tried creating a logical variable for the UIW that is set to TRUE after the UIW is called -- I haven't been able to get this to work.

Thanks in advance for your help.

Hey @anamorph,

If I understand correctly what you're doing the problem is that Keyboard Maestro cannot act upon its own UI elements (dialogs/window) once they're open.

-Chris

I worked around that by using a keyboard shortcut in the User Input Window.

I was able to make it work if I used Shift-Esc for a separate macro to close the UIW and the Things Quick Entry. Is there a way I can make this work on the second press of ESC?

IOW:

  • Open Things QE Window
  • Press ESC, which fires the KM Intercept Macro and opens the KM UIW
  • Press ESC again, which fires a KM macro that sends one keystroke to close the UIW, and then an ESC keystroke to close the Quick Entry Window

I'm thinking this requires a persistent variable that can be set to TRUE on the 1st ESC keystroke, and then set to FALSE after the 2nd ESC. I have not been able to get this to work. Suggestions?

Here's the Shift-ESC version:

2018-07-25_11-22-26

Hey @anamorph,

Why are you opening a window?

Why not just use a notification and remove that obstacle?

-Chris

Thanks, Chris. In the course of simplifying it, I got it to work.

1 Like