Prompt for User Input Window Not Appearing Even Though It Is Triggered

Has anybody ever experienced the prompt for user input action not displaying the window anywhere on the screen?

Just today on at least three different occasions that I've noticed, a macro has run that shows a user prompt...but the window has not been visible anywhere on the screen. This has resulted in the macro getting stuck in limbo since I can't interact with the prompt, and I have to cancel the macro. But when I run the macro manually, or just trigger the actual prompt for user input action, it still does not appear anywhere. The only thing that resolves the issue is quitting and relaunching the KM engine.

It has happened from time to time in the past, but today it's been happening a lot more, so I wanted to see if anybody else has had this issue and if so, what the solution might be. Thanks all!

Hey Chris,

I seem to remember something like that happening long ago. It's probably appearing off-screen.

This is occurring on what version of macOS with what version of Keyboard Maestro?

With what computer hardware and how many screens?

@peternlewis?

In the meantime you can use this AppleScript to reposition the prompt, so you can see it.

tell application "System Events"
   tell application process "Keyboard Maestro Engine"
      tell window 1
         set its position to {10, 40}
      end tell
   end tell
end tell

-Chris

Yes, I've had this in the past and I've also always been annoyed by the fact that the position that the user prompt dialog appeared was never entirely predictable.

As a consequence of another thread on this forum I now use this approach that prevents these issues. I always execute a sub macro prior to executing the Prompt for User Input action - a bit like this:

KM 0 2021-08-16_22-52-08

The sub macro which I have named [LIB]_Center Keyboard Maestro Prompts and Alerts positions the following Prompt for User Input dialog consistently. It looks like this:

KM 1 2021-08-16_22-57-28

The action to call it is this:

KM 2 2021-08-16_22-59-58

The code for the sub macro is here:
[LIB]_Center Keyboard Maestro Prompts and Alerts.kmmacros (3.2 KB)

while the action to call it is this:

Execute Macro “[LIB]_Center Keyboard Maestro Prompts and Alerts” Asynchronously.kmactions (463 Bytes)

A couple of threads from this forum are worth reading:

and this one where this approach was first mentioned:

Hope that helps.

1 Like

I have a different solution to this problem. If you have an iPad you should be able to attach it to your Mac using Sidecar and then drag the iPad around your Mac's screen using the Display tab in System Preferences and you will be able to locate and drag the window back to your main screen with your mouse.

Hey Chris, that makes sense since I had just changed my screen resolution to test something.

Big Sur 11.5.2, Keyboard Maestro 9.2.

2019 27" iMac (all stock, 3GHz 6-core i5, 4GB Radeon, but aftermarket RAM [40GB total]), one external monitor in extended mode.

Thanks for the AppleScript, I'm going to save it for future use either with this issue or other workflows!

The window should always be moved on to the screen when displayed, so I don't know why it would ever be off the screen after opening.

Version 10 will have some additions that will help with engine window placement.

Thanks for the tip but personally I loathe Sidecar and never use it :sweat_smile:

That’s exciting news, thanks for chiming in Peter.

Sidecar is very useful with Keyboard Maestro. You can put KM on one screen and test your full screen app on another screen at the same time. My iPad rests at the bottom of my large monitor (when I need it for this purpose) and it gives me a cheap dual monitor setup.

Yea I imagine it would be very useful for some people. But I already have an extra monitor so I don't need the extra screen space.

@ccstone question for you about the AppleScript you provided yesterday.... I wrote it as a sub-macro that runs asynchronously consists of a 0.5 second pause and then the script to allow time for the prompt to appear...however it seems to be moving some of my palettes around too...anyway to prevent this?

@peternlewis I'm still having this issue today even though I haven't made any changes to my displays. It also has caused some of my open palettes to disappear on me, presumably off screen as well. Any ideas as to what might be causing this?

EDIT: Also, ever since I installed the latest Big Sur update, window management has been VERY glitchy...basically repositioning a window works about 50% of the time, and the other 50% the window moves to random locations...is this perhaps related?

Try this:

tell application "System Events"
   tell application process "Keyboard Maestro Engine"
      tell (first window whose subrole is "AXSystemFloatingWindow" and title is "Keyboard Maestro User Input")
         set its position to {20, 40}
      end tell
   end tell
end tell
1 Like

As usual, you’re the man. Thanks so much.

I’ve been trying to find resources to learn AppleScript but most of the things I find online are quite outdated. Do you know where I can look to in order to improve my essentially non-existent skills?

1 Like

Hey Chris,

AppleScript is not like other languages – unfortunately Apple did a lousy job of moving it forward after its initial development, so applications can have wildly different syntactic requirements. That means you have to learn each app separately. There is significant overlap of course, but it's a challenge – especially without owning a copy of Script Debugger

There is now a Lite [free] version of Script Debugger available – the full version demo reverts to Lite mode if not purchased in 30 days or so.

JXA and AppleScriptObjC have hit the scene, so there are many more tools available than there used to be – but that makes for even more studying...

Introduction to AppleScript Language Guide

Learning & Using AppleScript & JavaScript for Automation (JXA)

Learning and Developing AppleScripts

Join the Script Debugger Forum. It's the single best place for AppleScript help these days.

There's also:

and

The Applescript Users List

Applescript Users List Archive (search with Google site search)

I haven't touched this for some time, so it's more than a little bit out of date:

BBEdit is a good app to learn with and has the additional benefit of being one of the best programming editors for the Mac.

(The commercial version reverts to “Lite” after a demo period but is still waay powerful and scriptable.)

There are some decent books, but they tend to be better references than learning tools.

I could go on, but I'll stop here.

-Chris

1 Like

Probably it is related, but it is not something I've observed or seem reported.

Obviously, restarting is a good idea when the system is behaving oddly.

Considering what software (or hardware) you have installed that may be messing with your system is also a good idea.

Thanks Peter, due to other (unrelated) issues I resintalled macOS yesterday, but the window management is still unreliable. I'm wondering if it has to do with my other window management software I have installed.

I've been using Magnet for years, even before I discovered Keyboard Maestro I believe. But when windows management started acting up a couple of weeks ago, I downloaded Rectangle, believing it was a problem with Magnet. Rectangle does appear to work reliably, but Keyboard Maestro's window management is still glitchy. Any ideas of what I can look into to try and remedy this? If I need to make a new topic for this, let me know.

If you have other apps that are messing around with window positions, then a first start would be to disable them and see if the problem continues.

Other that that I don't know what to suggest.

One thing I would suggest is using semaphores whenever you can. Here's why. I sometimes have multiple macros that handle hardware or limited resources, such as the mouse or keyboard (or in your case, the screen.) By putting semaphore locks/unlocks before/after accessing these limited resources, you prevent simultaneous accessing to the same limited resource.

Not only does this solve the problem when multiple macros try to access the same device at the same time, but more importantly it solves the problem of the same macro being run multiple times by different triggers. I find it's all too easy in KM to have the same macro running concurrently due to multiple triggers. Peter, maybe there could be a checkbox at the top of any macro to prevent simultaneous triggers, since most KM users won't ever need to run the same macro concurrently.

2 Likes

Hey Chris, just wanted to chime in and say thanks again for your AppleScript tips. This particular script (along with UI Browser app) have helped me to script other things on my computer (like Mic Drop's microphone monitor which is not a window), and has REALLY helped with some of my workflows. Thanks again!

1 Like