Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • August 19, 2017, 03:46 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: How to run a script after every win-unlock ???  (Read 6434 times)

hhbuesch

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 2
    • View Profile
    • Donate to Member
How to run a script after every win-unlock ???
« on: December 24, 2009, 07:10 AM »
any idea ?

Thanks and mary xmas
Peter

slowmaker

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 51
    • View Profile
    • Donate to Member
Re: How to run a script after every win-unlock ???
« Reply #1 on: January 11, 2010, 01:15 AM »
Do you mean session unlocks, as in fast user switching (winkey+L) out, then logging back in?

If so, your script's caller needs to do some request notifications of session state changes and process them.

The only way I know to do that is win api coding:

    1) call WTSRegisterSessionNotification()
    2) catch #WM_WTSSESSION_CHANGE message and check for #WTS_SESSION_UNLOCK flag
                    * if WTS_SESSION_UNLOCK flag is detected, the script should be called
    3) call WTSUnRegisterSessionNotification() before it exits


jpprater

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: How to run a script after every win-unlock ???
« Reply #2 on: January 11, 2010, 05:31 AM »
You can do it in AutoHotkey.
Read this thread from the autohotkey forum.  It tells you how and provides a helpful library.
I know this works because I used it recently in a project at work.

Jon

slowmaker

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 51
    • View Profile
    • Donate to Member
Re: How to run a script after every win-unlock ???
« Reply #3 on: January 11, 2010, 09:37 AM »
hhbuesch, this gave me an idea I started coding, not script specific, just:

run_on_unlock.exe <whatever command line you want here>

and then whenever the user comes back in from a session lock, the system will run <whatever command line you want here> verbatim, as if you'd typed it in a console session.

I don't want to step on the toes of whatever project prompted your question. Do you mind if I post a program like that elsewhere on the board?

slowmaker

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 51
    • View Profile
    • Donate to Member
Re: How to run a script after every win-unlock ???
« Reply #4 on: January 16, 2010, 03:47 PM »
For those who are interested, I went ahead with this, over here.

The source is included in the archive.