Задам сразу ещё один вопрос, может кто-то знает ответ. Когда менял под себя скрипт делающий из геймпада мышь, решил убрать из него команды, которые некоторые кнопки геймпада делают кнопками мыши. Просто мне достаточно того, чтобы эти команды были в одном скрипте, для первого джойстика, и незачем дублировать их во втором. И тут выяснилось что скрипт открывается только если присутствует строчка:
Hotkey, %JoystickPrefix%%ButtonLeft%, ButtonLeft
Причём не важно для какой кнопки: левой, правой или средней. Нужно чтобы хотя бы для одной было.
При этом вроде бы всё, что указывает на эти кнопки - убрал.
Решил проблему тем что оставил в скрипте для одного джойстика команду на левую клавишу, а во втором - на правую.
Хотя бы нет ненужных повторений.
Но странно, почему?
Вот эти два скрипта:
JoyMultiplier = 0.3
JoyThreshold = 3
InvertYAxis := false
ButtonLeft = 1
JoystickNumber = 1
#SingleInstance
JoystickPrefix = %JoystickNumber%Joy
Hotkey, %JoystickPrefix%%ButtonLeft%, ButtonLeft
JoyThresholdUpper := 50 + JoyThreshold
JoyThresholdLower := 50 - JoyThreshold
if InvertYAxis
YAxisMultiplier = -1
else
YAxisMultiplier = 1
SetTimer, WatchJoystick, 10
GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P
SetTimer, WatchPOV, 5
return
ButtonLeft:
SetMouseDelay, -1
MouseClick, left,,, 1, 0, D
SetTimer, WaitForLeftButtonUp, 10
return
WaitForLeftButtonUp:
if GetKeyState(JoystickPrefix . ButtonLeft)
return
SetTimer, WaitForLeftButtonUp, off
SetMouseDelay, -1
MouseClick, left,,, 1, 0, U
return
WatchJoystick:
MouseNeedsToBeMoved := false
SetFormat, float, 03
GetKeyState, joyx, %JoystickNumber%JoyX
GetKeyState, joyy, %JoystickNumber%JoyY
if joyx > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaX := joyx - JoyThresholdUpper
}
else if joyx < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaX := joyx - JoyThresholdLower
}
else
DeltaX = 0
if joyy > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaY := joyy - JoyThresholdUpper
}
else if joyy < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaY := joyy - JoyThresholdLower
}
else
DeltaY = 0
if MouseNeedsToBeMoved
{
SetMouseDelay, -1
MouseMove, DeltaX * JoyMultiplier, DeltaY * JoyMultiplier * YAxisMultiplier, 0, R
}
return
WatchPOV:
GetKeyState, POV, JoyPOV
KeyToHoldDownPrev = %KeyToHoldDown%
if POV < 0
KeyToHoldDown =
else if POV > 31500
KeyToHoldDown = Up
else if POV between 0 and 4500
KeyToHoldDown = Up
else if POV between 4501 and 13500
KeyToHoldDown = Right
else if POV between 13501 and 22500
KeyToHoldDown = Down
else
KeyToHoldDown = Left
if KeyToHoldDown = %KeyToHoldDownPrev%
return
SetKeyDelay -1
if KeyToHoldDownPrev
Send, {%KeyToHoldDownPrev% up}
if KeyToHoldDown
Send, {%KeyToHoldDown% down}
return
и
JoyMultiplier = 0.015
JoyThreshold = 3
InvertZAxis := false
ButtonRight = 3
JoystickNumber = 1
#SingleInstance
JoystickPrefix = %JoystickNumber%Joy
Hotkey, %JoystickPrefix%%ButtonRight%, ButtonRight
JoyThresholdUpper := 50 + JoyThreshold
JoyThresholdLower := 50 - JoyThreshold
if InvertZAxis
ZAxisMultiplier = -1
else
ZAxisMultiplier = 1
SetTimer, WatchJoystick, 10
ButtonRight:
SetMouseDelay, -1
MouseClick, right,,, 1, 0, D
SetTimer, WaitForRightButtonUp, 10
return
WaitForRightButtonUp:
if GetKeyState(JoystickPrefix . ButtonRight)
return
SetTimer, WaitForRightButtonUp, off
MouseClick, right,,, 1, 0, U
return
WatchJoystick:
MouseNeedsToBeMoved := false
SetFormat, float, 03
GetKeyState, joyr, %JoystickNumber%JoyR
GetKeyState, joyz, %JoystickNumber%JoyZ
if joyr > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaX := joyr - JoyThresholdUpper
}
else if joyr < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaX := joyr - JoyThresholdLower
}
else
DeltaX = 0
if joyz > %JoyThresholdUpper%
{
MouseNeedsToBeMoved := true
DeltaY := joyz - JoyThresholdUpper
}
else if joyz < %JoyThresholdLower%
{
MouseNeedsToBeMoved := true
DeltaY := joyz - JoyThresholdLower
}
else
DeltaY = 0
if MouseNeedsToBeMoved
{
SetMouseDelay, -1
MouseMove, DeltaX * JoyMultiplier, DeltaY * JoyMultiplier * ZAxisMultiplier, 0, R
}
return