HI, I've made an applescript that runs fine in script editor or Script debugger, but when I paste the same script in KM, it asks "Where is osascript?"
Here's the script:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set myApplication to name of current application
set screenWidth to 2560 --1920
set screenHeight to 1440
tell application myApplication
if (count of windows) ≤ 2 then
set myWidth to screenWidth / 2
set bounds of window 1 to {0, 0, myWidth, screenHeight}
try
set bounds of window 2 to {myWidth, 0, myWidth * 2, screenHeight}
end try
end if
end tell
My goal here is I want to resize the windows of the front app but with conditionals.
If I have 1 or 2, set them to half the width of the screen.
if I have 3 or 4, set them at half the width and half the height, each in a corner
if I have 5 or 6, set them at 1/3 the width and half the height
if I have 7 or 8, set them at 1/4 the width and half the height
ideally, it would work for the windows on a specific monitor in a dual monitor setup. I have an idea of how to do all the conditionals in Applescript. Will likely get stomped on the getting the info of which monitor the windows is in at some point, but since I can't get past the osascript message. I can't go any further.
Since KM can do a LOT, it might be able to do all this on its own, but I haven't figured out how to count window of the front app.
Any help appriciated:-)