What you need is the KM WiKi article “Using AppleScript to Get and Set Keyboard Maestro Variables”.
In short:
You want to get KM variables into the AppleScript, so you would do something like this (at the beginning of your AppleScript):
tell application "Keyboard Maestro Engine"
set trimTop to getvariable "Top"
set trimBottom to getvariable "Bottom"
set trimLeft to getvariable "Left"
set trimRight to getvariable "Right"
end tell
Then use the new variables (trimTop
, etc.) in the script.