; 此示例为:按住CapsLock开始录制麦克风
CapsLock::
PathToSaveRec := A_Desktop . "/" . A_Now . "record.wav"
Record()
KeyWait CapsLock
Record("Stop", PathToSaveRec)
Return

Record(Mode := "Start", FilePath := "") {
  if (Mode="Start") {
    DllCall("Winmm\mciSendString", "Str", "open new type waveaudio alias recsound", "Str", "", "UInt", 0, "Ptr", 0)
    , DllCall("Winmm\mciSendString", "Str", "record recsound", "Str", "", "UInt", 0, "Ptr", 0)
  } else {
    DllCall("Winmm\mciSendString", "Str", "save recsound " . FilePath, "Str", "", "UInt", 0, "Ptr", 0)
    , DllCall("Winmm\mciSendString", "Str", "close recsound", "Str", "", "UInt", 0, "Ptr", 0)
    ; , DllCall("Winmm\mciSendString", "Str", "close recsound" . FilePath, "Str", "", "UInt", 0, "Ptr", 0)  ; 延续上一个录音片段
  }
}

; 另一个示例:播放使用 BASS.dll 录制 WAV 文件
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=34352

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。