summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsotoudeh <matthewsot@outlook.com>2014-12-03 20:26:19 -0800
committermatthewsotoudeh <matthewsot@outlook.com>2014-12-03 20:26:19 -0800
commitf50d6a36262f4e3781a79e66ab6e09c74ac087fb (patch)
tree24bd47becfe08baf6165bc4485a110b7cf42ee27
parentb0a4b5406d17183e5ec845d5f47436ccaaf92961 (diff)
it works :D
-rw-r--r--AntiVol/AntiVol/AntiVol.csproj10
-rw-r--r--AntiVol/AntiVol/Form1.cs17
-rw-r--r--AntiVol/AntiVol/Keyboard.cs6
-rw-r--r--AntiVol/AntiVol/packages.config4
4 files changed, 28 insertions, 9 deletions
diff --git a/AntiVol/AntiVol/AntiVol.csproj b/AntiVol/AntiVol/AntiVol.csproj
index 0acacb7..3d9ba10 100644
--- a/AntiVol/AntiVol/AntiVol.csproj
+++ b/AntiVol/AntiVol/AntiVol.csproj
@@ -32,6 +32,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="AudioSwitcher.AudioApi">
+ <HintPath>..\packages\AudioSwitcher.AudioApi.CoreAudio.1.2.2\lib\net40\AudioSwitcher.AudioApi.dll</HintPath>
+ </Reference>
+ <Reference Include="AudioSwitcher.AudioApi.CoreAudio">
+ <HintPath>..\packages\AudioSwitcher.AudioApi.CoreAudio.1.2.2\lib\net40\AudioSwitcher.AudioApi.CoreAudio.dll</HintPath>
+ </Reference>
+ <Reference Include="NAudio">
+ <HintPath>..\packages\NAudio.1.7.2\lib\net35\NAudio.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -64,6 +73,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
+ <None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
diff --git a/AntiVol/AntiVol/Form1.cs b/AntiVol/AntiVol/Form1.cs
index b440f03..67a3c64 100644
--- a/AntiVol/AntiVol/Form1.cs
+++ b/AntiVol/AntiVol/Form1.cs
@@ -1,19 +1,12 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Forms;
-using System.Runtime.InteropServices;
-//http://www.geekpedia.com/tutorial176_Get-and-set-the-wave-sound-volume.html
+using NAudio.CoreAudioApi;
namespace AntiVol
{
public partial class Form1 : Form
{
+
public Form1()
{
InitializeComponent();
@@ -24,13 +17,19 @@ namespace AntiVol
{
if (!e.KeyName.Contains("Volume")) return true;
+ //Thanks! https://stackoverflow.com/questions/2534595/get-master-sound-volume-in-c-sharp
+ MMDeviceEnumerator devEnum = new MMDeviceEnumerator();
+ MMDevice defaultDevice = devEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
switch (e.KeyName)
{
case "VolumeUp":
+ defaultDevice.AudioEndpointVolume.VolumeStepUp();
break;
case "VolumeDown":
+ defaultDevice.AudioEndpointVolume.VolumeStepDown();
break;
case "VolumeMute":
+ defaultDevice.AudioEndpointVolume.Mute = !defaultDevice.AudioEndpointVolume.Mute;
break;
}
return false;
diff --git a/AntiVol/AntiVol/Keyboard.cs b/AntiVol/AntiVol/Keyboard.cs
index 1a38372..6015281 100644
--- a/AntiVol/AntiVol/Keyboard.cs
+++ b/AntiVol/AntiVol/Keyboard.cs
@@ -202,8 +202,14 @@ public class KeyboardHook : IDisposable
{
bool allowKey = true;
+ //Filter wParam for KeyUp events only
if (nCode >= 0)
{
+ if (wParam == (IntPtr) WM_KEYUP || wParam == (IntPtr) WM_SYSKEYUP)
+ {
+ return NativeMethods.CallNextHookEx(hookID, nCode, wParam, ref lParam);
+ }
+
allowKey = OnKeyIntercepted(new KeyboardHookEventArgs(lParam.vkCode, allowKey));
//If this key is being suppressed, return a dummy value
diff --git a/AntiVol/AntiVol/packages.config b/AntiVol/AntiVol/packages.config
new file mode 100644
index 0000000..001fa38
--- /dev/null
+++ b/AntiVol/AntiVol/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NAudio" version="1.7.2" targetFramework="net45" />
+</packages> \ No newline at end of file
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback