I'm trying to maniplulate the Display Text window, as in this discussion. This is going in a macro I distribute, so I don't want to rely on the plug-in from that topic. I figured I'd just do it in AppleScript in the macro.
To make it easier to configure, though, I set it up in a subroutine, but I am having a heck of a time getting it to work. Using an alert in the AppleScript, I've confirmed it's getting my values, but the script throws an error when trying to move/size the window.
The subroutine has four local variables, localTop, localLeft, localWidth, and localHeight, and here's the script:
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set theTop to getvariable "localTop" instance kmInst
set theLeft to getvariable "localLeft" instance kmInst
set theWidth to getvariable "localWidth" instance kmInst
set theHeight to getvariable "localHeight" instance kmInst
display alert "L: " & theLeft & " T: " & theTop & " W: " & theWidth & " H: " & theHeight
tell application "System Events"
tell window "Keyboard Maestro - Display Text"
set position to {theTop, theLeft}
set size to {theWidth, theHeight}
-- tell button "OK" to set focused to true
end tell
end tell
end tell
If I comment out the window manipulation bits, the display alert works:
But when I uncomment the position and size commands, I get this in Console:
default 22:43:37.957086 -0800 Keyboard Maestro Engine Execute an AppleScript failed with script error: text-script:494:502: execution error: System Events got an error: Can’t set window "Keyboard Maestro - Display Text" to {"900", "150"}. (-10006). Macro “Search the Web” cancelled (while executing Execute AppleScript).
If, on the other hand, I just hardcode values into the script, it works. What am I missing?
thanks;
-rob.