This is an AppleScript I wrote that works in conjunction with a free little utility called Caffeine (you can download it from the developer at http://lightheadsw.com/caffeine/, and it is also available on the Mac App Store). Caffeine is a Menubar app that effectively keeps your screensaver and power-saving functions from activating, thereby keeping your screen, and your Mac, awake. I have Caffeine set to load on boot up for ease of use, but you don't have to if that's not your preference, though you will need to have Caffeine running in order for this particular script to work as I've written it.
-- Author: Tim Bolhouse -- Created: 26 August 2014 3:09:14 pm -- Modified: 07 April 2015 2:57:23 am -- Application: Caffeine -- Task: Activate/Deactivate 1.1.3 -- Tags: @AppleScript, @Script, @Screensaver -- Script Name: Activate/Deactivate Caffeine -- This script turns on or turns off the Caffeine app depending on its current state. -- It overrides any default time setting you have set in Caffeine Preferences. (* If you want to activate the app for a specific length of time and then have it deactivate automatically, replace "*turn on*" with "*turn on for 0000*", where 0000 being the number of seconds you wish to keep Caffeine active. Can be as short as 1 second or as long as you want. Leading zeros are not required. *) tell application "Caffeine" if active = false then turn on else turn off end if end tell
This is what it will look like in Keyboard Maestro: