From 6140eea559cc617181604db32591828496119e1a Mon Sep 17 00:00:00 2001 From: Luca Berneking Date: Thu, 3 Aug 2017 21:32:17 +0200 Subject: [PATCH] add new feature to show OSD onvolume change with volume keys add form to change show time in ms --- .gitignore | 261 +++++++++++++++++++++++++ HideVolumeOSD/ContextMenus.cs | 23 ++- HideVolumeOSD/HideVolumeOSDApp.csproj | 14 +- HideVolumeOSD/HideVolumeOSDLib.cs | 59 ++++-- HideVolumeOSD/Settings.Designer.cs | 14 +- HideVolumeOSD/Settings.settings | 3 + HideVolumeOSD/SettingsForm.Designer.cs | 96 +++++++++ HideVolumeOSD/SettingsForm.cs | 36 ++++ HideVolumeOSD/SettingsForm.resx | 257 ++++++++++++++++++++++++ HideVolumeOSD/VolumeKeys.cs | 72 +++++++ HideVolumeOSD/app.config | 3 + 11 files changed, 822 insertions(+), 16 deletions(-) create mode 100644 .gitignore create mode 100644 HideVolumeOSD/SettingsForm.Designer.cs create mode 100644 HideVolumeOSD/SettingsForm.cs create mode 100644 HideVolumeOSD/SettingsForm.resx create mode 100644 HideVolumeOSD/VolumeKeys.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.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 + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# 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 +# TODO: 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 +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable 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 + +# 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 +node_modules/ +orleans.codegen.cs + +# 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 + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# 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/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/HideVolumeOSD/ContextMenus.cs b/HideVolumeOSD/ContextMenus.cs index 13fea38..f468d5e 100644 --- a/HideVolumeOSD/ContextMenus.cs +++ b/HideVolumeOSD/ContextMenus.cs @@ -67,8 +67,14 @@ public ContextMenuStrip Create() menu.Items.Add(item); switchMenu = item; - // About - item = new ToolStripMenuItem(); + item = new ToolStripMenuItem(); + item.Text = "Settings"; + item.Click += new EventHandler(Settings_Click); + item.ImageIndex = 0; + menu.Items.Add(item); + + // About + item = new ToolStripMenuItem(); item.Text = "About"; item.Click += new EventHandler(About_Click); item.ImageIndex = 2; @@ -139,5 +145,16 @@ void Exit_Click(object sender, EventArgs e) { Application.Exit(); } - } + + + /// + /// Open Settings Form + /// + /// The sender. + /// The instance containing the event data. + void Settings_Click(object sender, EventArgs e) + { + new SettingsForm().Show(); + } + } } \ No newline at end of file diff --git a/HideVolumeOSD/HideVolumeOSDApp.csproj b/HideVolumeOSD/HideVolumeOSDApp.csproj index aa11e65..fc4573a 100644 --- a/HideVolumeOSD/HideVolumeOSDApp.csproj +++ b/HideVolumeOSD/HideVolumeOSDApp.csproj @@ -111,6 +111,13 @@ True Settings.settings + + Form + + + SettingsForm.cs + + AboutBox.cs @@ -127,7 +134,12 @@ Resources.resx True - + + SettingsForm.cs + + + Designer + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/HideVolumeOSD/HideVolumeOSDLib.cs b/HideVolumeOSD/HideVolumeOSDLib.cs index 6917880..ee75c63 100644 --- a/HideVolumeOSD/HideVolumeOSDLib.cs +++ b/HideVolumeOSD/HideVolumeOSDLib.cs @@ -23,7 +23,11 @@ public class HideVolumeOSDLib IntPtr hWndInject = IntPtr.Zero; - public HideVolumeOSDLib(NotifyIcon ni) + VolumeKeys volumeKeys; + System.Timers.Timer hideTimer = new System.Timers.Timer(); + bool hiding = false; + + public HideVolumeOSDLib(NotifyIcon ni) { this.ni = ni; } @@ -64,9 +68,34 @@ public void Init() Application.ApplicationExit += Application_ApplicationExit; } - } - private IntPtr FindOSDWindow(bool bSilent) + volumeKeys = new VolumeKeys(); + volumeKeys.KeyPress += VolumeKeys_KeyPress; + + hideTimer.Elapsed += HideTimer_Elapsed; + } + + + private void VolumeKeys_KeyPress(object sender, EventArgs e) + { + hideTimer.Stop(); + if (Settings.Default.HideOSD == false) return; + if (Settings.Default.ShowMs == 0) return; + hideTimer.Interval = Settings.Default.ShowMs; + + if (hiding) ShowOSD(false); + + hideTimer.Start(); + } + + private void HideTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + hideTimer.Stop(); + + if (!hiding && Settings.Default.HideOSD) HideOSD(); + } + + private IntPtr FindOSDWindow(bool bSilent) { IntPtr hwndRet = IntPtr.Zero; IntPtr hwndHost = IntPtr.Zero; @@ -121,19 +150,27 @@ public void HideOSD() if (ni != null) ni.Icon = Resources.IconDisabled; - } - public void ShowOSD() + hiding = true; + hideTimer.Stop(); + } + + public void ShowOSD(bool show=true) { ShowWindow(hWndInject, 9); // SW_RESTORE - - // show window on the screen - - keybd_event((byte)Keys.VolumeUp, 0, 0, 0); - keybd_event((byte)Keys.VolumeDown, 0, 0, 0); + + if (show) + { + // show window on the screen + keybd_event((byte)Keys.VolumeUp, 0, 0, 0); + keybd_event((byte)Keys.VolumeDown, 0, 0, 0); + } + if (ni != null) ni.Icon = Resources.Icon; - } + + hiding = false; + } } } diff --git a/HideVolumeOSD/Settings.Designer.cs b/HideVolumeOSD/Settings.Designer.cs index f4c8c7e..783b511 100644 --- a/HideVolumeOSD/Settings.Designer.cs +++ b/HideVolumeOSD/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace HideVolumeOSD { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.1.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -34,5 +34,17 @@ public bool HideOSD { this["HideOSD"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int ShowMs { + get { + return ((int)(this["ShowMs"])); + } + set { + this["ShowMs"] = value; + } + } } } diff --git a/HideVolumeOSD/Settings.settings b/HideVolumeOSD/Settings.settings index 19ee3a3..9799b7b 100644 --- a/HideVolumeOSD/Settings.settings +++ b/HideVolumeOSD/Settings.settings @@ -5,5 +5,8 @@ True + + 0 + \ No newline at end of file diff --git a/HideVolumeOSD/SettingsForm.Designer.cs b/HideVolumeOSD/SettingsForm.Designer.cs new file mode 100644 index 0000000..db9923b --- /dev/null +++ b/HideVolumeOSD/SettingsForm.Designer.cs @@ -0,0 +1,96 @@ +namespace HideVolumeOSD +{ + partial class SettingsForm + { + /// + /// 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(SettingsForm)); + this.slShowOnChangeMs = new System.Windows.Forms.TrackBar(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.lbShowOnChangeMs = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.slShowOnChangeMs)).BeginInit(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // slShowOnChangeMs + // + this.slShowOnChangeMs.LargeChange = 50; + this.slShowOnChangeMs.Location = new System.Drawing.Point(6, 19); + this.slShowOnChangeMs.Maximum = 2000; + this.slShowOnChangeMs.Name = "slShowOnChangeMs"; + this.slShowOnChangeMs.Size = new System.Drawing.Size(575, 45); + this.slShowOnChangeMs.SmallChange = 10; + this.slShowOnChangeMs.TabIndex = 0; + this.slShowOnChangeMs.TickFrequency = 50; + this.slShowOnChangeMs.ValueChanged += new System.EventHandler(this.slShowOnChangeMs_ValueChanged); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.lbShowOnChangeMs); + this.groupBox1.Controls.Add(this.slShowOnChangeMs); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(587, 85); + this.groupBox1.TabIndex = 1; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Show OSD on VolumeKeys"; + // + // lbShowOnChangeMs + // + this.lbShowOnChangeMs.AutoSize = true; + this.lbShowOnChangeMs.Location = new System.Drawing.Point(279, 51); + this.lbShowOnChangeMs.Name = "lbShowOnChangeMs"; + this.lbShowOnChangeMs.Size = new System.Drawing.Size(29, 13); + this.lbShowOnChangeMs.TabIndex = 1; + this.lbShowOnChangeMs.Text = "0 ms"; + // + // SettingsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(611, 105); + this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "SettingsForm"; + this.Text = "SettingsForm"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SettingsForm_FormClosing); + this.Load += new System.EventHandler(this.SettingsForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.slShowOnChangeMs)).EndInit(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TrackBar slShowOnChangeMs; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label lbShowOnChangeMs; + } +} \ No newline at end of file diff --git a/HideVolumeOSD/SettingsForm.cs b/HideVolumeOSD/SettingsForm.cs new file mode 100644 index 0000000..11edc5f --- /dev/null +++ b/HideVolumeOSD/SettingsForm.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace HideVolumeOSD +{ + public partial class SettingsForm : Form + { + public SettingsForm() + { + InitializeComponent(); + } + + private void SettingsForm_Load(object sender, EventArgs e) + { + slShowOnChangeMs.Value = Settings.Default.ShowMs; + lbShowOnChangeMs.Text = Settings.Default.ShowMs + " ms"; + } + + private void slShowOnChangeMs_ValueChanged(object sender, EventArgs e) + { + lbShowOnChangeMs.Text = slShowOnChangeMs.Value + " ms"; + } + + private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e) + { + Settings.Default.ShowMs = slShowOnChangeMs.Value; + Settings.Default.Save(); + } + } +} diff --git a/HideVolumeOSD/SettingsForm.resx b/HideVolumeOSD/SettingsForm.resx new file mode 100644 index 0000000..dfc28f4 --- /dev/null +++ b/HideVolumeOSD/SettingsForm.resx @@ -0,0 +1,257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + AAABAAMAEBAAAAEAIABoBAAANgAAABgYAAABACAAiAkAAJ4EAAAgIAAAAQAgAKgQAAAmDgAAKAAAABAA + AAAgAAAAAQAgAAAAAABABAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAA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AA/wAAAP8AAAD/AAAA/xGe7/8Qne7/EJ3u/xGe7/8Qne7/EZ7v/xCd + 7v8Qne7/EJ3u/xGe7/8Qne7/EJ3u/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/xGe7/8Qne7/EJ3u/xGe7/8Qne7/EZ7v/xCd7v8Qne7/EJ3u/xGe7/8Qne7/EJ3u/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/xGe7/8Rnu//EZ7v/xGe + 7/8Rnu//EZ7v/xGe7/8Rnu//EZ7v/xGe7/8Rnu//EZ7v/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/4jO9/+Izvb/iM72/4jO9/+Izvb/iM73/4jO9v+Izvb/iM72/4jO + 9/+Izvb/iM72/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA//// + ///+/v7//v7+///////+/v7///////7+/v/+/v7//v7+///////+/v7//v7+/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA//////////////////////////////////// + /////////////////////////////wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA///////+/v7//v7+///////+/v7///////7+/v/+/v7//v7+///////+/v7//v7+/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/z8/P/8/Pz//Pz8//z8/ + P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA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7v/xGe7/8Rnu//EZ7v/xGe7/8Rnu//EZ7v/xGe7/8Rnu//EZ7v/xGe + 7/8Rnu//EZ7v/xGe7/8Rnu//AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/xGe7/8Rnu//EZ7v/xGe7/8Rnu//EZ7v/xGe7/8Rnu//EZ7v/xGe + 7/8Rnu//EZ7v/xGe7/8Rnu//EZ7v/xGe7/8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD///////////////////////////////////////// + /////////////////////////////////////////////wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP////////////////////////////// + ////////////////////////////////////////////////////////AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA//////////////////// + //////////////////////////////////////////////////////////////////8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD///////// + /////////////////////////////////////////////////////////////////////////////wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP////////////////////////////////////////////////////////////////////////////// + ////////AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + \ No newline at end of file diff --git a/HideVolumeOSD/VolumeKeys.cs b/HideVolumeOSD/VolumeKeys.cs new file mode 100644 index 0000000..e10348a --- /dev/null +++ b/HideVolumeOSD/VolumeKeys.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; + +namespace HideVolumeOSD +{ + class VolumeKeys + { + + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId); + + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool UnhookWindowsHookEx(IntPtr hhk); + + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern IntPtr GetModuleHandle(string lpModuleName); + + private const int WH_KEYBOARD_LL = 13; + private const int WM_KEYDOWN = 0x0100; + + private IntPtr _hookID = IntPtr.Zero; + + public event KeyPressHandler KeyPress; + public delegate void KeyPressHandler(object sender, EventArgs e); + + public VolumeKeys() + { + _hookID = SetHook(HookCallback); + } + + + private IntPtr SetHook(LowLevelKeyboardProc proc) + { + using (Process curProcess = Process.GetCurrentProcess()) + + using (ProcessModule curModule = curProcess.MainModule) + { + return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); + } + + } + + private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); + + + private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) + { + if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) + { + int vkCode = Marshal.ReadInt32(lParam); + + if ((Keys)vkCode == Keys.VolumeUp || (Keys)vkCode == Keys.VolumeDown) + { + KeyPress?.Invoke(this,new EventArgs()); + } + + } + return CallNextHookEx(_hookID, nCode, wParam, lParam); + } + + + } +} diff --git a/HideVolumeOSD/app.config b/HideVolumeOSD/app.config index cf119e6..b700b79 100644 --- a/HideVolumeOSD/app.config +++ b/HideVolumeOSD/app.config @@ -10,6 +10,9 @@ True + + 0 + \ No newline at end of file