WebKit Utilities (ASOC) from Sal Soghoian

Hello all.

I was trying WebKit Utilities (ASOC) from Sal.

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.

Anyone any clue ??

Sal’s Webkit Utility is written before macOS 10.13 era.
Bounds related function result format changed in macOS 10.13 (spec? bug?)

Pre 10.13: record
After 10.13: list

So, you’d better to change Webkit Utility to prepare bounds.

It is not so difficult task.

Thanks, I have to study more to… :slight_smile:

Thanks again for your confident in me, could you give me the direction/pointer ??

There’s a description here:

https://latenightsw.com/high-sierra-applescriptobjc-bugs/

See the section NSRect a list, not record

Thanks, Shane.

I did some test on your code in your book.

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()

This gave me the screenSize… on Mojave.

Maro, Shane.

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)