One fast solution is to use xautomation tools -
http://hoopajoo.net/projects/xautomation.html and then use it in your script like this:
xte is one of the tools you can find inside. Dont forget ofc to bind key combination to focus.
The other solution is to write ur own code using XTest... and get rid of this bash script.
You can use the same way if thats more comfortable for you, to move your mouse at certain coordinates and perform mouse click like this:
Code:
$xte 'mousemove X Y'
$xte 'mousedown 1'
Maybe there are other easier solutions... :\