• 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: Browser tab
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Browser tab


  • Subject: Re: Browser tab
  • From: Christopher Stone <email@hidden>
  • Date: Sun, 30 Apr 2017 23:20:25 -0500

On 04/30/2017, at 20:08, Tony <email@hidden> wrote:
I have several scripts that I use in a FileMaker database to scrape data from various webpages — using a filemaker perform AppleScript step.
...
Starting with safari 10.1, the make new document lines are started creating Safari crashes (albeit this script line does not cause an exception if run directly from script editor.


Hey Tony,

I've no idea why the script when run from FileMaker is crashing Safari, and I don't have FMP to test with.

My best guess would be a text-encoding issue, but that's a complete shot in the dark.

I can tell you that Apple has broken a number of things in Safari 10.1 (12603.1.30.0.34).

For one – it no longer sees its own Preferences window.

You'll have to resort to System Events to work with it:

------------------------------------------------------------------------------

set prefTabList to {"General", "Tabs", "AutoFill", "Passwords", "Search", "Security", "Privacy", "Notifications", "Extensions", "Advanced"}
set frontWindowNotPrefs to false

tell application "System Events"
    tell application process "Safari"
        tell (first window whose subrole is "AXStandardWindow")
            if its name is in prefTabList then
                tell toolbar 1
                    tell button "Security"
                        perform action "AXPress"
                    end tell
                end tell
            else
                set frontWindowNotPrefs to true
            end if
        end tell
    end tell
end tell

set theURL to "https://www.google.com/search?num=50&newwindow=1&site=&source=hp&q=Weird+shit+Maynard&oq=Weird+shit+Maynard&gs_l=hp.3..0i22i30k1.326.326.0.6622.3.3.0.0.0.0.161.353.1j2.3.0....0...1c.2.64.hp..0.1.127.0.iyXrddUPj4k"

if frontWindowNotPrefs then
    tell application "Safari"
        # return "Do something with document windows..."
        make new document with properties {URL:theURL}
    end tell
end if

------------------------------------------------------------------------------

For another – the method I spent days working out and testing back in 2005 to get document windows no longer works.

------------------------------------------------------------------------------
tell application "Safari"
    set winList to windows where its document is not missing value
end tell
------------------------------------------------------------------------------

So far this works for me:

------------------------------------------------------------------------------
tell application "Safari"
set winList to windows
end tell
------------------------------------------------------------------------------

But reports have come in from a few users of odd-ball invisible windows when using that code, so I'm not inclined to trust it at this time.

The code you used:

------------------------------------------------------------------------------
 (every window where visible is true)
------------------------------------------------------------------------------

Is not safe, because minimized windows are not picked up by it.

I'll post a script in a bit that safely gets all document windows.

--
Best Regards,
Chris

 _______________________________________________
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: 
 >Browser tab (From: Tony <email@hidden>)

  • Prev by Date: Re: Copying the path of files selected in Finder
  • Next by Date: Safari 10.1 on macOS 10.12.4 – Getting Valid Document Windows
  • Previous by thread: Browser tab
  • Next by thread: Safari 10.1 on macOS 10.12.4 – Getting Valid Document Windows
  • Index(es):
    • Date
    • Thread