See this:
Flipping a Switch in AppleScript (or Directly in Keyboard Maestro)? - #4 by Sleepy
For more information, see the wiki Searching the Forum for Answers section.