AHK播放MP3音乐

; https://www.autohotkey.com/boards/viewtopic.php?f=74&t=69367&hilit=setupapi
MusicFile := "E:\MP3\NEW\xxxxxxxx.mp3"
mciSendString("open " """" MusicFile """" " type mpegvideo Alias MyMusic")
mciSendString("play MyMusic")
MsgBox, Playing...

; 你可以看到我在@tmplinshi的代码中添加了一个“W”,但没有它也能工作。【Win10加不加W都能工作】
mciSendString(Command) {
   Return, DllCall("winmm.dll\mciSendString", Str,Command, Str,"", Int,0, Int,0)
}


; 第二个例子
MusicFile := "C:\Sounds\drumroll.mp3"
mciSendString("open " """" MusicFile """" " type mpegvideo Alias MyMusic")
mciSendString("play MyMusic")
MsgBox, Playing...

ResRead( WAV01, "C:\Sounds\Delete.wav" )
PlaySoundAsync( WAV01 )
MsgBox, pause

; ====================================================================
mciSendString(Command) {
   Return, DllCall("winmm.dll\mciSendStringW", Str,Command, Str,"", Int,0, Int,0)
}

PlaySoundAsync( ByRef Sound ) { ; http://www.autohotkey.com/board/topic/96484-read-wave-resource-from-exe-using-skans-dllread-possible/?p=609800
   Return DllCall( "winmm.dll\PlaySound" ( A_IsUnicode ? "W" : "A" ), UInt,&Sound, UInt,0, UInt, 0x7 )
}

; ResRead() By SKAN, from http://www.autohotkey.com/board/topic/57631-crazy-scripting-resource-only-dll-for-dummies-36l-v07/?p=609282
ResRead( ByRef Var, Key ) { 
  VarSetCapacity( Var, 128 ), VarSetCapacity( Var, 0 )
  If ! ( A_IsCompiled ) {
    FileGetSize, nSize, %Key%
    FileRead, Var, *c %Key%
    Return nSize
  }
 
  If hMod := DllCall( "GetModuleHandle", UInt,0 )
    If hRes := DllCall( "FindResource", UInt,hMod, Str,Key, UInt,10 )
      If hData := DllCall( "LoadResource", UInt,hMod, UInt,hRes )
        If pData := DllCall( "LockResource", UInt,hData )
  Return VarSetCapacity( Var, nSize := DllCall( "SizeofResource", UInt,hMod, UInt,hRes ) )
      ,  DllCall( "RtlMoveMemory", Str,Var, UInt,pData, UInt,nSize )
Return 0    
}

; PlaySoundAsync_File( SoundFile ) {
;    Return DllCall("winmm.dll\PlaySound", "str",SoundFile, UInt,0, UInt, 0x00020000 | 0x0001 )
; }

给TA捐赠
共{{data.count}}人
人已捐赠
其他

AHKWALL

2021-12-2 12:19:32

其他

ahk分割文本

2021-12-2 14:38:26

3 条回复 A文章作者 M管理员
  1. §勇往直前

    首次启动脚本,能触发相关弹窗播放声音,在不关闭脚本的情况下,再次需要播放声音的时候就只有触发相关弹窗没有声音了 不知道为什么,需要重新启动脚本 才……我弄了一个监控 文件变化的提醒,提醒的同时想像QQ那样“滴滴滴”的响一下,不知道如何优化支持不止响一次呢,静待老师 看有没有解决方案……

  2. 南海

    请教大佬,为什么32位编译以后改功能无法实现。编译前没问题。

    • 河许人

      改什么功能?

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索