Looking for guidance on locating hook in Win7 to determine if monitor is connected or disconnectedDetermine if device is connected/disconnected to RS232 port without opening the portI need a event to detect Internet connect/disconnectWhat's the best way to determine the location of the current PowerShell script?Win32 determining when keyboard is connected/disconnectedTrigger an exe once My device is connected via USBHow to control a Bluetooth LE connection on Windows 10?Azure IoT Hub Operations MonitoringSystemEvents.DisplaySettingsChanged not getting HDMI Arrival/Removal event?How to detect a network was broken down with ZeroMQ monitor mechanism?check if monitor cable is connected?
Formal mathematical definition of renormalization group flow
foot-pounds of energy?
A verb for when some rights are not violated?
Conditional probability of dependent random variables
Is there a way to say "double + any number" in German?
Why do dragons like shiny stuff?
How to increase Solr JVM memory
How easy is it to get a gun illegally in the United States?
C# TCP server/client class
How do I know when and if a character requires a backstory?
Can attackers change the public key of certificate during the SSL handshake
A Checkmate of Dubious Legality
Why are there yellow dot stickers on the front doors of businesses in Russia?
How do I handle a DM that plays favorites with certain players?
Is an "are" omitted in this sentence
Write The Shortest Program To Check If A Binary Tree Is Balanced
…down the primrose path
Why does capacitance not depend on the material of the plates?
Awk to get all my regular users in shadow
Need reasons why a satellite network would not work
What printing process is this?
Is it okay to use different fingers every time while playing a song on keyboard? Is it considered a bad practice?
How to design an effective polearm-bow hybrid?
Getting an entry level IT position later in life
Looking for guidance on locating hook in Win7 to determine if monitor is connected or disconnected
Determine if device is connected/disconnected to RS232 port without opening the portI need a event to detect Internet connect/disconnectWhat's the best way to determine the location of the current PowerShell script?Win32 determining when keyboard is connected/disconnectedTrigger an exe once My device is connected via USBHow to control a Bluetooth LE connection on Windows 10?Azure IoT Hub Operations MonitoringSystemEvents.DisplaySettingsChanged not getting HDMI Arrival/Removal event?How to detect a network was broken down with ZeroMQ monitor mechanism?check if monitor cable is connected?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Have a large amount of Win7 video devices distributed among several different locations in a healthcare setting. Sometimes the need is dire and they be used in a moments notice. Each device connects via HDMI to a wall mounted TV.
One pain point is that sometimes people will disconnect the HDMI cable from the Win7 computer to plug into their own personal devices which violates policy. They will not reconnect the cable which causes problems when the device needs to be used next. It has caused delays in care.
The past week i've been working to write a small app (preferably a service at system level) that will detect when display is no longer connected to PC then trigger action (e.g. EventLog entry, send email alert, etc). Unfortunately all my attempts have been met with roadblocks. Looking for ideas.
I've spent quite a bit of time researching ways or "hooks" that I might be able to surface within Windows that I can trigger off of. I found that there are native classes (DeviceWatcher, WindowsDeviceEnumeration, etc) that might help this work, but unfortunately they're not Win7 compatible.
I did create a c# console app with event handler for SystemEvents.DisplaySettingsChanging and this works just how I would like! I can disconnect the monitor and it will send an alert email and write an event log entry (which we can monitor with 3rd party tools and alert, create ticket, etc). While this console app works great, I need it to work more as a hidden background service. I created a Windows Service with the same functionality, but I found that event handlers can be tricky in Windows Services. I could never get the EventHandler(SystemEvents_DisplaySettingsChanging) to trigger when in Windows Service Mode. I've since found that EventHandler DisplaySettingsChanged is a user level event and will only work for current user and not system level when run as a service.
I've tested various methods of unplugging monitor and looking for ways for windows to report "No Monitor). I've tried WIn32_PnPEntity Class as well as Win32_Video* classes and they will all report that monitor is OK status even though it isn't connected.
I did find that I can literally watch device manager while disconnecting a monitor and see the monitor disappear from Monitors tab. There has to be some way I can hook into this.
I'm thinking I can run a windows service with a timer that will check this hook. If monitor connected, do nothing - if NOT connected, do action (send alert, write event log entry, create ticket, etc.)
Ultimately I expect to have a Windows Service with timer that will run in system mode which basically re-runs a check like this this:
If monitor connected, do nothing.
If no monitor connected, send alert, create ticket, create eventlog entry, etc..
I've spend a good chunk of time on this and I have to present findings 3/28.
Any help appreciated. Thanks!
c# powershell winapi monitoring
add a comment |
Have a large amount of Win7 video devices distributed among several different locations in a healthcare setting. Sometimes the need is dire and they be used in a moments notice. Each device connects via HDMI to a wall mounted TV.
One pain point is that sometimes people will disconnect the HDMI cable from the Win7 computer to plug into their own personal devices which violates policy. They will not reconnect the cable which causes problems when the device needs to be used next. It has caused delays in care.
The past week i've been working to write a small app (preferably a service at system level) that will detect when display is no longer connected to PC then trigger action (e.g. EventLog entry, send email alert, etc). Unfortunately all my attempts have been met with roadblocks. Looking for ideas.
I've spent quite a bit of time researching ways or "hooks" that I might be able to surface within Windows that I can trigger off of. I found that there are native classes (DeviceWatcher, WindowsDeviceEnumeration, etc) that might help this work, but unfortunately they're not Win7 compatible.
I did create a c# console app with event handler for SystemEvents.DisplaySettingsChanging and this works just how I would like! I can disconnect the monitor and it will send an alert email and write an event log entry (which we can monitor with 3rd party tools and alert, create ticket, etc). While this console app works great, I need it to work more as a hidden background service. I created a Windows Service with the same functionality, but I found that event handlers can be tricky in Windows Services. I could never get the EventHandler(SystemEvents_DisplaySettingsChanging) to trigger when in Windows Service Mode. I've since found that EventHandler DisplaySettingsChanged is a user level event and will only work for current user and not system level when run as a service.
I've tested various methods of unplugging monitor and looking for ways for windows to report "No Monitor). I've tried WIn32_PnPEntity Class as well as Win32_Video* classes and they will all report that monitor is OK status even though it isn't connected.
I did find that I can literally watch device manager while disconnecting a monitor and see the monitor disappear from Monitors tab. There has to be some way I can hook into this.
I'm thinking I can run a windows service with a timer that will check this hook. If monitor connected, do nothing - if NOT connected, do action (send alert, write event log entry, create ticket, etc.)
Ultimately I expect to have a Windows Service with timer that will run in system mode which basically re-runs a check like this this:
If monitor connected, do nothing.
If no monitor connected, send alert, create ticket, create eventlog entry, etc..
I've spend a good chunk of time on this and I have to present findings 3/28.
Any help appreciated. Thanks!
c# powershell winapi monitoring
A quick search on wm_devicechange hdmi in a search engine turned up some promising looking results.
– Ken White
Mar 27 at 2:51
add a comment |
Have a large amount of Win7 video devices distributed among several different locations in a healthcare setting. Sometimes the need is dire and they be used in a moments notice. Each device connects via HDMI to a wall mounted TV.
One pain point is that sometimes people will disconnect the HDMI cable from the Win7 computer to plug into their own personal devices which violates policy. They will not reconnect the cable which causes problems when the device needs to be used next. It has caused delays in care.
The past week i've been working to write a small app (preferably a service at system level) that will detect when display is no longer connected to PC then trigger action (e.g. EventLog entry, send email alert, etc). Unfortunately all my attempts have been met with roadblocks. Looking for ideas.
I've spent quite a bit of time researching ways or "hooks" that I might be able to surface within Windows that I can trigger off of. I found that there are native classes (DeviceWatcher, WindowsDeviceEnumeration, etc) that might help this work, but unfortunately they're not Win7 compatible.
I did create a c# console app with event handler for SystemEvents.DisplaySettingsChanging and this works just how I would like! I can disconnect the monitor and it will send an alert email and write an event log entry (which we can monitor with 3rd party tools and alert, create ticket, etc). While this console app works great, I need it to work more as a hidden background service. I created a Windows Service with the same functionality, but I found that event handlers can be tricky in Windows Services. I could never get the EventHandler(SystemEvents_DisplaySettingsChanging) to trigger when in Windows Service Mode. I've since found that EventHandler DisplaySettingsChanged is a user level event and will only work for current user and not system level when run as a service.
I've tested various methods of unplugging monitor and looking for ways for windows to report "No Monitor). I've tried WIn32_PnPEntity Class as well as Win32_Video* classes and they will all report that monitor is OK status even though it isn't connected.
I did find that I can literally watch device manager while disconnecting a monitor and see the monitor disappear from Monitors tab. There has to be some way I can hook into this.
I'm thinking I can run a windows service with a timer that will check this hook. If monitor connected, do nothing - if NOT connected, do action (send alert, write event log entry, create ticket, etc.)
Ultimately I expect to have a Windows Service with timer that will run in system mode which basically re-runs a check like this this:
If monitor connected, do nothing.
If no monitor connected, send alert, create ticket, create eventlog entry, etc..
I've spend a good chunk of time on this and I have to present findings 3/28.
Any help appreciated. Thanks!
c# powershell winapi monitoring
Have a large amount of Win7 video devices distributed among several different locations in a healthcare setting. Sometimes the need is dire and they be used in a moments notice. Each device connects via HDMI to a wall mounted TV.
One pain point is that sometimes people will disconnect the HDMI cable from the Win7 computer to plug into their own personal devices which violates policy. They will not reconnect the cable which causes problems when the device needs to be used next. It has caused delays in care.
The past week i've been working to write a small app (preferably a service at system level) that will detect when display is no longer connected to PC then trigger action (e.g. EventLog entry, send email alert, etc). Unfortunately all my attempts have been met with roadblocks. Looking for ideas.
I've spent quite a bit of time researching ways or "hooks" that I might be able to surface within Windows that I can trigger off of. I found that there are native classes (DeviceWatcher, WindowsDeviceEnumeration, etc) that might help this work, but unfortunately they're not Win7 compatible.
I did create a c# console app with event handler for SystemEvents.DisplaySettingsChanging and this works just how I would like! I can disconnect the monitor and it will send an alert email and write an event log entry (which we can monitor with 3rd party tools and alert, create ticket, etc). While this console app works great, I need it to work more as a hidden background service. I created a Windows Service with the same functionality, but I found that event handlers can be tricky in Windows Services. I could never get the EventHandler(SystemEvents_DisplaySettingsChanging) to trigger when in Windows Service Mode. I've since found that EventHandler DisplaySettingsChanged is a user level event and will only work for current user and not system level when run as a service.
I've tested various methods of unplugging monitor and looking for ways for windows to report "No Monitor). I've tried WIn32_PnPEntity Class as well as Win32_Video* classes and they will all report that monitor is OK status even though it isn't connected.
I did find that I can literally watch device manager while disconnecting a monitor and see the monitor disappear from Monitors tab. There has to be some way I can hook into this.
I'm thinking I can run a windows service with a timer that will check this hook. If monitor connected, do nothing - if NOT connected, do action (send alert, write event log entry, create ticket, etc.)
Ultimately I expect to have a Windows Service with timer that will run in system mode which basically re-runs a check like this this:
If monitor connected, do nothing.
If no monitor connected, send alert, create ticket, create eventlog entry, etc..
I've spend a good chunk of time on this and I have to present findings 3/28.
Any help appreciated. Thanks!
c# powershell winapi monitoring
c# powershell winapi monitoring
asked Mar 27 at 2:46
bigjimcfhbigjimcfh
191 silver badge3 bronze badges
191 silver badge3 bronze badges
A quick search on wm_devicechange hdmi in a search engine turned up some promising looking results.
– Ken White
Mar 27 at 2:51
add a comment |
A quick search on wm_devicechange hdmi in a search engine turned up some promising looking results.
– Ken White
Mar 27 at 2:51
A quick search on wm_devicechange hdmi in a search engine turned up some promising looking results.
– Ken White
Mar 27 at 2:51
A quick search on wm_devicechange hdmi in a search engine turned up some promising looking results.
– Ken White
Mar 27 at 2:51
add a comment |
1 Answer
1
active
oldest
votes
I explored WM_DEVICECHANGE and WM_DISPLAYCHANGE but I just couldn't get either to work as I needed and I was running out of time.
I need more time to figure these out (and capturing windows messages in general) in the future.
However, I was finally able to find the right hook to achieve my objective.
The challenge I was having was that no matter what class or assembly I used to detect monitor connection, I was always returning at least one display even though it was physically disconnected.
Tinkering in PowerShell, I found that using WMI and Win32_PnPEntity, I could pull the display info and if NO displays were connected, the DeviceID would always return DisplayNVD0000SomeGuid. When 1 or 2 monitors were connected the DeviceID's would be a hex variation replacing the zeros after NVD (ex. DisplayNVD39E4someGUID).
Knowing I could count on getting a deviceID of DisplayNVD0000 when no monitor was connected I build a windows service, with a timer using ManagementObjectSearcher and Win32_PnPEntity. Timer runs every 10 minutes then executes a check.
If finds no display physically connected, it will fire an event log entry which can be monitored with an external monitoring tool (Xymon, Nagios, etc) and an alert/action can be taken to ensure it gets corrected.
I tested with an HDMI monitor. Tested with monitor in powered off condition and with monitor source changed to another input condition (Not HDMI) and the only condition where I could get the alert to trigger was when cable was physically disconnected from PC, which is exactly what I wanted.
Theres more than one way to skin a cat. I know there are other devs out there that could've whipped together an elaborate working solution in a matter of a minutes. Considering the amount of cumulative screentime in C# over my career (not a lot, comparatively), I feel good about this small victory.
Hopefully this might help someone in the future.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55369041%2flooking-for-guidance-on-locating-hook-in-win7-to-determine-if-monitor-is-connect%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I explored WM_DEVICECHANGE and WM_DISPLAYCHANGE but I just couldn't get either to work as I needed and I was running out of time.
I need more time to figure these out (and capturing windows messages in general) in the future.
However, I was finally able to find the right hook to achieve my objective.
The challenge I was having was that no matter what class or assembly I used to detect monitor connection, I was always returning at least one display even though it was physically disconnected.
Tinkering in PowerShell, I found that using WMI and Win32_PnPEntity, I could pull the display info and if NO displays were connected, the DeviceID would always return DisplayNVD0000SomeGuid. When 1 or 2 monitors were connected the DeviceID's would be a hex variation replacing the zeros after NVD (ex. DisplayNVD39E4someGUID).
Knowing I could count on getting a deviceID of DisplayNVD0000 when no monitor was connected I build a windows service, with a timer using ManagementObjectSearcher and Win32_PnPEntity. Timer runs every 10 minutes then executes a check.
If finds no display physically connected, it will fire an event log entry which can be monitored with an external monitoring tool (Xymon, Nagios, etc) and an alert/action can be taken to ensure it gets corrected.
I tested with an HDMI monitor. Tested with monitor in powered off condition and with monitor source changed to another input condition (Not HDMI) and the only condition where I could get the alert to trigger was when cable was physically disconnected from PC, which is exactly what I wanted.
Theres more than one way to skin a cat. I know there are other devs out there that could've whipped together an elaborate working solution in a matter of a minutes. Considering the amount of cumulative screentime in C# over my career (not a lot, comparatively), I feel good about this small victory.
Hopefully this might help someone in the future.
add a comment |
I explored WM_DEVICECHANGE and WM_DISPLAYCHANGE but I just couldn't get either to work as I needed and I was running out of time.
I need more time to figure these out (and capturing windows messages in general) in the future.
However, I was finally able to find the right hook to achieve my objective.
The challenge I was having was that no matter what class or assembly I used to detect monitor connection, I was always returning at least one display even though it was physically disconnected.
Tinkering in PowerShell, I found that using WMI and Win32_PnPEntity, I could pull the display info and if NO displays were connected, the DeviceID would always return DisplayNVD0000SomeGuid. When 1 or 2 monitors were connected the DeviceID's would be a hex variation replacing the zeros after NVD (ex. DisplayNVD39E4someGUID).
Knowing I could count on getting a deviceID of DisplayNVD0000 when no monitor was connected I build a windows service, with a timer using ManagementObjectSearcher and Win32_PnPEntity. Timer runs every 10 minutes then executes a check.
If finds no display physically connected, it will fire an event log entry which can be monitored with an external monitoring tool (Xymon, Nagios, etc) and an alert/action can be taken to ensure it gets corrected.
I tested with an HDMI monitor. Tested with monitor in powered off condition and with monitor source changed to another input condition (Not HDMI) and the only condition where I could get the alert to trigger was when cable was physically disconnected from PC, which is exactly what I wanted.
Theres more than one way to skin a cat. I know there are other devs out there that could've whipped together an elaborate working solution in a matter of a minutes. Considering the amount of cumulative screentime in C# over my career (not a lot, comparatively), I feel good about this small victory.
Hopefully this might help someone in the future.
add a comment |
I explored WM_DEVICECHANGE and WM_DISPLAYCHANGE but I just couldn't get either to work as I needed and I was running out of time.
I need more time to figure these out (and capturing windows messages in general) in the future.
However, I was finally able to find the right hook to achieve my objective.
The challenge I was having was that no matter what class or assembly I used to detect monitor connection, I was always returning at least one display even though it was physically disconnected.
Tinkering in PowerShell, I found that using WMI and Win32_PnPEntity, I could pull the display info and if NO displays were connected, the DeviceID would always return DisplayNVD0000SomeGuid. When 1 or 2 monitors were connected the DeviceID's would be a hex variation replacing the zeros after NVD (ex. DisplayNVD39E4someGUID).
Knowing I could count on getting a deviceID of DisplayNVD0000 when no monitor was connected I build a windows service, with a timer using ManagementObjectSearcher and Win32_PnPEntity. Timer runs every 10 minutes then executes a check.
If finds no display physically connected, it will fire an event log entry which can be monitored with an external monitoring tool (Xymon, Nagios, etc) and an alert/action can be taken to ensure it gets corrected.
I tested with an HDMI monitor. Tested with monitor in powered off condition and with monitor source changed to another input condition (Not HDMI) and the only condition where I could get the alert to trigger was when cable was physically disconnected from PC, which is exactly what I wanted.
Theres more than one way to skin a cat. I know there are other devs out there that could've whipped together an elaborate working solution in a matter of a minutes. Considering the amount of cumulative screentime in C# over my career (not a lot, comparatively), I feel good about this small victory.
Hopefully this might help someone in the future.
I explored WM_DEVICECHANGE and WM_DISPLAYCHANGE but I just couldn't get either to work as I needed and I was running out of time.
I need more time to figure these out (and capturing windows messages in general) in the future.
However, I was finally able to find the right hook to achieve my objective.
The challenge I was having was that no matter what class or assembly I used to detect monitor connection, I was always returning at least one display even though it was physically disconnected.
Tinkering in PowerShell, I found that using WMI and Win32_PnPEntity, I could pull the display info and if NO displays were connected, the DeviceID would always return DisplayNVD0000SomeGuid. When 1 or 2 monitors were connected the DeviceID's would be a hex variation replacing the zeros after NVD (ex. DisplayNVD39E4someGUID).
Knowing I could count on getting a deviceID of DisplayNVD0000 when no monitor was connected I build a windows service, with a timer using ManagementObjectSearcher and Win32_PnPEntity. Timer runs every 10 minutes then executes a check.
If finds no display physically connected, it will fire an event log entry which can be monitored with an external monitoring tool (Xymon, Nagios, etc) and an alert/action can be taken to ensure it gets corrected.
I tested with an HDMI monitor. Tested with monitor in powered off condition and with monitor source changed to another input condition (Not HDMI) and the only condition where I could get the alert to trigger was when cable was physically disconnected from PC, which is exactly what I wanted.
Theres more than one way to skin a cat. I know there are other devs out there that could've whipped together an elaborate working solution in a matter of a minutes. Considering the amount of cumulative screentime in C# over my career (not a lot, comparatively), I feel good about this small victory.
Hopefully this might help someone in the future.
answered Mar 28 at 4:39
bigjimcfhbigjimcfh
191 silver badge3 bronze badges
191 silver badge3 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55369041%2flooking-for-guidance-on-locating-hook-in-win7-to-determine-if-monitor-is-connect%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
A quick search on wm_devicechange hdmi in a search engine turned up some promising looking results.
– Ken White
Mar 27 at 2:51