zoukankan      html  css  js  c++  java
  • C# 按钮控制windows音量

    控制系统音量
     
    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;
    using System.Runtime.InteropServices;//dll引用要用到的
     
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
            static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, uint lParam);
     
            const uint WM_APPCOMMAND = 0x319;
            const uint APPCOMMAND_VOLUME_UP = 0x0a;
            const uint APPCOMMAND_VOLUME_DOWN = 0x09;
            const uint APPCOMMAND_VOLUME_MUTE = 0x08;
     
            public Form1()
            {
                InitializeComponent();
            }
     
            private void button1_Click(object sender, EventArgs e)
            {//增加音量
                SendMessage(this.Handle, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_UP * 0x10000);
            }
     
            private void button2_Click(object sender, EventArgs e)
            {//减少音量
                SendMessage(this.Handle, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_DOWN * 0x10000);
            }
     
            private void button3_Click(object sender, EventArgs e)
            {//静音切换
                SendMessage(this.Handle, WM_APPCOMMAND, 0x200eb0, APPCOMMAND_VOLUME_MUTE * 0x10000);
            }
     
            private void button1_MouseDown(object sender, MouseEventArgs e)
            {
                
            }
     
        }
    }

    image

  • 相关阅读:
    Falsk的模板分配和蓝图、定制错误信息、 和补充
    Flask配置文件和 路由系统
    初始Flask
    REST Framework组件的解析源码
    MdelForm 和formset
    待修改脚本
    时间打点脚本
    Move Over and Click Link
    Wait and Click Element
    Strings=newString(“xyz”);创建了几个 StringObject?
  • 原文地址:https://www.cnblogs.com/jx270/p/2869105.html
Copyright © 2011-2022 走看看