Hi,
I am currently working on a newsletter bulk sending script and I am trying to stop safari from opening a new tab every time it loops round to a new email so far I have:
tell application "Safari"
activate
if current tab = {URL:"***.com"} then
tell application "System Events"
keystroke "a" using command down
delay 2
keystroke "c" using command down
tell application "Mail"
activate
delay 1
tell application "System Events"
keystroke tab
delay 1
keystroke tab
delay 1
keystroke "test"
delay 1
keystroke tab
keystroke "v" using command down
tell application "System Events"
tell process "Mail"
repeat with i from 1 to count of EmailAddresses
keystroke "d" using {command down, shift down}
end repeat
end tell
end tell
end tell
end tell
end tell
else
activate
tell window 1 to set current tab to make new tab with properties {URL:"***.com"}
delay 2
tell application "System Events"
keystroke "a" using command down
delay 2
keystroke "c" using command down
tell application "Mail"
activate
delay 1
tell application "System Events"
keystroke tab
delay 1
keystroke tab
delay 1
keystroke "test"
delay 1
keystroke tab
keystroke "v" using command down
tell application "System Events"
tell process "Mail"
repeat with i from 1 to count of EmailAddresses
keystroke "d" using {command down, shift down}
end repeat
end tell
end tell
end tell
end tell
end tell
end if
end tell
end tell
end repeat
end tell
But I get an error when running it not compiling “AppleScript Error: Safari got an error: Can’t get current tab.”
Is there a permission I need to change or something?
Any help would be great!
Thanks,
Bruce
P.S. I did start this at the end of a forum post but I though I’d better move it to a new post as it was not apart of the question being asked.