1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Screen lock

Discussion in 'T&T - Scripting' started by thorsten, Oct 13, 2011.

  1. thorsten

    Joined:
    Aug 16, 2008
    Messages:
    124
    Likes Received:
    0
    How can I check in a script whether the screen is locked?
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    If %_WINFGWINDOW returns a null string, the screen may or may not be locked -- but clearly something is going on.
     
  3. thorsten

    Joined:
    Aug 16, 2008
    Messages:
    124
    Likes Received:
    0
    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.
     
  4. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    Does it make a difference if you use?
    Code:
    iff "%_WINFGWINDOW" != "" then
     
  5. thorsten

    Joined:
    Aug 16, 2008
    Messages:
    124
    Likes Received:
    0
    Hehe, bingo :-). Just recently I reminded someone of the necessity of quoting and now I got hit myself :-). Thanks!
     
  6. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,189
    Likes Received:
    11
    According to the MS Scripting Guy, there's
    no definitive way. The example they used was to see if the screen
    saver was running.

    To do that in TCC, query the registry
    for the name of the screen saver:

    echo %@regquery["hkcu\control panel\desktop\SCRNSAVE.EXE"]

    And check to see if it is running:

    iff %@PID[%@filename[%@regquery["hkcu\control
    panel\desktop\SCRNSAVE.EXE"]]] == 0 then
    echo
    Screen saver is not running
    else
    echo
    Screen saver is running
    endiff

    -Scott



    How can I check in a script whether the
    screen is locked?
     
  7. thorsten

    Joined:
    Aug 16, 2008
    Messages:
    124
    Likes Received:
    0
    That's not going to work. I for instance have Webshots running and the application that changes the desktop background is the screen saver (webshots.scr). That means webshots.scr (=SCRNSAVE.EXE) is always running - even when the screen saver is not running.

    Interestingly "%@winsystem[114]" (SPI_GETSCREENSAVERRUNNING) does also not work (always returns 0)
     

Share This Page