Thanks, that should be the one I'm looking for. Unfortunately the following doesn't work:
do forever
iff %_WINFGWINDOW != "" then
beep 440 2
endiff
delay 1
enddo
...meaning it also beeps when I lock the screen. Strangely, echoing %_WINFGWINDOW in locked state emits "ECHO is OFF", so it should be a null string when the screen is locked.