• 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: Getting Tab Index and Window ID in Safari
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting Tab Index and Window ID in Safari


  • Subject: Re: Getting Tab Index and Window ID in Safari
  • From: "Nigel Garvey" <email@hidden>
  • Date: Sun, 21 May 2017 11:13:16 +0100

Christopher Stone wrote on Sat, 20 May 2017 18:15:07 -0500:

>tell application "Safari" to set tabWinList to tabs of windows
>
>try
>    tabWinList / 0
>on error eMsg
>    set AppleScript's text item delimiters to {"Can’t make ", " into
type
>real.", "of application \"Safari\"", " of window id", "«class bTab»"}
>    set tabWinList to text items of eMsg
>    set AppleScript's text item delimiters to linefeed
>    set tabWinList to tabWinList as text
>    set tabWinList to words of tabWinList
>    repeat with theWord in tabWinList
>        try
>            set contents of theWord to theWord as integer
>        on error
>            set contents of theWord to "null"
>        end try
>    end repeat
>end try
>
>set tabWinList to integers of tabWinList

Hi Chris.

1. I'm getting results for an invisible window with Safari 10.1.1 in El
Capitan. It looks (after minimal testing) as if windows with tabs
showing sites which plant cookies are only made invisible when they're
"closed" and are only deleted when Safari quits.
2. Your script doesn't reset the TIDs.
3. This seems to be about the same speed and independent of the user
language:

  set tabWinList to {}
  tell application "Safari"
    set windowIDs to id of (windows whose visible is true)
    repeat with i from 1 to (count windowIDs)
      set thisID to item i of windowIDs
      repeat with j from 1 to (count tabs of window id thisID)
        set end of tabWinList to j
        set end of tabWinList to thisID
      end repeat
    end repeat
  end tell
  tabWinList

NG
 _______________________________________________
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

  • Follow-Ups:
    • Re: Getting Tab Index and Window ID in Safari
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: Getting Tab Index and Window ID in Safari
  • Next by Date: Re: Safari - Bring a tab containing a given URL to the front
  • Previous by thread: Re: Getting Tab Index and Window ID in Safari
  • Next by thread: Re: Getting Tab Index and Window ID in Safari
  • Index(es):
    • Date
    • Thread