将踏板重新绑定到按钮 AHK

Rebinding pedals to buttons AHK

我正在使用 Thrustmaster TMX PRO。我想使用 AHK 将我的踏板更改为按钮。现在我有这个

SetTimer, WatchAxis, 5
return

WatchAxis:
JoyThrottle := GetKeyState("JoyX")  ; Get position of X axis.
JoyBreak := GetKeyState("JoyY")  ; Get position of Y axis.
KeyToHoldDownPrev := KeyToHoldDown  ; Prev now holds the key that was down before (if any).
JoyInfo := GetKeyState("JoyInfo") 
;MsgBox, %JoyInfo%
if (JoyBreak > 45)
    KeyToHoldDown := "Down"
else if (JoyThrottle > 45)
    KeyToHoldDown := "Up"
else
    KeyToHoldDown := ""

if (KeyToHoldDown = KeyToHoldDownPrev)  ; The correct key is already down (or no key is needed).
    return  ; Do nothing.

; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1  ; Avoid delays between keystrokes.
if KeyToHoldDownPrev   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev% up}  ; Release it.
if KeyToHoldDown   ; There is a key to press down.
    Send, {%KeyToHoldDown% down}  ; Press it down.
return

这适用于刹车踏板,但不适用于 throttle.So 我尝试了以下操作: GetKeyState(Joy+"X","Y","Z","RX","RY","RZ","SL0","SL1","R","Z","P","D"(他们都是独立的)

没有结果。我现在的问题是找到按钮。为了找到油门,我尝试了以下操作:

JoyInfo := GetKeyState("JoyInfo") MsgBox, %JoyInfo%

这表明:

有没有人有想法帮我转发一下?

提前致谢!

我理解控制器的最简单方法是使用这个脚本:

(有点老了,现代的ahk语法通常看起来不像那样,但它仍然有效。)

; Joystick Test Script
; https://www.autohotkey.com
; This script helps determine the button numbers and other attributes
; of your joystick. It might also reveal if your joystick is in need
; of calibration; that is, whether the range of motion of each of its
; axes is from 0 to 100 percent as it should be. If calibration is
; needed, use the operating system's control panel or the software
; that came with your joystick.

; July 6, 2005: Added auto-detection of joystick number.
; May 8, 2005 : Fixed: JoyAxes is no longer queried as a means of
; detecting whether the joystick is connected.  Some joysticks are
; gamepads and don't have even a single axis.

; If you want to unconditionally use a specific joystick number, change
; the following value from 0 to the number of the joystick (1-16).
; A value of 0 causes the joystick number to be auto-detected:
JoystickNumber = 0

; END OF CONFIG SECTION. Do not make changes below this point unless
; you wish to alter the basic functionality of the script.

; Auto-detect the joystick number if called for:
if JoystickNumber <= 0
{
    Loop 16  ; Query each joystick number to find out which ones exist.
    {
        GetKeyState, JoyName, %A_Index%JoyName
        if JoyName <>
        {
            JoystickNumber = %A_Index%
            break
        }
    }
    if JoystickNumber <= 0
    {
        MsgBox The system does not appear to have any joysticks.
        ExitApp
    }
}

#SingleInstance
SetFormat, float, 03  ; Omit decimal point from axis position percentages.
GetKeyState, joy_buttons, %JoystickNumber%JoyButtons
GetKeyState, joy_name, %JoystickNumber%JoyName
GetKeyState, joy_info, %JoystickNumber%JoyInfo
Loop
{
    buttons_down =
    Loop, %joy_buttons%
    {
        GetKeyState, joy%A_Index%, %JoystickNumber%joy%A_Index%
        if joy%A_Index% = D
            buttons_down = %buttons_down%%A_Space%%A_Index%
    }
    GetKeyState, JoyX, %JoystickNumber%JoyX
    axis_info = X%JoyX%
    GetKeyState, JoyY, %JoystickNumber%JoyY
    axis_info = %axis_info%%A_Space%%A_Space%Y%JoyY%
    IfInString, joy_info, Z
    {
        GetKeyState, JoyZ, %JoystickNumber%JoyZ
        axis_info = %axis_info%%A_Space%%A_Space%Z%JoyZ%
    }
    IfInString, joy_info, R
    {
        GetKeyState, JoyR, %JoystickNumber%JoyR
        axis_info = %axis_info%%A_Space%%A_Space%R%JoyR%
    }
    IfInString, joy_info, U
    {
        GetKeyState, JoyU, %JoystickNumber%JoyU
        axis_info = %axis_info%%A_Space%%A_Space%U%JoyU%
    }
    IfInString, joy_info, V
    {
        GetKeyState, JoyV, %JoystickNumber%JoyV
        axis_info = %axis_info%%A_Space%%A_Space%V%JoyV%
    }
    IfInString, joy_info, P
    {
        GetKeyState, joyp, %JoystickNumber%JoyPOV
        axis_info = %axis_info%%A_Space%%A_Space%POV%joyp%
    }
    ToolTip, %joy_name% (#%JoystickNumber%):`n%axis_info%`nButtons Down: %buttons_down%`n`n(right-click the tray icon to exit)
    Sleep, 100
}
return

在此处找到:https://www.autohotkey.com/docs/scripts/index.htm#JoystickTest