I have a script that activates firefox, refreshes the page, waits 60 seconds, then does it again, in an infinite loop. How would I get it to go back to what was active before?
So say I have firefox in the background with a question about Applescripting on StackOverflow up, but while I wait for a response, I’m playing a game. How do I get it to, after going to firefox and refreshing, come back to the game?
Code:
i="0"
while [ $i == 0 ]
do
osascript -e 'tell application "Firefox" to activate'
osascript -e 'tell application "System Events" to key code 15 using command down'
pause 10
go back to previous window
sleep 60
done
Since you’re already using System Events, use it to hide the application.