I have three instances of Firefox called -
- Firefox
- Firefox 2
- Firefox 3
They all live in the Applications folder and the difference is that they have different Firefox profiles and cookies.
I'd like to run an apple script that works on a particular instance of Firefox.
tell application "Firefox"
activate
tell application "System Events"
keystroke "n" using {command down}
end tell
end tell
tell application "Firefox"
activate
tell application "System Events"
keystroke "l" using {command down}
keystroke "a" using {command down}
key code 51
keystroke "https://google.com"
key code 36
end tell
end tell
If I run this with Firefox open then it works exactly how I want it to.
But, if Firefox is closed, but Firefox 2 or Firefox 3 are open then it has weird behavior.
It will replace the word Firefox with Firefox 2 or Firefox 3 (whichever is open and last active) and then it will run the script using that instance of Firefox which is not what I want.
tell application
block inside another. Keep them separate. You can easily just havetell application "Firefox" to activate
on a line of its own before your System Events block.