resolution changes with applescript?

Hi there. I am new to applescript, but was wondering if it might be fairly straight forward to come up with a script to fix my current dilemma. I am assuming that once I have a script or scripts, that there would be a way to run the script with a keyboard shortcut? Would I need a separate app to do this?

This is just the latest puzzle in my seemingly ongoing quest to use my mac mini as a HTPC…

I have a 22" widescreen vga monitor hooked up to my mini. I also have a LCD projector with a dvi input that I use for watching movies. I had been manually pulling out the cable and reconnecting the other each time I wanted to switch. I just bought a manual switch box that allows switching between one of two displays. However, when I switch, it doesnt automatically detect the proper resolution. In particular, when switching from the vga monitor to the dvi projector, it doesnt detect that the projector is a digital input unless I disconnect the cable and wait a few seconds, then plug it back in. Sometimes I have to do it several times before it works. The other issue is going the other way, from the projector to the monitor. It switches OK, but my desktop icons are all in the wrong place, and cannot be clicked on. I found that if I simply click “detect displays”, nothing happens. However, if I change the resolution to something else, and then back, everything is as it should be.

So I guess I’m looking for two things here:

  1. a script that will make my mac mini detect that it is hooked up to a digital display, and not an analog one. It needs to be done blind.
  2. a script that will either reset the screen resolution (remember “detect displays” does nothing) or will select another resolution, wait 5 seconds, and then select the proper resolution.

Thanks in advance