// public static MorphicResult <MorphicUnit, Win32ApiError> SendVolumeMuteToggleCommand(IntPtr sourceHwnd) { var generateAppCommandResult = VolumeUtils.InternalSendAppCommand(sourceHwnd, Keyboard.Utils.AppCommandUtils.AppCommand.APPCOMMAND_VOLUME_MUTE); if (generateAppCommandResult.IsError == true) { return(MorphicResult.ErrorResult(generateAppCommandResult.Error !)); } return(MorphicResult.OkResult()); }
// public static MorphicResult <MorphicUnit, Win32ApiError> SendVolumeUpCommand(IntPtr sourceHwnd, uint percent) { if (percent % 2 != 0) { throw new ArgumentOutOfRangeException(nameof(percent), "Argument must be an even value, as each key reduces the volume % by 2"); } if (percent > 100) { throw new ArgumentOutOfRangeException(nameof(percent), "Argument may not exceed 100 percent"); } var keyPressCount = percent / 2; for (var i = 0; i < keyPressCount; i += 1) { var generateAppCommandResult = VolumeUtils.InternalSendAppCommand(sourceHwnd, Keyboard.Utils.AppCommandUtils.AppCommand.APPCOMMAND_VOLUME_UP); if (generateAppCommandResult.IsError == true) { return(MorphicResult.ErrorResult(generateAppCommandResult.Error !)); } } return(MorphicResult.OkResult()); }
public static MorphicResult <MorphicUnit, Win32ApiError> SendVolumeMuteToggleCommand() { // if no sourceHwnd was provided, then use IntPtr.Zero; we'll consider this to be "null" and will send the command from the taskbar instead return(VolumeUtils.SendVolumeMuteToggleCommand(IntPtr.Zero)); }