• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting Safari Web page loading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Detecting Safari Web page loading (From: Takaaki Naganoya <email@hidden>)

  • Prev by Date: Re: Old script now fails
  • Next by Date: Re: Detecting Safari Web page loading
  • Previous by thread: Re: Detecting Safari Web page loading
  • Next by thread: Old script now fails
  • Index(es):
    • Date
    • Thread