{"id":960,"date":"2019-04-15T14:45:24","date_gmt":"2019-04-15T04:45:24","guid":{"rendered":"http:\/\/www.strangetimez.com\/Blog\/?page_id=960"},"modified":"2022-05-25T20:19:50","modified_gmt":"2022-05-25T10:49:50","slug":"monitor-power-off","status":"publish","type":"page","link":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/","title":{"rendered":"Monitor Power Off"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This is a very simple application that will allow you to turn off your  monitor(s) in Windows, rather than waiting for the set amount of time. <br \/><br \/><strong>How to use<\/strong>: When it starts, it will be minimised to the Task Bar (the icons next to the time). Double clicking on that icon will set the monitors to power off. Single clicking on the icon will bring up the small form, where you can click on the Turn Off button to do the same. Pressing <strong>CTRL+ALT+SHIFT+D<\/strong> will also power down your monitor. Closing the form will exit the application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Rather than posting the source code as a full project, below is the source code for MonitorPowerOff. You just need to add a Button to the main form, rename the form file to <code>frmMonitorOff<\/code> and paste this into the code behind the form. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tested in Windows 10 x64. <br \/>I am currently using <a rel=\"noreferrer noopener\" aria-label=\"Visual Studio 2017 Community Edition (opens in a new tab)\" href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\" target=\"_blank\">Visual Studio 2017 Community Edition<\/a>.<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong><a href=\"https:\/\/www.strangetimez.com\/Apps\/MonitorPowerOff\/MonitorPowerOff.exe\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Download MonitorPowerOff [FREE] (opens in a new tab)\">Download MonitorPowerOff [FREE]<\/a><\/strong><\/p>\n\n\n<p style=\"text-align: left;\"><a href=\"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_donations&amp;business=ZY9EW2SVJ84NU&amp;lc=AU&amp;item_name=Strangetimez&amp;item_number=LAWC&amp;currency_code=AUD&amp;bn=PP-DonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-590\" src=\"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2014\/06\/btn_donateCC_LG.gif\" alt=\"btn_donateCC_LG\" width=\"99\" height=\"47\"\/><\/a>Please support this app, and my time, by donating whatever $ you can spare.<\/p>\n<p><\/p>\n\n\n<pre class=\"wp-block-code\"><code>\nusing LAWC.Common;\nusing Microsoft.Win32;\nusing System;\nusing System.Runtime.InteropServices;\nusing System.Windows.Forms;\n\n\nnamespace MonitorPowerOff\n{\n    public partial class frmMonitorOff : Form\n    {\n\n        &#91;DllImport(\"user32.dll\")]\n        private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);\n\n\n        \n        public enum MonitorState\n        {\n            MonitorStateOn = -1,\n            MonitorStateOff = 2,\n            MonitorStateStandBy = 1\n        }\n\n        private KeyboardHook keyboardHook;\n\n\n        public frmMonitorOff()\n        {\n            InitializeComponent();\n            SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;\n\n            Keys key1 = Keys.Control;\n            Keys key2 = Keys.Alt;\n            Keys key3 = Keys.Shift;\n            Keys key4 = Keys.D;\n\n            \/\/ HOTKEY STUFF:\n            \/\/ register the event that is fired after the key press.\n            keyboardHook = new KeyboardHook();\n            keyboardHook.RegisterHotKey(1, KeyboardHook.KeyToModifierKey(key1) | KeyboardHook.KeyToModifierKey(key2) | KeyboardHook.KeyToModifierKey(key3), key4);\n            keyboardHook.KeyPressed += new EventHandler&lt;LAWC.Common.KeyPressedEventArgs&gt;(Hook_KeyPressed);\n\n            this.notifyIcon1.MouseClick += NotifyIcon1_MouseClick;\n\n            minimise();\n        }\n\n        private void NotifyIcon1_MouseClick(object sender, MouseEventArgs e)\n        {\n            \/\/ show context menu\n            if (e.Button == System.Windows.Forms.MouseButtons.Left)\n            {\n                toggleForm();\n            }\n        }\n\n\n        private void toggleForm()\n        {\n            \/\/ toggle\n            if (this.WindowState == FormWindowState.Minimized)\n            {\n                restore();\n            }\n            else if (this.WindowState == FormWindowState.Normal)\n            {\n                minimise();\n            }\n        }\n\n        private void restore()\n        {\n            this.WindowState = FormWindowState.Normal;\n            this.ShowInTaskbar = true;\n            notifyIcon1.Visible = true;\n            this.Show();\n            this.BringToFront();\n            this.Focus();\n        }\n\n        private void minimise()\n        {\n            this.WindowState = FormWindowState.Minimized;\n            this.ShowInTaskbar = false;\n            notifyIcon1.Visible = true;\n            if (this.Visible == true) this.Hide();\n        }\n\n\n        void Hook_KeyPressed(object sender, KeyPressedEventArgs e)\n        {\n            SetMonitorInState(MonitorState.MonitorStateOff);\n        }\n\n\n        void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)\n        {\n            SetMonitorInState(MonitorState.MonitorStateOff);\n        }\n\n\n        private void SetMonitorInState(MonitorState state)\n        {\n            SendMessage(0xFFFF, 0x112, 0xF170, (int)state);\n        }\n\n        private void button1_Click(object sender, EventArgs e)\n        {\n            SetMonitorInState(MonitorState.MonitorStateOff);\n        }\n\n        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)\n        {\n            SetMonitorInState(MonitorState.MonitorStateOff);\n        }\n\n\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a very simple application that will allow you to turn off your monitor(s) in Windows, rather than waiting for the set amount of time. How to use: When it starts, it will be minimised to the Task Bar (the icons next to the time). Double clicking on that icon will set the monitors [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"footnotes":""},"class_list":["post-960","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Monitor Power Off - Strangetimez<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Monitor Power Off - Strangetimez\" \/>\n<meta property=\"og:description\" content=\"This is a very simple application that will allow you to turn off your monitor(s) in Windows, rather than waiting for the set amount of time. How to use: When it starts, it will be minimised to the Task Bar (the icons next to the time). Double clicking on that icon will set the monitors [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/\" \/>\n<meta property=\"og:site_name\" content=\"Strangetimez\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-25T10:49:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2014\/06\/btn_donateCC_LG.gif\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/\",\"url\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/\",\"name\":\"Monitor Power Off - Strangetimez\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/wp-content\\\/uploads\\\/2014\\\/06\\\/btn_donateCC_LG.gif\",\"datePublished\":\"2019-04-15T04:45:24+00:00\",\"dateModified\":\"2022-05-25T10:49:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/#breadcrumb\"},\"inLanguage\":\"en-AU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-AU\",\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/wp-content\\\/uploads\\\/2014\\\/06\\\/btn_donateCC_LG.gif\",\"contentUrl\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/wp-content\\\/uploads\\\/2014\\\/06\\\/btn_donateCC_LG.gif\",\"width\":99,\"height\":47,\"caption\":\"Please Donate\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/monitor-power-off\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Monitor Power Off\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/#website\",\"url\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/\",\"name\":\"Strangetimez\",\"description\":\"ADHD, 3D Art, and other random stuff!\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/#\\\/schema\\\/person\\\/2c8d868342f14c1103ab0fce1e0d62d5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-AU\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/#\\\/schema\\\/person\\\/2c8d868342f14c1103ab0fce1e0d62d5\",\"name\":\"Byron1c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-AU\",\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/Avatar_Large_Cleanup.png\",\"url\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/Avatar_Large_Cleanup.png\",\"contentUrl\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/Avatar_Large_Cleanup.png\",\"width\":286,\"height\":316,\"caption\":\"Byron1c\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.strangetimez.com\\\/Blog\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/Avatar_Large_Cleanup.png\"},\"description\":\"I have a Bachelors Degree in Science (Computer Science). Im an application developer, amateur 3D artist, pet lover, and much more. I have been diagnosed with ADHD as an adult.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Monitor Power Off - Strangetimez","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/","og_locale":"en_US","og_type":"article","og_title":"Monitor Power Off - Strangetimez","og_description":"This is a very simple application that will allow you to turn off your monitor(s) in Windows, rather than waiting for the set amount of time. How to use: When it starts, it will be minimised to the Task Bar (the icons next to the time). Double clicking on that icon will set the monitors [&hellip;]","og_url":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/","og_site_name":"Strangetimez","article_modified_time":"2022-05-25T10:49:50+00:00","og_image":[{"url":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2014\/06\/btn_donateCC_LG.gif","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/","url":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/","name":"Monitor Power Off - Strangetimez","isPartOf":{"@id":"https:\/\/www.strangetimez.com\/Blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/#primaryimage"},"image":{"@id":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/#primaryimage"},"thumbnailUrl":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2014\/06\/btn_donateCC_LG.gif","datePublished":"2019-04-15T04:45:24+00:00","dateModified":"2022-05-25T10:49:50+00:00","breadcrumb":{"@id":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/#breadcrumb"},"inLanguage":"en-AU","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/"]}]},{"@type":"ImageObject","inLanguage":"en-AU","@id":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/#primaryimage","url":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2014\/06\/btn_donateCC_LG.gif","contentUrl":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2014\/06\/btn_donateCC_LG.gif","width":99,"height":47,"caption":"Please Donate"},{"@type":"BreadcrumbList","@id":"https:\/\/www.strangetimez.com\/Blog\/monitor-power-off\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.strangetimez.com\/Blog\/"},{"@type":"ListItem","position":2,"name":"Monitor Power Off"}]},{"@type":"WebSite","@id":"https:\/\/www.strangetimez.com\/Blog\/#website","url":"https:\/\/www.strangetimez.com\/Blog\/","name":"Strangetimez","description":"ADHD, 3D Art, and other random stuff!","publisher":{"@id":"https:\/\/www.strangetimez.com\/Blog\/#\/schema\/person\/2c8d868342f14c1103ab0fce1e0d62d5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.strangetimez.com\/Blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-AU"},{"@type":["Person","Organization"],"@id":"https:\/\/www.strangetimez.com\/Blog\/#\/schema\/person\/2c8d868342f14c1103ab0fce1e0d62d5","name":"Byron1c","image":{"@type":"ImageObject","inLanguage":"en-AU","@id":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2022\/08\/Avatar_Large_Cleanup.png","url":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2022\/08\/Avatar_Large_Cleanup.png","contentUrl":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2022\/08\/Avatar_Large_Cleanup.png","width":286,"height":316,"caption":"Byron1c"},"logo":{"@id":"https:\/\/www.strangetimez.com\/Blog\/wp-content\/uploads\/2022\/08\/Avatar_Large_Cleanup.png"},"description":"I have a Bachelors Degree in Science (Computer Science). Im an application developer, amateur 3D artist, pet lover, and much more. I have been diagnosed with ADHD as an adult."}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/pages\/960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/comments?post=960"}],"version-history":[{"count":18,"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/pages\/960\/revisions"}],"predecessor-version":[{"id":1477,"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/pages\/960\/revisions\/1477"}],"wp:attachment":[{"href":"https:\/\/www.strangetimez.com\/Blog\/wp-json\/wp\/v2\/media?parent=960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}