0

I'd like to write an application which asks a question every time I unlock my pc. Please let me know how to deal with the start-the-app-when-I-unlock-my-pc part. Thanks.

Pavan Vamsi
  • 125
  • 1
  • 1
  • 6
  • You will probably need to hook into something that watches the system events. http://stackoverflow.com/questions/11385164/eventviewer-eventid-for-lock-and-unlock – Matthew Layton Jun 03 '13 at 09:46
  • Hookup to SessionSwitchEventHandler: http://stackoverflow.com/questions/44980/how-can-i-programmatically-determine-if-my-workstation-is-locked – L-Four Jun 03 '13 at 09:46

2 Answers2

0

It depends on the language you're using and the operating system. The operating system is most likely to fire events which your program can listen and do something when fired. - like asking a question from the user.

r1pp3rj4ck
  • 1,437
  • 2
  • 10
  • 23
  • I'll be writing an app for windows operating systems only. Mostly I'll be comfortable in writing the app in Java. Now, can u guide me? Or which environment would be perfect for such apps? – Pavan Vamsi Jun 03 '13 at 10:26
-1

with c#, you can try:

static void Main(string[] args) {
    SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
    Console.ReadLine();
}

static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e) {
    if (e.Reason == SessionSwitchReason.SessionLock) {
        Console.WriteLine("lock");
    } else if (e.Reason == SessionSwitchReason.SessionUnlock) {
        Console.WriteLine("Unlock");
    }
}
vegemite4me
  • 6,621
  • 5
  • 53
  • 79
user2412747
  • 111
  • 1