Applescript: Check if Tab is open - if yes:activate, no:open
Posted: Fri Sep 30, 2011 8:16 pm
Hi everbody
I know, this thread could also be posted in an applescript forum, but im completely new to OS X and applescript and Iron, which is why i have no idea where I could find such a forum, and, given the question relates to Iron, i hope to find some answers in this forum. Please dont kill me
What I would like to do, is to build an applescript that checks if in Iron a tab which has the name "dict.leo.org" in its title, is open (not necessarily active).
If it is open, Applescript should activate it.
If it is not open, Applescript should open a new tab and activate it.
Here is what i tried (I know its probably completely wrong - but please have pitty, its one of my first baby steps in applescript - im willing to learn!)
I know, this thread could also be posted in an applescript forum, but im completely new to OS X and applescript and Iron, which is why i have no idea where I could find such a forum, and, given the question relates to Iron, i hope to find some answers in this forum. Please dont kill me

What I would like to do, is to build an applescript that checks if in Iron a tab which has the name "dict.leo.org" in its title, is open (not necessarily active).
If it is open, Applescript should activate it.
If it is not open, Applescript should open a new tab and activate it.
Here is what i tried (I know its probably completely wrong - but please have pitty, its one of my first baby steps in applescript - im willing to learn!)
Code: Select all
tell application "Chromium"
activate
set i to 0
set activated to false
repeat with t in (tabs of (first window whose index is 1))
set i to i + 1
if title of t contains "dict.leo.org" then
set (active tab index of (first window whose index is 1)) to i
set activated to true
end if
end repeat
if activated is false then
make new window
open "http://dict.leo.org"
end if
end tell