Which platform are you using windows, linux or mac?
For mac, you could use applescript to automate an action like this. Never tried but it more than likely could be done. Probably for Linux at the unix level you could also achieve such a thing 'if you know how'. lol