[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

catch Lockdown & Idle on events on XP pro/home station

Posted on 2007-10-07
9
Medium Priority
?
310 Views
Last Modified: 2013-12-04
Hi all
I would like to catch the following XP pro/home events:
Enter and exit idle mode (peripherals don't get input for few minutes)
Station lockdown and entrance (winkey + L or alt+ctrl+del -> lock computer)

I would like to run script/ batch / application on these events.
Please advice,
Sharon
0
Comment
Question by:sharon669
  • 5
  • 4
9 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 1500 total points
ID: 20104630
I don't believe there are events for those, rather you'll have to determine them for yourself.

for example, lock status:

// ///////////////////////////////////////////////////////
// /////////////////////////////////////////////////////// GetLogonDesktopState
// ////////////////////////////////////////////////////////////////////////////
void GetLogonDesktopState()
{
LogonDesktopState=0;

IntPtr DeskTopHandle=(IntPtr)null;
try {
    DeskTopHandle=OpenDesktop("Winlogon",0,true,(long)0x41); // 41=enum & read
    }
catch (Exception e)
      {
      PutMsg("WinLogon open excp <"+e.ToString()+">");
      return;
      }
if (DeskTopHandle==IntPtr.Zero)
   {
   PutMsg("Unable to open Winlogon ("+GetLastError().ToString()+")");
   return;
   }
EnumDesktopWindows(DeskTopHandle,new EnumWinProc(EnumLogonWindows),0);
CloseDesktop(DeskTopHandle);
return;
}

// ///////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////// EnumLogonWindows
// ////////////////////////////////////////////////////////////////////////////
bool EnumLogonWindows(int hwnd,int lParam)
{
windowHandle=(IntPtr)hwnd;

StringBuilder sb=new StringBuilder(1024);
GetWindowText((int)windowHandle,sb,sb.Capacity);
if (sb.Length>0)
   {
   if (sb.ToString()=="Windows Security") {LogonDesktopState=1; return false;}
   if (sb.ToString()=="Computer Locked")  {LogonDesktopState=2; return false;}
   if (sb.ToString()=="Unlock Computer")  {LogonDesktopState=3; return false;}
   }
return true;
}

statuses:
1 - they hit ctrl-alt-del and are at the screen asking them what to do
2 - box locked
3 - they're being asked for their password to unlock





Determine the time of the last user action (key stroke or mouse movement):
call GetLastInputInfo():
http://msdn2.microsoft.com/en-us/library/ms646302.aspx


Disk activity is a little more problematic.  You have constantly gather info on disk I/O so you can determine what constitutes 'idleness' for a specific box.

disk i/o info gathering:

mgmtScope = new ManagementScope("root\\cimv2");
mgmtScope.Connect();
mPath_Disk              = new ManagementPath();
mPath_Disk.RelativePath ="Win32_PerfRawData_PerfDisk_PhysicalDisk.Name='_total'";
mObject_Disk            =new ManagementObject(mgmtScope,mPath_Disk,null);
DiskCtr2=(UInt32)mObject_Disk.Properties["DiskTransfersPersec"].Value;
mObject_Disk.Dispose();


0
 
LVL 1

Author Comment

by:sharon669
ID: 20117662
Thank you for this post cookre,
This method of identifying lockdown is a little bit problematic,
What if the "Windows Security" String is different on pro/home stations?

Say you can get "lock down' event by the lock window title,
How do you catch the "unlock event"?

Any how this logic will require constant checking/querying the system which will load the station.
0
 
LVL 22

Expert Comment

by:cookre
ID: 20118036
Those are the titles for XP Pro.  I've never been in front of a Home box, so you'll have to verify them yourself.

1) If someone is logged on and active, window's station "WinSta0" / desktop "Winlogon" won't have any of those three windows.  

2) When they do CtrlAltDel, window "Windows Security" is created and they're presented with options.

3) If they select Lock Workstation, "Windows Security" goes away and window "Computer Locked" is created.

4) The next mouse or keyboard activity causes "Computer Locked" to go away, and "Unlock Computer" is created.


Since MSGINA.dll is also in Home, I presume these states obtain there also.

5) After entering their password, state 1) resumes.

 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:cookre
ID: 20118042
Oops.

The line about GINA should have been at the end.
0
 
LVL 1

Author Comment

by:sharon669
ID: 20146169
Thank you
With your solution I will have to run these test every few seconds, it will load my client's computer, ant want be accurate (depend on the sample rate).
I am looking for OS API solution, win32 method call, or Hook, so I can implement it later on XP home / 2000
0
 
LVL 22

Expert Comment

by:cookre
ID: 20149540
Do the GetLastInputInfo() first.  That way, if they're typing or mousing, you don't have to do any of the other checks.
0
 
LVL 1

Author Comment

by:sharon669
ID: 20215958
But I looking better win oriented solution,

So topic still open
If anyone have idea on how to achieve the station status functionality please advise;

0
 
LVL 1

Author Comment

by:sharon669
ID: 20712615
found solution
using GINA
see :
http://www.pcreview.co.uk/forums/thread-1312927.php
0
 
LVL 1

Author Closing Comment

by:sharon669
ID: 31408059
Thank you for you time
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question