BUG: The Mystery of the Drifting Debugger

For quite a while (at least 3-4 years) I have had this issue where the Debugger window (palette, whatever) will not consistently re-open where I put it previously (i.e. upper right corner of second display.) The issue is intermittent with no rhyme or reason as to why it occurs. In fact, sometimes it can go weeks with the problem not happening at all.

Although the problem occurs randomly, it functions cyclically...What I mean is, when the Debugger is activated, by macro or menubar, instead of reappearing at the position where it was last closed (upper right corner of screen,) the Debugger window initially appears somewhere near the upper left corner of the second display when it begins its cycle of roaming. Subsequent to this, every time the Debugger is closed and reopened, the window cascades down ~10-20px from wherever it was positioned previously. This happens until the window reaches the bottom of the screen, then it pops to the top of the screen and starts cascading again.

I hacked an AppleScript fix a while ago that forces the Debugger to the upper right corner whenever it starts, but, when it first appears, it still flashes somewhere on the screen before the script puts baby in the corner.

This issue has persisted despite completely removing reinstalling Keyboard Maestro, KM app updates, system updates, clearing caches, direct modifications to plist files (and probably 12 other things,) but nothing seems to tame this beast!

Have you tired the de-bugger?

(I am very aware this wasn't; helpful but I saw a spot for a joke and needed to make it)

1 Like

Hey Jakz,

I stumbled on this old post and now I'm wondering if you wouldn't mind sharing your script to "put baby in the corner"?

"Baby" still needs to learn its place.

Hey John,

You ought to be able to do this natively with the Keyboard Maestro Engine window now.

token:LastWindowID [Keyboard Maestro Wiki]

Along with a move the front window action.

But here's some AppleScript just in case:

# Get position of KM debugger window (must be open).
tell application "System Events"
   tell application process "Keyboard Maestro Engine"
      tell window "Keyboard Maestro Debugger"
         get position
      end tell
   end tell
end tell

Result: {617, 23}

# Set position of KM debugger window (must be open).
tell application "System Events"
   tell application process "Keyboard Maestro Engine"
      tell window "Keyboard Maestro Debugger"
         set position to {617, 23}
      end tell
   end tell
end tell

-Chris

I couldn't get Debugger to play along with this -- opening it doesn't seem to create a %LastWindowID%. I also couldn't see a way to get the width/height of an Engine window (although I didn't look very hard!).

Here's a macro that will open Debugger and move it to the top-right corner of the "main" display while maintaining its last-set size:

Launch Debugger to Top Right of Main.kmmacros (3.1 KB)

Image

Should be reliable -- unless, by some amazing coincidence, you've also got a "Custom HTML Prompt" also titled "Keyboard Maestro Debugger" which you manage to open in the extremely brief period between the Debugger launching and the AppleScript executing...

2 Likes

This is really helpful - thank you guys.

%LastWindowID% doesn't get an ID but the scripts work.

Manipulate Window failed to find engine window with id “” in macro “Trying” (while executing Move and Resize Engine Window with ID %LastWindowID%)

Nige you're blowing my mind with that example but it makes sense. I feel like I missed AppleScript day in school.

The only tricksie bit is that while KM returns a window frame as

left-edge, top-edge, width, height

...AppleScript's bounds are

{left-edge, top-edge, right-edge, bottom-edge}

So that nasty calculation (which would be much clearer if split up) is simply finding the width and height of the Debugger window and using those values to "work back" from the top-right corner coordinates of the "main" screen to set the new window bounds.

1 Like

John,

Attached is the macro I use to force the Debugger to bend to my will. This has worked flawlessly since I set it up several years ago. (You'll just need to set your desired position value of the variable: 'defaultDebuggerPosition' and chnage hokey, if you like.)

I used to have the macro function more elegantly with an initial check to determine the position of the Debugger after it appears, and then only set the position if it wasn’t already where I wanted it...

This current version, however, doesn’t check :poop:, it just brutishly sets the position every time the Debugger appears, making it function almost invisibly.

In addition to ensuring the Debugger appears in the upper right of my second display, the macro is setup as a toggle so the same hotkey (I use ⇧F1) is used to enable and disable it.

Keyboard Maestro Debugger (Activate:Deactivate).kmmacros (28.9 KB)

Image

image

2 Likes