Can I use automator to launch a keystroke when program is idle
I don't know how well it would work, but you could try running something like this in AppleScript Editor.

repeat
    tell application "System Events" to tell process "Safari"
        set p to properties of UI elements of UI elements
        delay 10
        if properties of UI elements of UI elements is p then
            set frontmost to true
            keystroke "r" using command down
            --return
            delay 20
        end if
    end tell
end repeat