vital
Joined: 05 Oct 2005 Posts: 17 Location: china
|
Posted: Sun Nov 04, 2007 3:56 pm Post subject: a simple mouse gesture script |
|
|
only 8 gestures. i have a poor english ,so ......
| Code: | #singleinstance force
#noenv
SendMode Input
Rbutton::
MouseGetPos , sposX , sposY
loop
{
if A_TimeSincethisHotkey < 250 ;250ms
{
sleep 10
if !GetKeyState("Rbutton" , "p")
{
MouseGetPos , eposX , eposY
dx := eposx - sposx
dy := eposy - sposy
if (dx = 0 and dy = 0)
{
hotkey ,Rbutton, off
click right ,sposx,sposy
hotkey ,Rbutton, on
}
;\down,between 30° and 60°
else if (dx > 5 and dy > 5 and dy/dx>0.58 and dy/dx <1.73)
ges_send("d2r")
;/down,between 30° and 60°
else if (dx < -5 and dy > 5 and dy/dx>-1.73 and dy/dx < -0.58)
ges_send("d2l")
else if (dx < -5 and abs(dy/dx) < 0.58 ) ;right-->left
ges_send("r2l")
else if (dy > 5 and abs(dx/dy) < 0.58) ;top-->bottom
ges_send("t2b")
else if (dx > 5 and abs(dy/dx) < 0.58) ;left-->right
ges_send("l2r")
else if (dy < -5 and abs(dx/dy) < 0.58) ;bottom-->top
ges_send("b2t")
else if (dx > 5 and dy < -5 and dy/dx>-1.73 and dy/dx < -0.58) ;/up,between 30° and 60°
ges_send("u2r")
else if (dx < -5 and dy < -5 and dy/dx>0.58 and dy/dx <1.73) ;\up,between 30° and 60°
ges_send("u2l")
else
{
hotkey ,Rbutton, off
mouseclickdrag ,right , %sposx% , %sposy%, %eposx% , %eposy%,0
sleep 50
hotkey ,Rbutton, on
}
break
}
else
continue
}
else
{
MouseGetPos , eposX , eposY
hotkey ,Rbutton, off
mousemove , %sposx% , %sposy%,0
click down right %sposx% , %sposy%
mousemove , %eposx% , %eposy%,0
keywait , Rbutton ;after rbutton to be freed
hotkey ,Rbutton, on
break
}
}
return
;action function:according to the gesture type to send the keys
;the action is written to [gesture] section in gesture.ini
ges_send(ges_type)
{
iniread , ges_act, gesture.ini, gesture, %ges_type%
stringsplit ,ges_actarray, ges_act , |,%A_Space%%A_Tab%
loop , %ges_actarray0%
{
if !mod(a_index,2)
continue
ifwinactive % ges_actarray%a_index%
{
sec_index := a_index + 1
send % ges_actarray%sec_index%
break
}
}
return
} |
below is a gesture.ini file
the format is : ges_type=wintitle1|keys1|wintitle2|keys2|wintitle3|keys3, the default wintitle is "A"
| Quote: | [gesture]
d2r=A|^{f4}
d2l=A|#d
r2l=A|!{left}
t2b=A|{enter}
l2r=login ahk_class ThunderForm|vital{tab}mmmmm{enter}|A|^v
b2t=A|#p
u2r=A|!{f4}
u2l=A|{esc} |
|
|