I'd like to have a script that gets some input on one Chrome window, switches to another Chrome Window to process it, and then returns to the original window.
I can get the Chrome window title from the original window, process on the second window, but I'm failing to return to the original window.
this is the working code to get the Window title:
my getCurrentWindowTitle() my returnToOriginalWindow() global frontApp, frontAppName, windowTitle set windowTitle to "" on getCurrentWindowTitle() tell application "System Events" set frontApp to first application process whose frontmost is true set frontAppName to name of frontApp tell process frontAppName tell (1st window whose value of attribute "AXMain" is true) set windowTitle to value of attribute "AXTitle" end tell end tell end tell end getCurrentWindowTitle
And this is the code bit which I'm struggling to tweak so I can return to the original window:
on returnToOriginalWindow() tell application "Google Chrome" to set index of window 1 where title contains windowTitle to 1 delay 0.05 do shell script "open -a Google\\ Chrome" end returnToOriginalWindow
Any insights on how to test, develop, fix this are really appreciated.