////////////
//
//  Script: senToggleResolutionGate 0.1.1
//  Updated: 7 May 2008
//  Compatibility: Maya 8 and higher
//  Probably works with earlier versions, too.
//
//
//  Written by Sven-Erik Neve
//  Website and contact info: www.seneve.de
//  Bugs, comments, questions or suggestions? Get in touch!
//
//
//  Usage:
//  Focus a viewport (for example middle mouse-click
//  anywhere in a viewport) and run the script by executing
//  the senToggleResolutionGate command.
//
//
//  Installation:
//  Copy this source code within a MEL file to one of your
//  scripts folders, for example on Windows XP 32-bit to the
//  folder \My Documents\maya\<version>\scripts. Start Maya
//  or (if it is running) use the rehash command to make Maya
//  aware of the newly copied script. Execute the script with
//  the senToggleResolutionGate command.
//
//
//  Purpose:
//  By default you enable and disable Resolution Gates in the
//  Camera Settings of each viewport's View menu. This script
//  toogles the Resolution Gate of the active viewport and
//  sets the correct amount of overscan. Cuts down on the need
//  to use a menu.
//
////////////

global proc senToggleResolutionGate() {
	// Is a model panel focused? If it is, go on.
	string $focusedPanel = `getPanel -wf`;
	if (`getPanel -to $focusedPanel` == "modelPanel")
	{
		// Get camera name and Resolution Gate setting.
		string $camInPanel = `modelPanel -q -cam $focusedPanel`;
		int $camResGate = `camera -q -dr $camInPanel`;

		// Toggle Resolution Gate and set overscan.
		camera -e -dr (!$camResGate) $camInPanel;
		if (!$camResGate) camera -e -ovr 1.3 $camInPanel;
		else camera -e -ovr 1.0 $camInPanel;
	}
}

senToggleResolutionGate(All) MEL script. Note: This source code toggles the Resolution Gate of the active viewport's camera only. The ZIP archive also contains a version that toggles the Resolution Gates of all cameras. Here's how the script works: It checks whether the Resolution Gate is enabled for the camera of the active viewport. It then toggles the Resolution Gate and sets the correct amount of overscan.

Download this script (1.88 KiByte)
Maya 8 or higher, probably works with earlier versions, too.