#SingleInstance, FORCE
Gui, +LastFound
hRecipient := WinExist()
DISP_GUID := "{6fe69556-704a-47a0-8f24-c28d936fda47}"
VarSetCapacity(DISP_STAT, 16, 0)
DllCall("ole32\CLSIDFromString", "UInt", &DISP_GUID, "UInt", &DISP_STAT)
hDisp := DllCall("RegisterPowerSettingNotification", "UInt", hRecipient, "UInt", &DISP_STAT, "UInt", 0)
OnMessage(0x0218, "DispStatChange")
OnExit("ExitSub")
SetTimer, DispTimer, 1000
Return

DispStatChange(wParam, lParam, msg, hwnd)
{
global DispStat
DispStat := NumGet(lParam + 16 + 4)
}

ExitSub()
{
global hDisp
DllCall("UnregisterPowerSettingNotification", "UInt", hDisp)
}

!F10:: Msgbox, % DispStat ? "Display On" : "Display Off"

DispTimer:
If DispStat
Return
Msgbox, % DispStat ? "Display On" : "Display Off"
ExitApp