Alright here's something I came up with. It works well for me, but will no doubt need to be modified to suit your needs. Since I don't know what kind of window you need to place below the UIP window, I just used a Display Text action from KM itself. But the principle is the same.
You still need to run the get uip coordinates
macro asynchronously from within the calling macro but it handles all of the positioning from within the same AppleScript so it doesn’t need to wait for the prompt window to be acted on.
Try this out, see if it could be adapted to your needs and let me know what you think!
EDIT: These macros and AppleScripts use global variables, prefixed with debug_
to facilitate troubleshooting while building. The calling macro has a basic AppleScript at the end (currently disabled) to delete all those variables. You could probably convert them to instance variables if you wanted, but I didn't feel like messing with that part haha.
-Chris
place uip above dt.kmmacros (6.7 KB)
Macro screenshot (click to expand/collapse)
AppleScript for place uip above dt macro:
----------------------------------------------------------
# Author: Chris Thomerson
#
# Current Version: 1.0
# Version History: 1.0 (Initial script)
#
# Created: Friday, December 24, 2021
# Modified: Friday, December 24, 2021
# macOS: 12.1 (Monterey)
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----------------------------------------------------------
tell application "Keyboard Maestro Engine"
--gets DT variables from Keyboard Maestro
set dtXPos to getvariable "debug_dtXPos"
set dtYPos to getvariable "debug_dtYPos"
set dtXSize to getvariable "debug_dtXSize"
set dtXSize to getvariable "debug_dtYSize"
end tell
tell application "System Events"
tell application process "Keyboard Maestro Engine"
--checks for user prompt existence
repeat until window "Keyboard Maestro User Input" exists
delay 0.1
end repeat
--gets all coordinates for user prompt
tell window "Keyboard Maestro User Input"
--gets user prompt position and size
set uipPos to its position
set uipSize to its size
--separates user prompt individual coordinates
set {uipXPos, uipYPos} to uipPos
set {uipXSize, uipYSize} to uipSize
set its position to {dtXPos, dtYPos - uipYSize}
--set its position to {100, 100}
end tell
end tell
end tell
tell application "Keyboard Maestro Engine"
--sets separated UIP coordinates to Keyboard Maestro variables
setvariable "debug_uipXPos" to uipXPos
setvariable "debug_uipYPos" to uipYPos
setvariable "debug_uipXSize" to uipXSize
setvariable "debug_uipYSize" to uipYSize
end tell
get uip coordinates (subroutine).kmmacros (4.1 KB)
Macro screenshot (click to expand/collapse)
AppleScript for get uip coordinates (subroutine) macro:
----------------------------------------------------------
# Author: Chris Thomerson
#
# Current Version: 1.0
# Version History: 1.0 (Initial script)
#
# Created: Friday, December 24, 2021
# Modified: Friday, December 24, 2021
# macOS: 12.1 (Monterey)
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----------------------------------------------------------
tell application "System Events"
tell application process "Keyboard Maestro Engine" to tell window "Keyboard Maestro - Display Text"
set position to {800, 600}
set size to {300, 150}
set dtPos to its position
set dtSize to its size
set {dtXPos, dtYPos} to dtPos
set {dtXSize, dtYSize} to dtSize
end tell
end tell
tell application "Keyboard Maestro Engine"
setvariable "debug_dtXPos" to dtXPos
setvariable "debug_dtYPos" to dtYPos
setvariable "debug_dtXSize" to dtXSize
setvariable "debug_dtYSize" to dtYSize
end tell