绿色风's Blog
专注AutoIT(Au3)
  • 首页
  • 流●年
  • 笔●记
    • 学习随记
    • 源码示例
  • 脚●本
    • UDF(收集)
    • 工作室UDF
    • 工具●教程
    • 教程之GDI
  • 作●品
  • 下●载
  • 情怀ExcelTip
8月302018

AU3控制当前程序的音量

作者:绿色风   发布:2018-8-30 6:38 Thursday   分类:源码示例   阅读:4165次   评论:0条  

#RequireAdmin
#pre_usex64=n
#QQ交流群:477266297
#include <GUIConstants.au3>
Opt('MustDeclareVars', 1)

Global $MainForm = GUICreate('SoundValueTest', 400, 200, -1, -1)
Global $Sli_SoundValue = GUICtrlCreateSlider(10, 112, 380, 20)
GUICtrlSetLimit($Sli_SoundValue, 100, 0)
GUICtrlSetData($Sli_SoundValue, waveOutGetVolume())
Global $Lbl_CurrentSound = GUICtrlCreateLabel("当前程序音量:", 10, 16, 100, 41)
Global $Lbl_CurrentSoundValue = GUICtrlCreateLabel(waveOutGetVolume(), 110, 16, 164, 41)
GUICtrlSetColor($Lbl_CurrentSoundValue, 0xff0000)
GUISetState()
Local $nMsg
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Sli_SoundValue
                        waveOutSetVolume(0, GUICtrlRead($Sli_SoundValue))
                        GUICtrlSetData($Lbl_CurrentSoundValue, waveOutGetVolume())
        EndSwitch
WEnd

;~ 第二个参数的低字节是左声道音量,高字节是右声道音量

Func waveOutGetVolume($hHwd = 0)
        Local $WaveVol = -1
        Local $tBuffer = DllStructCreate("dword")
        If @error Then Return SetError(2, 0, -2)
        Local $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", $hHwd, "long", DllStructGetPtr($tBuffer))
        If @error Then Return SetError($ret[0], 0, $WaveVol)
        $WaveVol = Round(100 * DllStructGetData($tBuffer, 1) / 0xFFFF)
        Return SetError($ret[0], 0, $WaveVol)
EndFunc   ;==>waveOutGetVolume

Func waveOutSetVolume($hHwd = 0, $Round = 100)
        Local $iSoundValue = Round(0xFFFF * $Round / 100)
        Local $ret = DllCall('winmm.dll', 'none', 'waveOutSetVolume', 'hwnd', $hHwd, 'dword', $iSoundValue)
        Return $ret[0] = ''
EndFunc   ;==>waveOutSetVolume```




本文固定链接: http://www.jianyiit.com/post-295.html

blogger
该日志由 绿色风 于2018-8-30 6:38 Thursday发表在 源码示例 分类下。
版权所有:《绿色风's Blog》 → 《AU3控制当前程序的音量》;
除特别标注,本博客很多文章均为原创. 互联分享,尊重版权,转载请以链接形式标明本文地址;
本文标签:

扫描二维码,在手机上阅读
上一篇::检测当前网页,并加载返回JQuery
下一篇:Windows常用shell命令大全[自带程序的名称]

热门文章

相关文章

  • Au3 屏幕取色器
  • 笔记本电池电量显示
  • AU3高级目录文件遍历
  • 有点意思的代码-模拟混沌单摆
  • [汇编注入]纯AU3实现的汇编注入引擎(完全脱离DLL等外部插件)
取消回复

发表评论

亲,头像对么?

42 + 52 =

提交中,请稍候……


木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!


    站点统计
    • 运行时间: 20254 天
    • 日志总数: 365 篇
    • 评论数量: 7240 条
    • 微语数量: 6 条
    • 附件总量: 388 件
  • 逝出的青春

  • 打赏"绿色风"



      扫码关注本站公众号 可搜本站内容

  • Autoit V3 脚本交流群

      常驻群1:905774875
      常驻群2:40672266


  • 链接

    • AU3中文论坛
    • Excel资料库
    • 完美者博客
    • 顺网小哥'S Blog
    • 猛牛哥的博客
    • 网吧系统下载
  • 分类

    • 流●年(66)
    • 笔●记(0)
    • 脚●本(0)
    • 作品(21)
    • 学习随记(51)
    • 源码示例(68)
    • UDF(收集)(26)
    • 工作室UDF(30)
    • 工具●教程(62)
    • 教程之GDI(24)
Copyright © 2013 绿色风's Blog. Powered by emlog. Theme by 射雕天龙. 鄂ICP备2021011689号-1 鄂公网安备42102302000078号 sitemap