Monday, September 28, 2020

#1 2019-11-17 09:52:09 am

Fredrik71
Member
Registered: 2019-10-23
Posts: 393

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 ??


I could teach you to cook but I couldn't do anything if you do not have desire or commitment for it.


Filed under: webkit

Offline

 

#2 2020-03-14 07:59:37 pm

maro
Member
From:: Nerima, Tokyo, Japan
Registered: 2004-05-30
Posts: 128
Website

Re: WebKit Utilities (ASOC) from Sal Soghoian

set screenBounds to the NSScreen's mainScreen's visibleFrame as record



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.


I wrote thousands of AppleScript to realize my idea. Natural language interface, voice recognition commander and so on. Though my mother toungue is strange language, Japanese, my most frequently write language is AppleScript. I believe it is for making things easy and powerful.

Offline

 

#3 2020-03-15 03:19:47 am

Fredrik71
Member
Registered: 2019-10-23
Posts: 393

Re: WebKit Utilities (ASOC) from Sal Soghoian

Thanks, I have to study more to... smile

maro wrote:

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




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

maro wrote:

It is not so difficult task.


I could teach you to cook but I couldn't do anything if you do not have desire or commitment for it.

Offline

 

#4 2020-03-15 05:15:42 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6460

Re: WebKit Utilities (ASOC) from Sal Soghoian

Fredrik71 wrote:

direction/pointer ??



There's a description here:

https://latenightsw.com/high-sierra-app … objc-bugs/

See the section NSRect a list, not record


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#5 2020-03-15 09:36:40 am

Fredrik71
Member
Registered: 2019-10-23
Posts: 393

Re: WebKit Utilities (ASOC) from Sal Soghoian

Thanks, Shane.

I did some test on your code in your book.

Applescript:

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.


I could teach you to cook but I couldn't do anything if you do not have desire or commitment for it.

Offline

 

#6 2020-03-15 11:12:15 am

Fredrik71
Member
Registered: 2019-10-23
Posts: 393

Re: WebKit Utilities (ASOC) from Sal Soghoian

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.

Applescript:

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

Applescript:

set screenWidth to NSWidth(screenBounds)
set screenHeight to NSHeight(screenBounds)

Last edited by Fredrik71 (2020-03-15 02:52:48 pm)


I could teach you to cook but I couldn't do anything if you do not have desire or commitment for it.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)