public class Whistle
{
public Whistle()
{
}
[CommandMethod("Whistles", CommandFlags.Session)]
public void PlayFile()
{
IntPtr hWnd = Process.GetProcessesByName("explorer")[0].MainWindowHandle;
uint msg = 0x319;//<<< not sure about this one.
UIntPtr VOLUME_UP = (UIntPtr)0x319; //0xA0000;
IntPtr lParam = IntPtr.Zero;
IntPtr e = DirectVolume.VolUp.SendMessageW(hWnd, msg, VOLUME_UP, lParam);
System.Windows.MessageBox.Show( "Value of e : " + e.ToString());
if (e.ToInt32() > 0)
{
MediaPlayer mp
= new MediaPlayer
(); mp
.Open(new Uri
(@"G:/AutoCAD2012Support/VisualStudio2010/WhistleSounds/Samsung_whistle_ringtone.mp3", UriKind
.RelativeOrAbsolute)); mp.Play();
}
}
}
}
namespace DirectVolume
{
public partial class VolUp
{
[DllImport("User32.dll")]
public static extern IntPtr FindWindow(String sClassName, String sAppName);
[DllImport("User32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, uint msg, UIntPtr VOLUME_UP, IntPtr lParam);
//P/Invoke User32, and use either SendMessageW() + VOLUME_UP const, or KeyBd_Event() + Keys.VolumeUp enum.
//const int VOLUME_UP = 0xA0000;
}
}