eagle4life69 Posted October 31, 2017 Share Posted October 31, 2017 (edited) So I am looking to write something that would detect if a laptop is docked or not. I am thinking the simple way is to detect if a certain nic card is present since all of my docks have the same hardware device type for the nic. What I need help with is how to make this work to read when the laptop is docked and undocked. and how to make the program run without eating memory I found sleeping isn't effective but maybe that's me thanks for the help UPDATE 1: Maybe looking at the key will work better for docking. But how to make it know when the state changes from a 1 to a 2? HKLM\SYSTEM\CurrentControlSet\Control\IDConfigDB\CurrentDockInfo\DockingState Edited October 31, 2017 by eagle4life69 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 31, 2017 Moderators Share Posted October 31, 2017 @eagle4life69 Dog ate your help file? Look at RegRead in the help file. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
eagle4life69 Posted October 31, 2017 Author Share Posted October 31, 2017 (edited) 3 minutes ago, JLogan3o13 said: @eagle4life69 Dog ate your help file? Look at RegRead in the help file. I understand how to read the registry but how do I loop it over and over again? so about 1000 checks a minute? at some point would I not just eat memory? I'm looking for better programming than just doing a while loop with a sleep(50) Edited October 31, 2017 by eagle4life69 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 31, 2017 Moderators Share Posted October 31, 2017 Maybe a While Loop? While RegRead(<KeyName>, <ValueName>) = "Value" Sleep(100) WEnd MsgBox(0, "", "Value Changed!") "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
eagle4life69 Posted October 31, 2017 Author Share Posted October 31, 2017 6 minutes ago, JLogan3o13 said: Maybe a While Loop? While RegRead(<KeyName>, <ValueName>) = "Value" Sleep(100) WEnd MsgBox(0, "", "Value Changed!") I will try that my concern is if it runs 24/7 how much memory would it eat thanks for the help Link to comment Share on other sites More sharing options...
TheDcoder Posted October 31, 2017 Share Posted October 31, 2017 It shouldn't eat memory, it would reuse a limited amount. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
eagle4life69 Posted November 3, 2017 Author Share Posted November 3, 2017 On 10/31/2017 at 0:01 AM, TheDcoder said: It shouldn't eat memory, it would reuse a limited amount. OK I will run some tests I appreciate the comments Link to comment Share on other sites More sharing options...
ScottQ Posted March 6, 2021 Share Posted March 6, 2021 (edited) On 10/31/2017 at 9:31 AM, eagle4life69 said: Maybe looking at the key will work better for docking. But how to make it know when the state changes from a 1 to a 2? HKLM\SYSTEM\CurrentControlSet\Control\IDConfigDB\CurrentDockInfo\DockingState I am assuming this only works if your laptop dock is the type that has an eject button because it does not work for the docking station I have for the Thinkpad T510. I do not consider this to be a port replicator but may Windows OS does . The dock station I have for T510 has a key lock; power button; no eject button; uses the connector located in the middle underside of laptop; and has various ports. It is a Thinkpad branded docking station and everything else works fine when laptop is docked. I set "DockingState" value manually to "4" and rebooted while docked. "DockingState" updated to "1". Windows 7 start menu had no undock option so I assume this is not considered docking station by Windows. I could count the number of USB ports as an indicator of docked state but that is not a generic solution if I want code that work for many brands of laptop / dock stations. Any ideas what to check to detect the docked state for this category of docking stations (ie those with no eject button)? Edited March 7, 2021 by ScottQ revised info Link to comment Share on other sites More sharing options...
ScottQ Posted March 7, 2021 Share Posted March 7, 2021 (edited) [please ignore ] Edited March 7, 2021 by ScottQ added to prev comment as just got edit button - mods could you please delete this empty comment for me Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now