////////////
//
//  Script: senToggleWireframeOnShaded 0.1
//  Updated: 12 March 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 execute the
//  senToggleWireframeOnShaded 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 senToggleWireframeOnShaded command.
//
//
//  Purpose:
//  By default you set Wireframe on Shaded mode in the Shading
//  menu of each viewport. This script not only toggles
//  Wireframe on Shaded for all viewports at once, it also
//  cuts down the need to use a menu.
//
////////////

global proc senToggleWireframeOnShaded() {
	// Is a model panel focused? If it is, go on.
	string $focusedPanel = `getPanel -wf`;
	if (`getPanel -to $focusedPanel` == "modelPanel")
	{
		// Check WoS setting and get a list of all model panels.
		int $focusedPanelWOS = `modelEditor -q -wos $focusedPanel`;
		string $modelPanels[] = `getPanel -typ modelPanel`;
		{
			// Toggle WoS for all model panels.
			for ($element in $modelPanels)
			{
				modelEditor -e -wos (!$focusedPanelWOS) $element;
			}
		}
	}
}

senToggleWireframeOnShaded MEL script. This script toggles Wireframe on Shaded mode for all viewports. It starts by checking whether the focused panel is of type modelPanel – a regular viewport. If it is the script queries the modelPanel's Wireframe on Shaded mode. It also saves a list of all modelPanels currently in the scene. Finally the script sets Wireframe on Shaded mode in all modelPanels to be the opposite of what it is in the active panel.

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