Another possible solution is to only use one input on the TV. Connect an A/V receiver to that one input and connect all your other devices to the A/V receiver. Then you should only need to deal with switching inputs on the TV if you want to watch over the air TV using the TV's tuner. You can probably even get rid of that need by getting a stand-alone TV tuner and hooking that up to the A/V receiver.
Many A/V receivers have network interfaces that you can use to control them if for some reason you don't want to use their remote. Most Denon receivers for example have an HTTP server that presents a web-based interface if you browse to it from a computer or mobile device.
They also run a simple HTTP based API that is easy to use from scripts. For example here is a shell script that gets the current volume setting of mine:
URL=http://192.168.0.xx/goform/AppCommand.xml
cat > tmp.$$ <<HERE
<?xml version="1.0" encoding="utf-8"?>
<tx>
<cmd id="1">GetVolumeLevel</cmd>
</tx>
HERE
curl -X POST -H "Content-Type: text/xml" --upload-file tmp.$$ $URL
rm tmp.$$
which when run gives me this at the moment: <?xml version="1.0" encoding="utf-8" ?>
<rx>
<cmd>
<volume>-45.0</volume>
<disptype>RELATIVE</disptype>
<dispvalue>-45.0dB</dispvalue>
</cmd>
</rx>