I open it in script editor and made a new bundle for macOS Mojave.
Test the example script from Sal with New Template Cocoa-AppleScript Applet.app
– main.scpt
– Cocoa-AppleScript Applet
– Copyright 2011 {Your Company}. All rights reserved.
– This is the main script for a Cocoa-AppleScript Applet.
– You can put the usual script applet handlers here.
use AppleScript version “2.7”
use script “WebKit Utilities”
set the windowObject to display URL ¬
“http://www.apple.com” window size {600, 800}
I get this error:
Can’t get |size| of {«class form»:«constant ****usrp», «class want»:property, «class seld»:“visibleFrame”, from:mainScreen of NSScreen}. (-1728)
Not sure, but thinking the window size from the NSScreen is not correct setup.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use scripting additions
on screenSize()
set theScreen to current application's NSScreen's mainScreen()
set theFrame to theScreen's visibleFrame()
return {item 1 of theFrame, item 2 of theFrame}
end screenSize
screenSize()
It was not so difficult to get something on the screen with HTML document.
I’m not sure if this is correct way to do it, I remove the ScreenBounds origin of the last complain.
set {thisWindowWidth, thisWindowHeight} to theWindowSize
set screenBounds to the NSScreen's mainScreen's visibleFrame()
set screenWidth to item 2 of item 1 of screenBounds
set screenHeight to item 2 of item 2 of screenBounds
set windowLeft to ((screenWidth - thisWindowWidth) / 2) -- + (screenBounds's origin's x)
set windowBottom to screenHeight - thisWindowHeight -- + (screenBounds's origin's y) - 40
I use this instead and made a reference
set screenWidth to NSWidth(screenBounds)
set screenHeight to NSHeight(screenBounds)