Experimente este script AHK:
$F1 Up:: ; or whatever combination you want
Keyboard_Blocked := true ; assign the Boolean value "true" or "1" to this variable
BlockInput On ; disable keyboard and mouse
SendMessage, 0x112, 0xF170, 2,, Program Manager ; turn the monitor off, similar to power saving mode
; or:
; Run path of your screensaver
return
; The #If directive creates context-sensitive hotkeys:
#If (Keyboard_Blocked) ; If this variable has the value "true"
$F1 Up:: ; press F1 to re-enable keyboard and mouse and turn the monitor on
BlockInput Off
Keyboard_Blocked := false
return
#If ; turn off context sensitivity
EDITAR:
Em vez de configurar nas opções de energia o tempo de inatividade depois que o monitor desligar ou pressionar Win + L para bloquear o sistema, você pode fazê-lo usando um script AHK permanentemente em execução. Neste script você pode adicionar mais coisas (teclas de atalho, hotstrings, funções etc.) que facilitam seu trabalho.
#NoEnv
#SingleInstance Force
SetTimer, DetectTimeIdle, 50
return
DetectTimeIdle:
; lock the computer automatically after 20 seconds of inactivity.
; Replace 20000 with 60000 for 1 minute etc.
If (A_TimeIdle > 20000) ; as long as there is no input within the last 20 seconds
GoSub !F1 Up ; jump to this hotkey definition
return
; Press Alt+F1 to manually lock the computer
!F1 Up::
Keyboard_Blocked := true ; assign the Boolean value "true" or "1" to this variable
BlockInput On ; disable keyboard and mouse
SendMessage, 0x112, 0xF170, 2,, Program Manager ; turn the monitor off, similar to power saving mode
return
#If (Keyboard_Blocked)
; press F1 or F2 or Space ... to re-enable keyboard and mouse and turn the monitor on
$F1 Up::
$F2 Up::
$Space Up::
; ...
BlockInput Off
Keyboard_Blocked := false
; Move the mouse (speed 10) by 20 pixels to the right and 30 pixels down from its current location to unlock the computer:
MouseMove, 20, 30, 10, R
reload
return
#If