diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..426d76d --- /dev/null +++ b/.gitignore @@ -0,0 +1,398 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/3rdparty_licensing/3RDPARTY.txt b/3rdparty_licensing/3RDPARTY.txt new file mode 100644 index 0000000..725942b --- /dev/null +++ b/3rdparty_licensing/3RDPARTY.txt @@ -0,0 +1,3 @@ +This application contains the following 3rd party elements: + +* https://www.iconfinder.com/icons/9035939/moon_sharp_icon MIT License diff --git a/3rdparty_licensing/MIT.txt b/3rdparty_licensing/MIT.txt new file mode 100644 index 0000000..697b0fa --- /dev/null +++ b/3rdparty_licensing/MIT.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..58858b8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Simon Tushev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6760e6f --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# PressSleepKey - turn your monitor off +![GitHub](https://img.shields.io/github/license/tushev/presssleepkey) ![C#](https://img.shields.io/badge/language-C%23-green) ![.NET 6](https://img.shields.io/badge/runtime-.NET%206-blueviolet) + + +The story of this app is very simple: I had a keyboard with dedicated **Sleep** key, that I used for turning my display off. Not locking, just shutting down the display. +After a while, I replaced my keyboard with a newer one, with lots of cool features, and programmable keys (CORSAIR K55 RGB PRO XT). +However, it turned out that it is not possible to make one of the keys function like dedicated **Sleep** key. + +This program sends (WM_SYSCOMMAND)[https://docs.microsoft.com/en-us/windows/win32/menurc/wm-syscommand] WinAPI message with `SC_MONITORPOWER, 2` params. +This message shuts the display off. + +Normally, Windows should turn the monitor on if the user moves the mouse or presses any key. +However, this program does nothing to turn the display back on; it's up to the user. + +* `src-console` contains console app +* `src-winforms` contains WinForms app + +It seems that Corsair iCUE software does not allow to assign a console app to the custom keys (sic!). Please use WinForms version with iCUE. + diff --git a/src-console/9035939_moon_sharp_icon.ico b/src-console/9035939_moon_sharp_icon.ico new file mode 100644 index 0000000..b1ec68f Binary files /dev/null and b/src-console/9035939_moon_sharp_icon.ico differ diff --git a/src-console/PressSleepKey.csproj b/src-console/PressSleepKey.csproj new file mode 100644 index 0000000..1b1fdf9 --- /dev/null +++ b/src-console/PressSleepKey.csproj @@ -0,0 +1,16 @@ + + + + Exe + net6.0 + enable + enable + + 9035939_moon_sharp_icon.ico + + + + + + + diff --git a/src-console/PressSleepKey.sln b/src-console/PressSleepKey.sln new file mode 100644 index 0000000..ab4b210 --- /dev/null +++ b/src-console/PressSleepKey.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32407.343 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PressSleepKey", "PressSleepKey.csproj", "{FF8E9A56-5AC8-40C4-8295-95DFE0226D2E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FF8E9A56-5AC8-40C4-8295-95DFE0226D2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF8E9A56-5AC8-40C4-8295-95DFE0226D2E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF8E9A56-5AC8-40C4-8295-95DFE0226D2E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF8E9A56-5AC8-40C4-8295-95DFE0226D2E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {75063883-CE00-4A27-A6F1-D79881567A33} + EndGlobalSection +EndGlobal diff --git a/src-console/Program.cs b/src-console/Program.cs new file mode 100644 index 0000000..fc2320d --- /dev/null +++ b/src-console/Program.cs @@ -0,0 +1,29 @@ +using System; +using System.Runtime.InteropServices; +using System.Timers; + +namespace PressSleepKey +{ + class Program + { + private static int WM_SYSCOMMAND = 0x0112; + private static uint SC_MONITORPOWER = 0xF170; + private static int SW_HIDE = 0; + + public static void Main(string[] args) + { + var handle = GetConsoleWindow(); + ShowWindow(handle, SW_HIDE); + SendMessage(handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)2); + } + + [DllImport("kernel32.dll")] + static extern IntPtr GetConsoleWindow(); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); + + [DllImport("user32.dll")] + static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); + } +} \ No newline at end of file diff --git a/src-console/Properties/launchSettings.json b/src-console/Properties/launchSettings.json new file mode 100644 index 0000000..b241eab --- /dev/null +++ b/src-console/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "PressSleepKey": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/src-winforms/9035939_moon_sharp_icon.ico b/src-winforms/9035939_moon_sharp_icon.ico new file mode 100644 index 0000000..b1ec68f Binary files /dev/null and b/src-winforms/9035939_moon_sharp_icon.ico differ diff --git a/src-winforms/Form1.Designer.cs b/src-winforms/Form1.Designer.cs new file mode 100644 index 0000000..527ef0d --- /dev/null +++ b/src-winforms/Form1.Designer.cs @@ -0,0 +1,51 @@ +namespace PressSleepKeyWF +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.SuspendLayout(); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(135, 0); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Form1"; + this.Text = "PressSleepKey"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/src-winforms/Form1.cs b/src-winforms/Form1.cs new file mode 100644 index 0000000..5fc765b --- /dev/null +++ b/src-winforms/Form1.cs @@ -0,0 +1,10 @@ +namespace PressSleepKeyWF +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src-winforms/Form1.resx b/src-winforms/Form1.resx new file mode 100644 index 0000000..68f85c4 --- /dev/null +++ b/src-winforms/Form1.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAAAAAAAEAIABSDgAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAEAAAABAAgGAAAAXHKoZgAAAAlw + SFlzAAALEwAACxMBAJqcGAAADgRJREFUeJzt3XmsHWUZx/EfZalQdgibAkW2smgLCInEUEEUqLIIgsge + gbKIFCgFRP6oSxSRAhUVEEFElEUjQVYJoUhYDQhStlZW2QLI3pYdfZ5Mr1za3nvPOfPOPLN8P8n3H0zw + nnfmuZx7zsw7EgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQHMNs3a0vh/9gwAozwjrKOsJ67/W7qE/DYBS + DLfGW88qG3zvxbn/HEBDLWZNsJ7Th4Pf1ymBPxeAgvnf+I9o/sH3PrDWi/vRABRlS+sOLXjw+7o57KcD + UIjlranW+xp8+L1vB/2MABLzr/QOtV7S0IPf9/Z/9ZCfFEBSa1s3qrPB7+uOkJ8UQDKLKPt0f5a6G37v + uICfF0Ai/l/929X94Pe1bvk/MoAUDrBeV+/DP6P0nxhAbktbl6r3we/r7LJ/cAD5bGA9oPzD7+1R8s8O + IId9rdlKM/z+9d/K5f74AHrhn/KfrDSD39d9pb4CAD3xK/puUNrh96aW+SIAdM9v0Jmp9MPv7Vni6wDQ + pc2s51XM8Ht8/w9U1FjrNRU3/P7vHlbaqwHQMb9vf46KG35vWmmvBkDH/Gu+d1Xs8HtTynpBADpzrLLv + 5osefm+fkl4TgA58T+UMfl+blPOyAAxlosodfn+XsVQprwz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6AERTILxTyt1jRB5po3hj+kuxpvaP4A07k+dv+1u7qE+UrYh8Bis93uD5ACLG19Ybi + TwJqZ/6htD+tGIHGiusEqPz8icGfFyrBLxZ6SvEnBbUjf4LP5kKlrGrdpfiTg5qd39gzSqikEdaVij9J + qJldZS0jVJo/gPRnij9ZqDn513yT1aJHdzWBb7ns+69FnzxU7/xbpt2EWhotNhql3vNzx59bgRrz3Yav + VvzJRPXqMmXnDhrA/3YbL24ppqHza0r8XEEDbWTdq/iTjKrZbdbaQqP5A0lPFncU0of5jWWTxa69rfIl + 6zHFn3wU23RlHxajhRZX9m7A7+iKPhGp3PxO0snWcKH1xojLiNvUNHE5L+axqHWM9YriT1AqJv+T72sC + BrG8NVX8WdCk/IrQyco+AAY64h8M3aj4k5d6zz/dP0vZnaJAT7a17lT8yUyd51/x+pV86y7geAJd8ysJ + dxTPKqx6/mfbxeL6fRTEfxH4nWF3K/5kpw/zt/q/sdYb+NABafmGpH6Tkd8rHj0Abe1l6yfW6kMcK6Aw + G1rniS3Ky+xB6zBlO0ABleBbRfldZHxOUEy+Bbd/sOcfyrIzDyrNnwnv7wp4ZkG+/M+rW5Q9bJN781E7 + S1h7WH+y5ih+oOqS36BzkrVW90sOVNOSyvYpvFzsVThv/r397dZx4rt7tIDvXPw5ZXci+k1Ibfwm4QVl + f9P75yYfz7ecQL2taR2o7LvsGYofziJ6xrrEOsL6lPggDxjQStYu1qnK7kfwR1FFD3A3+b5606yfKnuU + O9tsATmtZm2n7O/k3yr7dNz/qxr558Oz1q3K3rlMssZZI8V/3YHS+I426yv75XCQdaJ1mrJfEv4oK/9w + bab1qLKBfXlu/X9xvNrvnz9u/VPZL5hrrYvm/vv8F89+c/9/fDMNbq0FAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAADI6X+FCe5b6XpqPwAAAABJRU5ErkJggg== + + + \ No newline at end of file diff --git a/src-winforms/PressSleepKeyWF.csproj b/src-winforms/PressSleepKeyWF.csproj new file mode 100644 index 0000000..2c901fe --- /dev/null +++ b/src-winforms/PressSleepKeyWF.csproj @@ -0,0 +1,17 @@ + + + + WinExe + net6.0-windows + enable + true + enable + PressSleepKeyWF.Program + 9035939_moon_sharp_icon.ico + + + + + + + \ No newline at end of file diff --git a/src-winforms/PressSleepKeyWF.sln b/src-winforms/PressSleepKeyWF.sln new file mode 100644 index 0000000..304a675 --- /dev/null +++ b/src-winforms/PressSleepKeyWF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32407.343 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PressSleepKeyWF", "PressSleepKeyWF.csproj", "{B0487E25-4C7B-4D06-BC57-BB47C7B52E99}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0487E25-4C7B-4D06-BC57-BB47C7B52E99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0487E25-4C7B-4D06-BC57-BB47C7B52E99}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0487E25-4C7B-4D06-BC57-BB47C7B52E99}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0487E25-4C7B-4D06-BC57-BB47C7B52E99}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F449235D-9381-4C70-BC9A-B9F681A4A5A7} + EndGlobalSection +EndGlobal diff --git a/src-winforms/Program.cs b/src-winforms/Program.cs new file mode 100644 index 0000000..b192b07 --- /dev/null +++ b/src-winforms/Program.cs @@ -0,0 +1,29 @@ +using System; +using System.Runtime.InteropServices; + +namespace PressSleepKeyWF +{ + internal static class Program + { + private static int WM_SYSCOMMAND = 0x0112; + private static uint SC_MONITORPOWER = 0xF170; + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + + var f = new Form1(); + SendMessage(f.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)2); + } + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); + + } +} \ No newline at end of file diff --git a/src-winforms/Properties/launchSettings.json b/src-winforms/Properties/launchSettings.json new file mode 100644 index 0000000..f6887c1 --- /dev/null +++ b/src-winforms/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "PressSleepKeyWF": { + "commandName": "Project" + } + } +} \ No newline at end of file