Hello R3gX, after playing a bit with this new script I'm very happy.
The mouse gesture detection works perfectly, really.Never missed one, always detected the correct sequence of movements.
As a side note, I messed up a little with the code and now I have this issue: if I perform a tiny movement like 3-4 pixels the gesture code is triggered, without being fed with direction tags (the letters U D L R).
About the GUI, well, I simply don't like it because I find it too intrusive.
That squarish words feel very DOS like, and that's not what I expect from a program in 2011.
I tried to remove GUI instructions from the script, and I guess it was successful.
My suggestion is - when a gesture is detected - just display a tooltip telling which command is being performed. Let it last one second and disappear, that's all.
Another thing I would change is the external file commands.ini; I think it could be integrated inside the main script, maybe just creating a commented caption to separate the section from others.
This is the stripped down version I just tested, mainly to understand how MGR works. Lacking all actual commands and actions right now...
AutoHotkey.ahk
;
; Begin auto-execute section
;
#Include %A_ScriptDir%\MGR.ahk
SetBatchLines, -1
#SingleInstance force
#NoEnv
SetTitleMatchMode, RegEx
CoordMode, Mouse, Screen
Process, Priority, , H
SendMode Input
SetTimer, RepeatingActions, 500
Return
;
; End auto-execute section
;
;======================================
; R E P E A T I N G A C T I O N S
;======================================
RepeatingActions:
WinSet, Style, -0xC40000, ahk_class TTOTAL_CMD
WinMove, ahk_class TTOTAL_CMD,,0,0,1535,900
WinSet, Style, -0xC40000, ahk_class NOTES
WinMove, ahk_class NOTES,,0,0,1535,900
WinSet, Style, -0xC40000, ahk_class SAP_FRONTEND_SESSION
WinMove, ahk_class SAP_FRONTEND_SESSION,,0,0,1535,900
WinSet, Style, -0xC40000, ahk_class XmainClass
WinMove, ahk_class XmainClass,,0,0,1535,900
WinSet, Style, -0xC40000, ahk_class QWidget
WinMove, ahk_class QWidget,,0,0,1535,900
WinSet, Style, -0xC40000, ahk_class MRCC_Class
WinMove, ahk_class MRCC_Class,,0,0,1535,900
WinSet, Style, -0xC40000, ahk_class XTPMainFrame
WinMove, ahk_class XTPMainFrame,,0,0,1535,900
WinSet, Style, -0xC00000, ahk_class DSUI:PDFXCViewer
WinSet, Style, -0xC00000, ahk_class Photo_Lightweight_Viewer
WinSet, AlwaysOnTop, On, ahk_class CalcFrame
return
;=====================================
; M O U S E W H E E L M O D S
;=====================================
WheelLeft::
Send ^+{Tab}
return
WheelRight::
Send ^{Tab}
return
~MButton::
If (A_PriorHotkey = A_ThisHotkey AND A_TimeSincePriorHotkey < 400)
WinClose A
Return
;====================================================
; R I G H T M O U S E B U T T O N M O D S
;====================================================
*RButton::
MouseGetPos, mX1, mY1
Loop
{
Sleep, 10
MouseGetPos, mX2, mY2
}
Until (!GetKeyState("RButton", "P") || Abs(mX2-mX1)>3 || Abs(mY2-mY1)>3 || (A_TimeSinceThisHotkey > 350))
if A_TimeSinceThisHotkey > 350
{
MouseMove, 650, 514
Send ^!{Tab}
KeyWait, RButton
Send, {LButton}
Return
}
If (Abs(mX2-mX1)<4 && Abs(mY2-mY1)<4)
{
Send, {RButton}
Return
}
Else
{
Gesture := mgr_MonitorGesture()
MsgBox,,,Gesture = %gesture%,1
}
Return
;==================================
; F U L L S C R E E N M O D E
;==================================
^+F11:: ; Trigger is CTRL+SHIFT+F11
WinSet, Style, -0xC40000, A
WinMove, A,,0,0,1535,900
return
;================================
; P R E C I S I O N M O D E
;================================
;
; Activation keeping CapsLock pressed with left hand
;
CapsLock::
Keywait, CapsLock, T0.75
if ErrorLevel
{
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, 1, UInt, 0)
Send #{NumpadAdd}
KeyWait, CapsLock
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, 15, UInt, 0)
WinClose, ahk_class MagUIClass
}
else
{
SetCapsLockstate,% GetKeyState("CapsLock","T") ? "Off":"On"
KeyWait, CapsLock
}
Return
;
; Activation keeping ScrollLock pressed with right hand
;
ScrollLock::
Keywait, ScrollLock, T0.75
if ErrorLevel
{
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, 1, UInt, 0)
Send #{NumpadAdd}
KeyWait, ScrollLock
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, 15, UInt, 0)
WinClose, ahk_class MagUIClass
}
else
{
SetScrollLockState,% GetKeyState("ScrollLock","T") ? "Off":"On"
KeyWait, ScrollLock
}
Return
;============================================
; A P P L I C A T I O N S P E C I F I C
;============================================
;
; MOZILLA FIREFOX
;
#IfWinActive Google Reader
PgDn::
Send +{n}
Send +{o}
Return
PgUp::
Send +{p}
Send +{o}
Return
#IfWinActive
#IfWinActive ahk_class MozillaWindowClass
Control::
If (A_PriorHotkey = A_ThisHotkey AND A_TimeSincePriorHotkey < 350)
Send ^{Tab}
Return
Shift::
If (A_PriorHotkey = A_ThisHotkey AND A_TimeSincePriorHotkey < 350)
Send ^+{Tab}
Return
~MButton::
If (A_PriorHotkey = A_ThisHotkey AND A_TimeSincePriorHotkey < 400)
Send, ^w
Return
#IfWinActive
;
; MICROSOFT PICTURE VIEWER
;
#IfWinActive ahk_class Photo_Lightweight_Viewer
PgDn::
WheelDown::
#IfWinActive ahk_class Photo_Slideshow_FrameWindow
PgDn::
WheelDown::
Send {Right}
Return
#IfWinActive ahk_class Photo_Lightweight_Viewer
PgUp::
WheelUp::
#IfWinActive ahk_class Photo_Slideshow_FrameWindow
PgUp::
WheelUp::
Send {Left}
Return
#IfWinActive ahk_class Photo_Lightweight_Viewer
Esc::
#IfWinActive ahk_class Photo_Slideshow_FrameWindow
Esc::
Send !{F4}
Return
#IfWinActive
MGR.ahk
mgr_GetModifiers()
{ ; Simple way to get hotkey modifiers
Modifiers := ""
Modifiers .= GetKeyState("Ctrl", "P") ? "^" : ""
Modifiers .= GetKeyState("Alt", "P") ? "!" : ""
Modifiers .= GetKeyState("Shift", "P") ? "+" : ""
Modifiers .= GetKeyState("LWin", "P") ? "#" : ""
Return, Modifiers
}
mgr_MonitorGesture()
{ ; Monitor the mouse directions to get the gesture
While GetKeyState("RButton", "P")
{
MouseGetPos, x1, y1
While GetKeyState("RButton", "P")
{
Sleep, 10
MouseGetPos, x2, y2
Module := Sqrt((x2-x1)**2+(y2-y1)**2)
If (Module>=25) ; A minimal movement is needed
{
Direction := mgr_GetDirection(x2-x1, y2-y1)
If (Direction && LastDirection && Direction<>LastDirection) ; If the direction has changed,
Break ; get the next direction
x1 := x2 , y1 := y2
}
LastDirection := Direction ; Usefull to know if the direction has changed
}
Directions .= "-" LastDirection ; Add the last movement to have a complete gesture
LastDirection := Direction := ""
}
Directions .= Direction
Return, mgr_RemoveDups(Directions, "-")
}
mgr_GetDirection(X_Offset, Y_Offset)
{ ; Get the direction of the mouse movement depending on polar coordinates
Directions := 8
Deg := (360/Directions) ; Degree value that "cuts" RingMenu in equal slices
Module := Sqrt((X_Offset**2)+(Y_Offset**2)) ; Distance between the center and the mouse cursor
Argument := ACos(X_Offset/Module)*(180/(4*ATan(1))) ; Angle between the mouse and the X-axis from the center
Argument := (Y_Offset<0 ? 360-Argument : Argument) ; (Screen Y-axis is inverted)
Argument -= Mod(Directions, 2) ? 0 : Deg/2 ; Allows vertical/horizontal movement from the first slice
Direction := Directions-Mod(Floor(Argument/Deg), Directions) ; Converts the argument into a slice number
Direction := Direction>Directions ? 1 : Direction
Direction := Direction=1 ? "R"
: Direction=2 ? "UR"
: Direction=3 ? "U"
: Direction=4 ? "UL"
: Direction=5 ? "L"
: Direction=6 ? "DL"
: Direction=7 ? "D"
: Direction=8 ? "DR"
: ""
Return, Direction
}
mgr_RemoveDups(list1, separator="")
{ ; Remove duplicated follwing values
Loop, Parse, list1, % separator
{
list2 .= (A_LoopField<>Last_LoopField) ? separator A_LoopField : ""
Last_LoopField := A_LoopField
}
Return % Trim(list2, separator)
}