Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a laptop with windows 8.1, I often run it in public places where sometimes I leave it for a few minutes and I started to think would it be possible to log off and log on when I switch off and on my wireless mouse.

I'm using microsoft wireless mouse 4000 it connects to computer via nano adaptor. Laptop itself if it is relevant is Samsung Chronos 7.

Maybe it is not possible, I don't know, but I thought I will ask. I don't have much of such programming experience, but I'm web developer and do sometimes play with powershell (very novice still), so I was thinking maybe it is possible to somehow track when mouse connects to computer?

Thanks for replies!


Thank you all for helping out and pointing to possible flaws of such feature. Something to think about. But for now, the whole idea is to check whether it is possible, and if it is, how hard it would be to make it. More like DIY project if you like.

share|improve this question
I am not sure how to take the idea all the way, but if you want a list of USB devices that are connected, you can use Get-WmiObject Win32_USBControllerDevice – soandos Feb 26 '14 at 22:40
That's seems rather like Zero-Interaction Authentication PDF ACM. – Dan D. Feb 27 '14 at 4:52
up vote 2 down vote accepted

if you really want to use this, despite previous answers - use the task scheduler and get to know the event id for mouse connect/disconnect (the trigger), and use as action the logout (shutdown command) / login (I don't know how to log in a user from cmd line) of windows.


I found a utility that can log in a user from the command line, which would suit your needs:

Here is an article on USB device event ID's:

share|improve this answer
Thanks for you help, it seems like theoretically that's possible so I will mark your answer as the right one. Also very nice links, especially the one about USB device event ID's, looks very promising! – Giedrius Feb 27 '14 at 4:39

Sounds like an X - Y Problem. Just use win+l to lock the device when you're not using it. Simple enough. What you're trying to do sounds like a bad idea for a number of reasons the least of which is security, and the amount of time "saved" in comparison to the amount of time you'll spend trying to get this to work.

share|improve this answer
I see what you mean by that, but in this case I'm fully aware of simple shortcuts that are available to lock the PC. Yet the real problem is whether the idea that I have is possible, and could I make it with some internet folks advice. Its more like DIY project, which doesn't necessarily have to be the most optimum solution to the problem. I'm sorry if I failed to reflect that in my question though. – Giedrius Feb 27 '14 at 4:35
Just about anything is possible, whether or not it's a good idea is still relevant. – MDT Guy Feb 27 '14 at 21:19

Even if it is possible (with the help of some third party software) it would bring a lot of problems with it. What if the battery runs out on your Wireless Mouse ? What if your Wireless Mouse is malfunctioning or happens to loose temporary the connection with your Laptop ? Also (I don't know) but it might be that your mouse is saving energy by turning its self off when you are not using it for a specific amount of time. All this would lock your system, even though you do not want it.

I suggest every time you turn your back on your Laptop in the Public make sure to hit Win+L on your Windows 8.1 system.

share|improve this answer
It works exactly, like you said. Receiver sends usb packet when mouse is down, but mouse goes down every few seconds. The only way is monitor conection of receiver itself, but that lacks convenience. – week Feb 26 '14 at 22:50
And what if someone has the same type of mouse working on the same frequency? He'll easily be able to unlock his computer. – Spook Feb 27 '14 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .