Тема: AHK: Не рабочий скрипт жестов и пара вопросов
Доброго времени суток. Имеется скрипт жестов мыши, на форуме, вроде, никто не жаловался. Подскажите, пожалуйста, почему он не работает.
DemoText =
(
-- MMHK-Demo 4 --
check out the Tooltip!
It displays the current direction of the mouse movement.
)
OnExit, MMHK_OnExit
MMHK_Start()
MMHK_TriggerLength := 3
MsgBox, %Demotext%
return
#Include MMHK.ahk
MMHK_AllOtherMovements:
CoordMode, ToolTip, Screen
ToolTip , Vector: %MMHK_CurrentVector%`nDirection: %MMHK_CurrentDirection%, 5, 5, 2
return
; MMHK.ahk - Mouse Movement HotKeys (Release 2)
; by Zed_Gecko (using a Mouse-Hook made by Sean)
; MMHK allows you to create hotkey-like labels for mouse movements.
; You can assign actions to any combination of
; Mouse-Movements (8 directions supported)
; & Prefix-Key (Win, Ctrl, Alt, Shift)
; & MouseButton (Left, Middle, Right)
; -- ATTENTION! --
; Don´t include in the auto-execute section
; -- USAGE --
; use MMHK_Start() to init Mouse Movement Hotkeys
; call MMHK_Stop() before closing the script
; u can use OnExit, MMHK_OnExit in your Script instead
; -- supported "HotKey"-Labels --
;u can use the Mouse Movement labels (almost) like usual hotkeys:
; e.g.:
; up:
; up_right:
; right:
; down_right:
; down:
; down_left:
; left:
; up_left:
; LButton_up:
; LButton_up_left:
; RButton_up:
; MButton_up:
; LButton_RButton_up:
; LButton_RButton_MButton_up:
; #up:
; !up:
; ^up:
; +up:
; !^LButton_up:
; #!^+LButton_RButton_MButton_up_left:
;
; basicly all combinations of Movement, Mouse-Button and Modifier-Key will work, but
; the need to be written in the right order.
; The order is: # ! ^ + LButton_ RButton_ MButton_ [direction]
; all Mouse-Buttons must have the "_" at the end, the Modifer-Symbols must not.
; in addition you can use
; MMHK_AllOtherMovements:
; thisLabel will be called if there is no Mouse Movement label for the current action.
; -- usefull VARIABLES --
; MMHK_TriggerLength -> the amount of Pixels the mouse must move to trigger a Mouse Movement HotKey
; u can change it´s value to any thing between 3 and 1000, default is 100
; MMHK_ThisHotkey -> The Label of the Mouse Movement HotKey that is currently detected, even if not defined
; MMHK_PrevHotkey -> The Label of the Mouse Movement HotKey that was detected before the currently detected one.
; MMHK_PrePrevHotkey -> The Label of the Mouse Movement HotKey that was detected before MMHK_PrevHotkey
; MMHK_PrePrePrevHotkey -> The Label of the Mouse Movement HotKey that was detected before MMHK_PrePrevHotkey
; MMHK_PrePrePrePrevHotkey -> The Label of the Mouse Movement HotKey that was detected before MMHK_PrePrePrevHotkey
; MMHK_CurrentDirection -> The direction of the current mouse movement. e.g. "up" or "down_left"
; MMHK_CurrentVector -> The direction of the current mouse movement in radians. (a float between -pi & +pi. 0 is left, -pi & +pi is right)
#Persistent
return
MMHK_OnExit:
MMHK_Stop()
ExitApp
return
MMHK_HotKeyHandler:
MMHK_HandlerActive = Off
MMHK_HotKeyHandlerFunc()
MMHK_HandlerActive := -1
return
MMHK_Start()
{
MMHK_idHook := 14
MMHK_pfn := RegisterCallback("MMHK_MouseMove", "Fast")
MMHK_hHookMouse := DllCall("SetWindowsHookEx", "int", MMHK_idHook, "Uint", MMHK_pfn, "Uint", DllCall("GetModuleHandle", "Uint", 0), "Uint", 0)
MMHK_Stop(MMHK_hHookMouse)
Return MMHK_hHookMouse
}
MMHK_Stop(MMHK_hHook = "off")
{
static MMHK_hHookStatic
if (MMHK_hHook != "off")
{
MMHK_hHookStatic := MMHK_hHook
Return MMHK_hHookStatic
}
else
Return DllCall("UnhookWindowsHookEx", "Uint", MMHK_hHookStatic)
}
MMHK_MouseMove(MMHK_nCode, MMHK_wParam, MMHK_lParam)
{
MMHK_NH := DllCall("CallNextHookEx", "Uint", 0, "int", MMHK_nCode, "Uint", MMHK_wParam, "Uint", MMHK_lParam)
global MMHK_HandlerActive
If !MMHK_nCode && (MMHK_wParam = 0x200)
{
SetTimer, MMHK_HotKeyHandler, %MMHK_HandlerActive%
}
Return MMHK_NH
}
MMHK_HotKeyHandlerFunc()
{
static MMHK_OldX, MMHK_OldY, MMHK_Hotkey, MMHK_HKLength, MMHK_THK, MMHK_PHK, MMHK_PPHK, MMHK_PPPHK, MMHK_PPPPHK, MMHK_PI := 3.141592653589793
global MMHK_TriggerLength, MMHK_CurrentVector, MMHK_CurrentDirection ,MMHK_ThisHotkey, MMHK_PrevHotkey, MMHK_PrePrevHotkey, MMHK_PrePrePrevHotkey, MMHK_PrePrePrePrevHotkey
CoordMode, Mouse, Screen
MouseGetPos, MMHK_X, MMHK_Y
MMHK_NewKeys =
if GetKeyState("LWin") || GetKeyState("RWin")
MMHK_NewKeys .= "#"
if GetKeyState("LAlt") || GetKeyState("RAlt")
MMHK_NewKeys .= "!"
if GetKeyState("LControl") || GetKeyState("RControl")
MMHK_NewKeys .= "^"
if GetKeyState("LShift") || GetKeyState("RShift")
MMHK_NewKeys .= "+"
if GetKeyState("LButton")
MMHK_NewKeys .= "LButton_"
if GetKeyState("RButton")
MMHK_NewKeys .= "RButton_"
if GetKeyState("MButton")
MMHK_NewKeys .= "MButton_"
MMHK_XDiff := MMHK_X - MMHK_OldX
MMHK_YDiff := MMHK_Y - MMHK_OldY
MMHK_OldX := MMHK_X
MMHK_OldY := MMHK_Y
MMHK_Distance := ( ((MMHK_XDiff) ** 2) + ((MMHK_YDiff) ** 2) ) ** 0.5
MMHK_Vector := ( ASin( MMHK_XDiff / MMHK_Distance ) + (MMHK_PI / 2) ) * ( (MMHK_YDiff < 0) ? 1 : -1)
MMHK_NewDir =
loop, 1
{
if ( MMHK_Vector > (7 / 8 * MMHK_PI)) || ( MMHK_Vector < (7 / 8 * MMHK_PI * -1))
{
MMHK_NewDir = right
break
}
if ( MMHK_Vector > (5 / 8 * MMHK_PI))
{
MMHK_NewDir = up_right
break
}
if ( MMHK_Vector > (3 / 8 * MMHK_PI))
{
MMHK_NewDir = up
break
}
if ( MMHK_Vector > (1 / 8 * MMHK_PI))
{
MMHK_NewDir = up_left
break
}
if ( MMHK_Vector > (1 / 8 * MMHK_PI * -1))
{
MMHK_NewDir = left
break
}
if ( MMHK_Vector > (3 / 8 * MMHK_PI * -1))
{
MMHK_NewDir = down_left
break
}
if ( MMHK_Vector > (5 / 8 * MMHK_PI * -1))
{
MMHK_NewDir = down
break
}
MMHK_NewDir = down_right
}
MMHK_NewHotkey := MMHK_NewKeys . MMHK_NewDir
if ( MMHK_NewHotkey = MMHK_Hotkey )
MMHK_HKLength += MMHK_Distance
else
{
MMHK_Hotkey := MMHK_NewHotkey
MMHK_HKLength := MMHK_Distance
}
if ((MMHK_TriggerLength < 3) || (MMHK_TriggerLength > 1000))
{
MMHK_TriggerLength := 100
}
MMHK_CurrentVector := MMHK_Vector
MMHK_CurrentDirection := MMHK_NewDir
if ( MMHK_HKLength > MMHK_TriggerLength )
{
MMHK_HKLength := 0
MMHK_PPPPHK := MMHK_PPPHK
MMHK_PPPHK := MMHK_PPHK
MMHK_PPHK := MMHK_PHK
MMHK_PHK := MMHK_THK
MMHK_THK := MMHK_Hotkey
MMHK_PrePrePrePrevHotkey := MMHK_PPPPHK
MMHK_PrePrePrevHotkey := MMHK_PPPHK
MMHK_PrePrevHotkey := MMHK_PPHK
MMHK_PrevHotkey := MMHK_PHK
MMHK_ThisHotkey := MMHK_THK
if IsLabel(MMHK_Hotkey)
{
SetTimer, %MMHK_Hotkey%, -1
}
else
{
MMHK_AOM := "MMHK_AllOtherMovements"
if IsLabel(MMHK_AOM)
{
SetTimer, %MMHK_AOM%, -1
}
}
}
}
Ссылку оригинального скрипта из темы на форуме удалили. Возможно, этот скрипт уже был изменён.
Лирическое отступление. Я инвалид первой группы, работает только голова. Мышь у меня во рту с тремя кнопками и колесом. Других клавиш нажимать для меня не возможно. Жесты очень сильно расширяют мои возможности. И недавно начал знакомится с АНK, ввиду того что даёт контролируемые возможности управления в отличии от готовых программ таких как ComfortKeys, StrokesPlus и подобных.
И вот несколько вопросов уважаемым гуру:
1. Есть ли возможность в подобных скриптах назначить отправку клавиш только при движении мыши без нажатия кнопок. Как я понимаю все подобные программы и скрипты сохраняют переменные при нажатии и со временем сравнивают. Можно ли избежать этого? Пример веду курсор влево отправляется А, вправо D и т.д.
2. Есть ли возможность открывать Гуй с кнопками в зависимости от приложений при нажатие колеса в таком виде
от центра нажатия, при этом сохраняя посыл самой кнопки колеса.