织梦CMS - 轻松建站从此开始!

欧博ABG-会员注册-官网网址

欧博官网The VideoLAN Forums

时间:2025-12-20 15:25来源: 作者:admin 点击: 8 次
Quite a few people online have expressed an interest in being able to control VLC using a foot pedal. I wanted to let the community know about a solu

Quite a few people online have expressed an interest in being able to control VLC using a foot pedal. I wanted to let the community know about a solution.

I am successfully using the Infinity USB foot pedal (IN-USB2) to control VLC in the background, for transcription purposes. I type in a word processor, and am able to control VLC playing in the background, using my foot pedal. This solution requires the AutoHotkey scripting engine, and one of the following scripts:

32 bit:

Code:

; This script allows you to use a USB foot pedal to control VLC in the ; background, in this case, for transcription. This script has been ; tested with a VEC Infinity IN-USB-2 3-function foot pedal. This ; particular foot pedal has 3 buttons, and, therefore, 6 programmable ; functions, as each button can be pressed or released. ; ; To use this script, save it as FootPedal32.ahk and launch it with ; AutoHotkey installed. ; ; See below for more information on customizing this script for VLC. ; ; This version of the script is for the 32-bit version of AutoHotkey. ; ; This script was taken from combined with ; ; ; Thanks go out to all who contributed to this script, and the makers ; of AutoHotkey. ; OnMessage(0x00FF, "InputMessage") RegisterHIDDevice(12, 3) ; Register Foot Pedal PedalLastPress := 0 Return ProcessPedalInput(input) { global PedalLastPress ; The input are combinations of 1, 2, 4 with 00 appended to the end ; indicating which pedals are pressed. ; For example, pressing the leftmost pedal triggers input 100, middle pedal 200, etc. ; all three pedals presses together will trigger 700 (1 ^ 2 ^ 4 = 7) ; Release of pedal trigger an input indicating what pedals are still held down input := input//100 If (input > PedalLastPress) PressKey((PedalLastPress & input) ^ input) ; Else ; ReleaseKey((PedalLastPress & input) ^ PedalLastPress) PedalLastPress := input } ; The ControlSend command allows simulated keystrokes to be sent to any running ; program, even if it is running in the background. For more information on how ; it works, see ; For more information on which commands can be sent, and how to format them, ; see PressKey(bits) { SetTitleMatchMode, 2 If (bits & 1) ; left pedal { ;Msgbox Left pedal pressed! ControlSend,,{=}+{Left},VLC media player ;Normalizes playback speed, and rewinds 3 seconds } Else If (bits & 4) ; right pedal { ;Msgbox Right pedal pressed! ControlSend,,{]},VLC media player ;Increases playback speed by 0.1x increments } Else ; center pedal { ;MsgBox Center pedal pressed! ControlSend,,{Space},VLC media player ;Play/pause } } ; The following function should be uncommented & customized to your liking ; if you would like to utilize different actions upon releasing the foot ; pedal buttons ;ReleaseKey(bits) ;{ ; ToolTip Releasing %bits% ; SetTitleMatchMode, 2 ; If (bits & 1) ; MsgBox left pedal up! ; Else If (bits & 4) ; MsgBox Right pedal up! ; Else ; MsgBox Center pedal up! ;} Mem2Hex( pointer, len ) { A_FI := A_FormatInteger SetFormat, Integer, Hex Loop, %len% { Hex := *Pointer+0 StringReplace, Hex, Hex, 0x, 0x0 StringRight Hex, Hex, 2 hexDump := hexDump . hex Pointer ++ } SetFormat, Integer, %A_FI% StringUpper, hexDump, hexDump Return hexDump } ; Keyboards are always Usage 6, Usage Page 1, Mice are Usage 2, Usage Page 1, ; HID devices specify their top level collection in the info block RegisterHIDDevice(UsagePage,Usage) { ; local RawDevice,HWND RIDEV_INPUTSINK := 0x00000100 DetectHiddenWindows, on HWND := WinExist("ahk_class AutoHotkey ahk_pid " DllCall("GetCurrentProcessId")) DetectHiddenWindows, off VarSetCapacity(RawDevice, 12) NumPut(UsagePage, RawDevice, 0, "UShort") NumPut(Usage, RawDevice, 2, "UShort") NumPut(RIDEV_INPUTSINK, RawDevice, 4) NumPut(HWND, RawDevice, 8) Res := DllCall("RegisterRawInputDevices", "UInt", &RawDevice, UInt, 1, UInt, 12) if (Res = 0) MsgBox, Failed to register for HID Device } InputMessage(wParam, lParam, msg, hwnd) { RID_INPUT := 0x10000003 RIM_TYPEHID := 2 SizeofRidDeviceInfo := 32 RIDI_DEVICEINFO := 0x2000000b DllCall("GetRawInputData", UInt, lParam, UInt, RID_INPUT, UInt, 0, "UInt *", Size, UInt, 16) VarSetCapacity(Buffer, Size) DllCall("GetRawInputData", UInt, lParam, UInt, RID_INPUT, UInt, &Buffer, "UInt *", Size, UInt, 16) Type := NumGet(Buffer, 0 * 4) Size := NumGet(Buffer, 1 * 4) Handle := NumGet(Buffer, 2 * 4) VarSetCapacity(Info, SizeofRidDeviceInfo) NumPut(SizeofRidDeviceInfo, Info, 0) Length := SizeofRidDeviceInfo DllCall("GetRawInputDeviceInfo", UInt, Handle, UInt, RIDI_DEVICEINFO, UInt, &Info, "UInt *", SizeofRidDeviceInfo) VenderID := NumGet(Info, 4 * 2) Product := NumGet(Info, 4 * 3) ; tooltip %VenderID% %Product% if (Type = RIM_TYPEHID) { SizeHid := NumGet(Buffer, (16 + 0)) InputCount := NumGet(Buffer, (16 + 4)) Loop %InputCount% { Addr := &Buffer + 24 + ((A_Index - 1) * SizeHid) BAddr := &Buffer Input := Mem2Hex(Addr, SizeHid) If (VenderID = 1523 && Product = 255) ; need special function to process foot pedal input ProcessPedalInput(Input) Else If (IsLabel(Input)) { Gosub, %Input% } } } }

64 bit:

Code:

; This script allows you to use a USB foot pedal to control VLC in the ; background, in this case, for transcription. This script has been ; tested with a VEC Infinity IN-USB-2 3-function foot pedal. This ; particular foot pedal has 3 buttons, and, therefore, 6 programmable ; functions, as each button can be pressed or released. ; ; To use this script, save it as FootPedal64.ahk and launch it with ; AutoHotkey installed. ; ; See below for more information on customizing this script for VLC. ; ; This version of the script is for the 64-bit version of AutoHotkey. ; ; This script was taken from combined with ; ; ; Thanks go out to all who contributed to this script, and the makers ; of AutoHotkey. ; OnMessage(0x00FF, "InputMessage") RegisterHIDDevice(12, 3) ; Register Foot Pedal PedalLastPress := 0 Return ProcessPedalInput(input) { global PedalLastPress ; The input are combinations of 1, 2, 4 with 00 appended to the end ; indicating which pedals are pressed. ; For example, pressing the leftmost pedal triggers input 100, middle pedal 200, etc. ; all three pedals presses together will trigger 700 (1 ^ 2 ^ 4 = 7) ; Release of pedal trigger an input indicating what pedals are still held down input := input//100 If (input > PedalLastPress) PressKey((PedalLastPress & input) ^ input) ; Else ; ReleaseKey((PedalLastPress & input) ^ PedalLastPress) PedalLastPress := input } ; The ControlSend command allows simulated keystrokes to be sent to any running ; program, even if it is running in the background. For more information on how ; it works, see ; For more information on which commands can be sent, and how to format them, ; see PressKey(bits) { SetTitleMatchMode, 2 If (bits & 1) ; left pedal { ;Msgbox Left pedal pressed! ControlSend,,{=}+{Left},VLC media player ;Normalizes playback speed, and rewinds 3 seconds } Else If (bits & 4) ; right pedal { ;Msgbox Right pedal pressed! ControlSend,,{]},VLC media player ;Increases playback speed by 0.1x increments } Else ; center pedal { ;MsgBox Center pedal pressed! ControlSend,,{Space},VLC media player ;Play/pause } } ; The following function should be uncommented & customized to your liking ; if you would like to utilize different actions upon releasing the foot ; pedal buttons ;ReleaseKey(bits) ;{ ; ToolTip Releasing %bits% ; SetTitleMatchMode, 2 ; If (bits & 1) ; MsgBox left pedal up! ; Else If (bits & 4) ; MsgBox Right pedal up! ; Else ; MsgBox Center pedal up! ;} Mem2Hex( pointer, len ) { A_FI := A_FormatInteger SetFormat, Integer, Hex Loop, %len% { Hex := *Pointer+0 StringReplace, Hex, Hex, 0x, 0x0 StringRight Hex, Hex, 2 hexDump := hexDump . hex Pointer ++ } SetFormat, Integer, %A_FI% StringUpper, hexDump, hexDump Return hexDump } ; Keyboards are always Usage 6, Usage Page 1, Mice are Usage 2, Usage Page 1, ; HID devices specify their top level collection in the info block RegisterHIDDevice(UsagePage,Usage) { ; local RawDevice,HWND RIDEV_INPUTSINK := 0x00000100 DetectHiddenWindows, on HWND := WinExist("ahk_class AutoHotkey ahk_pid " DllCall("GetCurrentProcessId")) DetectHiddenWindows, off VarSetCapacity(RawDevice, 8 + A_PtrSize) NumPut(UsagePage, RawDevice, 0, "UShort") NumPut(Usage, RawDevice, 2, "UShort") NumPut(RIDEV_INPUTSINK, RawDevice, 4, "UInt") NumPut(HWND, RawDevice, 8, "UPtr") Res := DllCall("RegisterRawInputDevices", "Ptr", &RawDevice, "UInt", 1, "UInt", 8 + A_PtrSize, "UInt") if (Res = 0) MsgBox, Failed to register for HID Device } InputMessage(wParam, lParam, msg, hwnd) { RID_INPUT := 0x10000003 RIM_TYPEHID := 2 SizeOfHeader := 8 + A_PtrSize + A_PtrSize SizeofRidDeviceInfo := 32 RIDI_DEVICEINFO := 0x2000000b DllCall("GetRawInputData", "Ptr", lParam, "UInt", RID_INPUT, "Ptr", 0, "UIntP", Size, "UInt", SizeOfHeader, "UInt") VarSetCapacity(Buffer, Size) DllCall("GetRawInputData", "Ptr", lParam, "UInt", RID_INPUT, "Ptr", &Buffer, "UIntP", Size, "UInt", SizeOfHeader, "UInt") Type := NumGet(Buffer, 0 * 4, "UInt") Size := NumGet(Buffer, 1 * 4, "UInt") Handle := NumGet(Buffer, 2 * 4, "UPtr") VarSetCapacity(Info, SizeofRidDeviceInfo) NumPut(SizeofRidDeviceInfo, Info, 0) Length := SizeofRidDeviceInfo DllCall("GetRawInputDeviceInfo", "Ptr", Handle, "UInt", RIDI_DEVICEINFO, "Ptr", &Info, "UIntP", SizeofRidDeviceInfo) VenderID := NumGet(Info, 4 * 2, "UInt") Product := NumGet(Info, 4 * 3, "UInt") ; tooltip %VenderID% %Product% if (Type = RIM_TYPEHID) { SizeHid := NumGet(Buffer, (SizeOfHeader + 0), "UInt") InputCount := NumGet(Buffer, (SizeOfHeader + 4), "UInt") Loop %InputCount% { Addr := &Buffer + SizeOfHeader + 8 + ((A_Index - 1) * SizeHid) BAddr := &Buffer Input := Mem2Hex(Addr, SizeHid) If (VenderID = 1523 && Product = 255) ; need special function to process foot pedal input ProcessPedalInput(Input) Else If (IsLabel(Input)) { Gosub, %Input% } } } }

As I am personally running the 32 bit version of AutoHotkey, I have not tested the 64 bit version of the above script.

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-12-23 04:12 最后登录:2025-12-23 04:12
栏目列表
推荐内容