Re: Detecting Safari Web page loading
Re: Detecting Safari Web page loading
- Subject: Re: Detecting Safari Web page loading
- From: Takaaki Naganoya <email@hidden>
- Date: Tue, 20 Mar 2018 00:21:05 +0900
My event listener script was wrong. It did not work.
<AppleScript>
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
set |center| to my NSDistributedNotificationCenter's defaultCenter()
|center|'s addObserver:me selector:"notify:" |name|:(missing value)
object:(missing value)
on notify:notification
set |name| to (notification's |name|) as text
set object to (notification's object())
set userInfo to notification's userInfo
try
message(object, |name|, userInfo's |Artist|)
--|name|と|Name|は混在できない
on error
message(object, |name|, "")
end try
end notify:
on message(title, subtitle, msg)
set notification to current application's NSUserNotification's
alloc()'s init()
set notification's title to title
set notification's subtitle to subtitle
set notification's |informativeText| to msg
my (NSUserNotificationCenter's defaultUserNotificationCenter()'s
deliverNotification:notification)
end message
</AppleScript>
--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/
> 2018/03/19 23:11、Takaaki Naganoya <email@hidden>のメール:
>
> Hi, everyone.
>
> Can we detect Safari’s web loading event from external AppleScript?
> A notification listening script reports
>
> “com.apple.CFNetwork.CookiesChanged.XxXXXXXXXxXxXXxXxxXXXxXXxXxXXXxxXXXXXxxX”
>
> with Safari’s loading new URL.
>
>
> <AppleScript>
> use AppleScript version "2.4"
> use scripting additions
> use framework "Foundation"
>
> set |center| to my NSDistributedNotificationCenter's defaultCenter()
> |center|'s addObserver:me selector:"notify:" |name|:(missing value)
> object:(missing value)
>
> on notify:notification
> log {aName}
> end notify:
>
> on message(title, subtitle, msg)
> set notification to my NSUserNotification's alloc()'s init()
> set notification's title to title
> set notification's subtitle to subtitle
> set notification's |informativeText| to msg
> my (NSUserNotificationCenter's defaultUserNotificationCenter()'s
> deliverNotification:notification)
> end message
> </AppleScript>
>
>
> --
> Takaaki Naganoya
> email@hidden
> http://piyocast.com/as/
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden