Manipulate KM’s Display Text Window

Agreed.

I can make the request, but coming from your mouth, @JMichaelTX and @ccstone it would make more impact i presume... :slight_smile:

Not necessarily. Peter will consider all requests. Go ahead an make it, and we'll jump in. :wink:

@ccstone, @JMichaelTX, @peternlewis

Here you go:

1 Like

Any update for KM9 ?

I see. It throws an error:

Plug In failed with script error:[…] : Can’t set window "Keyboard Maestro - Display Text"

You get the same?

@peternlewis, any recent (or not so recent) changes that provoke this? Or a quick hint, that would save me from diving into…?

1 Like

Not that I can think of. Perhaps it is a security permission issue? Not having accessibility or automation access to Keyboard Maestro Engine?

Script in Above Plugin

# Description: Part of a KM action. Manipulates the most recent Display Text Window.
# Author: Tom Floeren <ecdltf@mac.com>, http://dflect.net
# Version: 0.9.1
# Mod. Date: 2017-05-05


set winName to "Keyboard Maestro - Display Text"
set thePosition to system attribute "KMPARAM_Position"
set theSize to system attribute "KMPARAM_Size"
set focusOK to system attribute "KMPARAM_Focus_OK_button"
set activateWin to system attribute "KMPARAM_Make_window_active"

set {theX, theY, theWidth, theHeight} to {0, 0, 0, 0}

set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {","}

try
  set theX to text item 1 of thePosition as integer
  set theY to text item 2 of thePosition as integer
end try
try
  set theWidth to text item 1 of theSize as integer
  set theHeight to text item 2 of theSize as integer
end try

set AppleScript's text item delimiters to saveTID

if activateWin = "1" then tell application "Keyboard Maestro Engine" to activate

tell application "System Events"
  tell application process "Keyboard Maestro Engine"
    tell window winName
      if thePosition ≠ "" then set position to {theX, theY}
      if theSize ≠ "" then set size to {theWidth, theHeight}
      if focusOK = "1" then tell button "OK" to set focused to true
    end tell
  end tell
end tell

@Tom, FWIW, I don't get any errors when I run the AppleScript in the below PlugIn.
Running Keyboard Maestro 9.1d1 on macOS 10.14.6 (Mojave).

OK, tried the plugin again today and got no errors this time.

I can reproduce the error I got the last time by disabling the Display Text in Window action before. So, I guess, when I got the error, the window wasn’t properly on screen for some reason when the Manipulate action was executed.

@slimhan, do you get the error I posted above? If yes, see if it disappears if you throw in a pause between window-creating action and Manipulate Window action. Or/and check the other actions in your macro for possible interference. Or do you have a different issue?

@Tom Well I didn't try to install it because it said "Update for KM8" on the post

The update for KM8 was for a reason (see the post).

But it’s nearly impossible for me, or for other people who have posted many macros/plugins, to test each one after each KM update. So, just assume a macro/plugin still works; you’ll notice if it doesn’t. (Unless it’s some dangerous or security-critical stuff.)

Well, so, instead of testing if it works, you had us do the testing :hugs:. I would say you can install it now :wink:

You are right. I was in a hurry when I wrote my first post and then forgot about it. I'll check it now! :blush:

I just tried it and I don't get any errors. The only thing for me is the latency. It moves the window sometimes seconds later and sometimes really fast. But it's not because of the plugin, I have this issue with other macros using AppleScript too.

On 10.15? Any heavy background stuff running, especially third-party anti-virus software?

It's 10.14.6 No heavy background process. And just CleanMyMac if that counts as an anti-virus software.

From their web page:

CleanMyMac X officially holds a “Gold” level of Mac virus detection. We give you a real-time shield against trojans, data miners, and recent browser hijackers.

This most likely means that is has some background process(es) running all the time.

But I guess you already have tried your AppleScripts with CleanMyMac disabled, right? (Not only the front-end app shut down, also all processes that belong to it, + reboot without these processes.)

I would also be careful with the “Junk cleaning” functions of these apps. Often, what they label as ‘junk’ are actually cache files and folders. And they are there for a reason. (Unless it is orphaned cache from some uninstalled apps, or if there are indications that a cache contains corrupted data.)

Is it possible to use variables for the position?

eg I'd love to move a Display Text window to "the center", which may be a different location depending on which monitor I'm using.

another eg: In some use-cases I'd love to be able to move a Display Text window to %CurrentMouse% so that it showed up right where I'm looking at that moment

Thanks for this great plugin :slight_smile:

Dan

While searching for how to manipulate a Display Text window, I found a loose end in a sidetrack in this thread. The issue was how to call attention to the fact that the plugin of this thread had been updated. One solution was to paste in an image of text that had the desired background color. At that time Discourse may not have supported the <mark> tag.

But Discourse does support <mark> now, so inserting an image of text should no longer be necessary.

Does anyone still use this plugin? Has something else replaced it?

The last reported test was three years ago (Nov 2020), saying that it works about 3.5 years after it was first released (May 2017).

I haven't tested it, but the only thing you'd need it for today is the OK button and bringing the window to the foreground. The Set Next Engine Window Position can handle the size and location of the window.

-rob.

1 Like