09/01/02 17:31:07 dpIHoV0B0
■ 現在選択されているWave再生デバイス名を取得する
SoundDevice_GetDeviceName() {
RegRead, Playback, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback
return Playback
}
■ 名前でWave再生デバイスを指定する (>>13-14 と組み合わせで使う)
SoundDevice_SetDeviceName(deviceName) {
deviceList := SoundDevice_GetDeviceList("wave", true, true)
Loop, PARSE, deviceList, `n
{
StringSplit, data, A_LoopField, %A_Tab%
if (data1 == deviceName)
return SoundDevice_SetWaveDeviceId(data2)
}
}
■ 再生デバイスのトグルをする。上のものと組み合わせて使う。
戻り値に変更後のデバイス名を返す
SoundDevice_ToggleDevice() {
currentDeviceName := SoundDevice_GetDeviceName()
deviceList := SoundDevice_GetDeviceList()
StringSplit, device, deviceList, `n
deviceCount:=device0, currentId:=0, nextId:=1
Loop, %deviceCount%
if (device%A_Index% == currentDeviceName)
currentId := A_Index
else if (currentId && A_Index == (currentId + 1))
nextId := A_Index
SoundDevice_SetDeviceName(device%nextId%)
return device%nextId%
}