It is all self contained. so anything it needs as far as setting variables it will make. I put in some error handling as well.. for things like if you are in an RDP session and restart EG. it has no way of knowing what the original state of the switch was or if you are in an RDP session. so it will spit out a notice in the log telling you to toggle the wall switch and possibly restart the RDP session. but it will always default to leaving the screen on. and a simple toggle of the wall switch will fix this if it happens to be backwards. This can also happen if you have the switch off and you have to reboot the computer. the screen will default to on as well. and will require a toggle of the switch to get it back in sync. I do not know if there is a way to check the state of the switch. if there is via something like HTTP this can be added as well. then there would be no need to sync anything.
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4" Guid="{5EE4F107-2AA3-4802-8DB8-604BD73F8D36}" Time="1501852367.14">
<Folder Name="Display Blackout" XML_Guid="{5EF73764-95C1-4FC6-A23A-C897E479651D}" Expanded="True">
<Macro Name="Display Blackout Off" XML_Guid="{512BEA4F-6AE7-442C-A35A-A73CBC3F08B1}" Expanded="True">
<Event Name="HTTP.ST.DummySwitch.switch.on" XML_Guid="{10A19873-FA79-40F4-8395-F3DA4712BEA5}" />
<Action Name="Blackout Off" XML_Guid="{9A62027A-8840-4099-B6A7-B57F005E4B54}">
EventGhost.PythonScript(u"if not hasattr(eg.globals, 'display_blackout'):\n eg.globals.display_blackout = None\n \nif not hasattr(eg.globals, 'rdp_state'):\n eg.globals.rdp_state = None\n \nif eg.globals.rdp_state is None:\n eg.PrintNotice(\n 'Display Syncing Error:\\n'\n 'Please logoff RDP session if one is active.\\n'\n 'Please toggle wall switch to resync.'\n \n )\n eg.globals.rdp_state = False\n\neg.globals.display_blackout = False\ndisplay = eg.DesktopDisplay.GetDisplay(0)\n\nif not eg.globals.rdp_state and display.blackout:\n display.blackout = False\n\n")
</Action>
</Macro>
<Macro Name="Display Blackout On" XML_Guid="{5D90EB1B-DA40-4E3A-8C29-BA74324B1B5A}" Expanded="True">
<Event Name="HTTP.ST.DummySwitch.switch.off" XML_Guid="{AF66EEE0-592A-4CCC-8B36-DFA09ADECC8F}" />
<Action Name="Blackout On" XML_Guid="{162BD3AF-1E95-4D7C-AB71-743EA7CA2AB4}">
EventGhost.PythonScript(u"if not hasattr(eg.globals, 'display_blackout'):\n eg.globals.display_blackout = None\n \nif not hasattr(eg.globals, 'rdp_state'):\n eg.globals.rdp_state = None\n \nif eg.globals.rdp_state is None:\n eg.PrintNotice(\n 'Display Syncing Error:\\n'\n 'Please logoff RDP session if one is active.\\n'\n 'Please toggle wall switch to resync.'\n \n )\n eg.globals.rdp_state = False\n \neg.globals.display_blackout = True\ndisplay = eg.DesktopDisplay.GetDisplay(0)\n\nif not eg.globals.rdp_state and not display.blackout:\n display.blackout = True\n\n")
</Action>
</Macro>
<Macro Name="RDP Session Connect" XML_Guid="{7D2B0529-7E0C-47D6-B17E-9EFD05896858}">
<Event Name="System.RemoteConnect" XML_Guid="{4B73EA84-178D-4EC4-A039-1458B257F3C4}" />
<Action Name="RDP Connect Set Blackout" XML_Guid="{8DAEB60F-8E10-4ECD-8BF4-D14EFE71BA98}">
EventGhost.PythonScript(u"if not hasattr(eg.globals, 'display_blackout'):\n eg.globals.display_blackout = False\n \nif not hasattr(eg.globals, 'rdp_state'):\n eg.globals.rdp_state = None\n\nif eg.globals.rdp_state is None:\n eg.PrintNotice(\n 'Display Syncing Error:\\n'\n 'Please Toggle Wall Switch to resync.'\n )\n \neg.globals.rdp_state = True\ndisplay = eg.DesktopDisplay.GetDisplay(0)\neg.globals.display_blackout = display.blackout\n\nif display.blackout:\n display.blackout = False\n ")
</Action>
</Macro>
<Macro Name="RDP Session Disconnect" XML_Guid="{C92A4B69-3075-4DDE-B633-C49C3ED2AFAA}">
<Event Name="System.RemoteDisconnect" XML_Guid="{189402CC-958B-4AE8-951C-07A764B921A2}" />
<Action Name="RDP Disconnect Set Blackout" XML_Guid="{10EA3251-2765-41B1-A080-47DA3E7B770D}">
EventGhost.PythonScript(u"if not hasattr(eg.globals, 'display_blackout'):\n eg.globals.display_blackout = False\n \nif not hasattr(eg.globals, 'rdp_state'):\n eg.globals.rdp_state = None\n\nif eg.globals.rdp_state is None:\n eg.PrintNotice(\n 'Display Syncing Error:\\n'\n 'Please Toggle Wall Switch to resync.'\n )\n \neg.globals.rdp_state = False\ndisplay = eg.DesktopDisplay.GetDisplay(0)\n\nif eg.globals.display_blackout:\n display.blackout = True\n\neg.globals.display_blackout = display.blackout")
</Action>
</Macro>
</Folder>
</EventGhost>
