Writing a Simple AutoHotkey Script (press a key every X second on desktop)

Solution 1:

Why do you want to send F11 to the desktop?
If it's just to keep your computer awake you can use the following script:

#SingleInstance, force
#Persistent
SetTimer, NoSleep, 30000
Return

NoSleep:
 DllCall( "SetThreadExecutionState", UInt,0x80000003 )
Return

From Microsoft:

SetThreadExecutionState function
Enables an application to inform the system that it is in use, thereby preventing the system from entering sleep or turning off the display while the application is running.


It is also possible to emulate mouse-action to keep the system from sleeping
(if above script somehow doesn't work for you):

Loop {
    Sleep, 30000
    MouseMove, 1, 0, 1, R  ;Move the mouse one pixel to the right
    MouseMove, -1, 0, 1, R ;Move the mouse back one pixel
}

So there would be no need to emulate actually pressing a key.