How can I create a script that automatically switches windows? I'm trying to do the same thing Alt+Tab does.
The answer from sr_ mentioned
wmctrl, which works for me.
I installed it on Ubuntu 16.04 with
sudo apt-get install wmctrl. I was able to switch window with
wmctrl -a emacs24.
wcmtrl -a $WIN seems to search for windows with names that contain the string
$WIN. The search is case-insensitive.
Here is man wmctrl for reference.