------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/05/20 17:30
# dMod: 2017/05/20 17:42
# Appl: Safari
# Task: Get Tab Index and Window ID of every window as a list
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Safari, @Tab_Index, @Window_ID
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------
------------------------------------------------------------------------------
# Satimage.osax Version
------------------------------------------------------------------------------
tell application "Safari" to set tabWinList to tabs of windows
try
tabWinList / 0
on error eMsg
set tabWinList to fnd("\\d+", eMsg, true, true) of me
end try
------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on fnd(_find, _data, _all, strRslt)
try
find text _find in _data all occurrences _all string result strRslt with regexp without case sensitive
on error
return false
end try
end fnd
------------------------------------------------------------------------------