开发者

MS Access / VBA, check for desktop lock

开发者 https://www.devze.com 2023-03-13 04:13 出处:网络
Basically, what I\'m trying to find is a way for MS Access (2003) to detect if the user has done a Ctrl+Alt+Del and locked their workstation. If that happens, I want the open database to shut down. Cu

Basically, what I'm trying to find is a way for MS Access (2003) to detect if the user has done a Ctrl+Alt+Del and locked their workstation. If that happens, I want the open database to shut down. Currently, I have a hidden form t开发者_开发问答hat runs in the background that checks for inactivity, but it's unreliable.

Is there a way to do this in VBA, or should I do this another way (or both)?

Thanks!


You're not going to find a reliable way to do that from within Access.

  1. Ctrl/Alt/Del doesn't actually lock the computer, it brings up the Login dialog, so you'd need a secondary detection to see what option the user selects in that dialog.
  2. What if the user presses Win + L instead of Ctrl/Alt/Del?
  3. In Win7 (and Vista?) the user can Lock the computer from the Start menu - typically a mouse action, not keyboard.
  4. If Access isn't the application that has focus at the time the keys are pressed, it has no visibility of the action.

You might want to pursue more "reliable" methods of detecting idle time within the app itself. What is your current approach? Are you stuck with 2003, or could you possibly update to 2007/2010?

Maybe these?

http://www.tek-tips.com/viewthread.cfm?qid=933476

How to get the idle time in Windows XP using VBA?

Those are still timer-based, not looking at login state. The tek-tips code is VB, which may be adaptable for VBA, or may not. The SO link is VBA, and looks pretty similar, so there's potential.


To check for Locked System in Win 7 , you need to have an little trick. I have a code which when clicked , it will lock a system ( and records that time ). Then it will pause for 5 seconds (application.wait time method) which a user will not see as the system is locked. Then put a message box in code. When user will be back, he will see a message box popup which says "Is your break finished" . Put code for popup button to record time when Ok/Cancle button is clicked. In this way you are capturing both times - 1.when system is locked and when it is unlocked.

Please let me know if you have any issues. riyajshaikh7@gmail.com

0

精彩评论

暂无评论...
验证码 换一张
取 消