 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Icarus
Joined: 24 Nov 2005 Posts: 851
|
Posted: Sun Jan 27, 2008 7:27 pm Post subject: |
|
|
Not missing the point at all, just admiring the script and trying to improve it while still keeping it simple.
Although the diagonals that I have attempted are not a great idea, since it makes unique recognition harder.
The best examples are simple, but if they are not taken to the next step, they just stay examples - no?  |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Mon Jan 28, 2008 3:19 am Post subject: |
|
|
| Icarus wrote: | | I would also suggest to include diagonal as a valid gesture | My mouse gestures script supports diagonals. It's not as simplistic, though. |
|
| Back to top |
|
 |
rodfell
Joined: 05 Oct 2007 Posts: 138 Location: Bundaberg (Bundy), Qld, Australia
|
Posted: Thu Jan 31, 2008 6:02 am Post subject: diagonals |
|
|
| i don't like diagonals in gesture scripts. i think they increase the error rate. an "R" can still be drawn as URDLRD if you really need an R. most of the gestures i use are simple... DR DL UR UL etc |
|
| Back to top |
|
 |
rodfell
Joined: 05 Oct 2007 Posts: 138 Location: Bundaberg (Bundy), Qld, Australia
|
Posted: Thu Jan 31, 2008 6:35 am Post subject: |
|
|
i often use the gesture GDURD . this is how i draw an "h" (to hide windows). i can draw the h fairly easily in a curved or fluent action
d..................................................d
d..................................................d
d..................................................d
d......urrrrr....................................d
d....u.........d.................................durrrrrrrrr
d...u..........d...........compared........du.........d
d..u.............d..............to..............du..........d
du...............d...............................du..........d
du...............d...............................du..........d
d.................d...............................du..........d
if the script allowed for diagonals, it would be far less fluent. The fluency i get with this script is why i wrote it. going up and right as an arc, is far easier than up and right trying to avoid a diagonal. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Thu Jan 31, 2008 7:06 am Post subject: |
|
|
I agree completely. I typically only use two-stroke gestures, with diagonals disabled. When I initially wrote my gestures script, I had no idea what would be best, so I wrote it with support for any number of directions.
I say "two-stroke", but I draw it more like a curve.  |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 1121
|
Posted: Thu Jan 31, 2008 7:47 am Post subject: |
|
|
I'm my own experimentation I found that short (e.g. two stroke) gestures were reliable enough with diagonals. This raises the number of two stroke gestures from 12 to 56, probably more than you'd need.
But complex gestures like letters are much harder to do correctly when you include diagonals. Unless you do them slow and carefully, which misses the main point of gestures, it's very easy to turn a right angle into two 45° angles or vice-versa. |
|
| Back to top |
|
 |
Icarus
Joined: 24 Nov 2005 Posts: 851
|
Posted: Thu Jan 31, 2008 8:32 am Post subject: |
|
|
Agree with all, but heres a thought:
If we define that diagonal must be at least at a certain length (say 40 pixels), we might be able to achieve both accuracy and diagonals.
So, for example, if you draw a circle, it will be recorded as a combination of UDLR since the "diagonal" lines inside the circle are too short to be meaningful, but if you do a distinctive diagonal (e.g. the leg of the R) it will be recorded as 3 (diagonal RD).
So R is URDL3 and can be drawn loosely and with curves.
Just a theoretical suggestion, i am guessing that people who are used to 2 stroke gestures do not need it. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Thu Jan 31, 2008 9:39 am Post subject: |
|
|
I think introducing any dependency on length reduces the efficiency of gestures. True pattern/character recognition could be powerful, but does not belong in a "simple mouse gestures" script.  |
|
| Back to top |
|
 |
michaelJ Guest
|
Posted: Thu Jan 31, 2008 2:11 pm Post subject: |
|
|
I would like to implement it as follows:
back = hold right button and click left button
forward= hold left button and click right button
Is that possible and how? |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Jan 31, 2008 11:32 pm Post subject: |
|
|
| michaelj. that's called mouse rocking. i looked into adding rocking, but as it uses the left mouse button, it is hard to keep it simple. the problem is the only way to have rocking but allow normal left clicking is to use a tilde (~). when you use the tilde, it's hard to stop the left click doing what it normally does (which is a lot). to try without a tilde, means you have to emulate everything the left click would normally do (which is a lot). if autohotkey used a conditional tilde, it would be a lot simpler. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Fri Feb 01, 2008 2:11 am Post subject: |
|
|
| Anonymous wrote: | | if autohotkey used a conditional tilde, it would be a lot simpler. | I disagree. The click needs to be delayed for some amount of time - i.e. to wait for the user to click the other button. Otherwise, a "conditional tilde" effect could be achieved with a mouse hook (keywords: WH_MOUSE_LL, SetWindowsHookEx.) |
|
| Back to top |
|
 |
rodfell
Joined: 05 Oct 2007 Posts: 138 Location: Bundaberg (Bundy), Qld, Australia
|
Posted: Fri Feb 01, 2008 6:48 am Post subject: |
|
|
| could you elaborate on WH_MOUSE_LL and SetWindowsHookEx |
|
| Back to top |
|
 |
rodfell
Joined: 05 Oct 2007 Posts: 138 Location: Bundaberg (Bundy), Qld, Australia
|
Posted: Fri Feb 01, 2008 6:54 am Post subject: gesture now includes left click |
|
|
i have included left clicking now. the adding off wheelup and down and left clicks has slightly bloated things, but not by too much. the addition of left clicking (and double clicking) seems to work very well. | Code: | ;simple mouse gestures call subroutines based on a gesture made when the right button is held down.
;the script tracks up (u) down (d) left (l) right (r) wheelup(+) wheeldown(-) and left mouse click(c). There is a tolerance of +/- 45 degrees, so it is quite simple and accurate
;by not allowing diagonals, gestures can have curves. eg a circle drawn from the top and clockwise is registered as rdlu (right down left up)
;if a gesture is down (d) and right (r), like an "L", a subroutine called gdr ( for gesture down right) will be called
;if anything is labelled as gdr:, the action will be run
;as a further example, if an "S" is drawn (from top to bottom), gldrdl: (gesture left down right down left) will be called
;these 2 examples are included. See below for further examples
CoordMode, Mouse, Screen
winget, window0, id, ahk_class Progman ;window0 is the desktop
hotkey, lbutton, off ;allows normal left click function
rbutton::
hotkey, lbutton, on ;disables normal left click
if (window1<>window0)
window2:=window1 ;window1 is the window underneath the current gesture, window2 is from the previous gesture
mousegetpos,xpos1, ypos1,window1
gesture= ;clear previous tracking results
settimer, gesture, 10
GestureMode = 1
return
rbutton up::
settimer, gesture, off
hotkey, lbutton, off ;re-enables normal left click
GestureMode = 0
gesture := "g" . gesture ;eg. gdr = gesture down right
if islabel(gesture)<>0 ;checks if gesture is labelled
gosub, %gesture% ; eg. gosub, gdr
msgbox,,, %gesture% not yet defined,4
return
gesture:
mousegetpos,xpos2, ypos2
dx:=xpos2-xpos1
dy:=ypos1-ypos2
if (abs(dy)>=abs(dx))
{
if (dy>0)
track=u ;track is up
else
track=d ;down
}
else
{
if (dx>0)
track=r ;right
else
track=l ;left
}
if (abs(dy)<4 and abs(dx)<4)
track= ;not tracking at all if no significant change in x or y
xpos1:=xpos2
ypos1:=ypos2
if (track<>SubStr(gesture, 0, 1)) ;ignore track if not changing since previous track
gesture := gesture . track
return
lbutton:: ;registers a left click. double click if clicked twice
gesture := gesture . "c"
return
WheelUp:: ;Since u and d are taken, we'll use + and - for the mouse wheel.
If GestureMode ;we're currently recording a gesture
{
If (SubStr(gesture, 0) != "+") ;Don't record two wheelups in a row
gesture := gesture . "+"
}
Else ;we're not recording a gesture so just do a wheelup
Sendinput {WheelUp}
Return
WheelDown:: ;ditto for down
If GestureMode
{
If (SubStr(gesture, 0) != "-")
gesture := gesture . "-"
}
Else
Sendinput {WheelDown}
Return
g: ;normal right click
click, right, xpos1, ypos1
exit
;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;
gc:
msgbox,,,rocker,5
exit
glc:
msgbox,,,you gestured left and clicked,5
exit
gu: ;; gesture up ;; maximize window under cursor. maximize last window if cursor over desktop
if (window1=window0)
{
if (window2<>"")
winmaximize, ahk_id %window2%
}
else
winmaximize, ahk_id %window1%
exit
gd: ;minimize window under cursor
if (window1<>window0) ;don't minimize the desktop
winminimize, ahk_id %window1%
exit
gl: ;browser back
winactivate, ahk_id %window1%
sendinput, {Browser_Back}
exit
gr: ;browser forward
winactivate, ahk_id %window1%
sendinput, {Browser_Forward}
exit
gdr: ;restore last window.
winrestore, ahk_id %window2%
exit
gldr: ;close window under cursor (draw a C)
if (window1<>window0)
winclose, ahk_id %window1%
exit
gldrdl:
msgbox, you drew an S
exit
gurdurd:
msgbox, you drew an M
exit
g+:
MsgBox WheelUp
exit
g-:
MsgBox WheelDown
exit
gl+:
MsgBox Left-WheelUp
exit |
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Fri Feb 01, 2008 8:53 am Post subject: |
|
|
| rodfell wrote: | | could you elaborate on WH_MOUSE_LL and SetWindowsHookEx | AutoHotkey uses a low-level mouse hook (WH_MOUSE_LL) to implement mouse hotkeys. The return value of the hook determines whether the mouse message will be passed on to the target window. If you implemented the mouse hook yourself, you'd have full control over when this happens, though it wouldn't be as straightforward as mouse hotkeys.
Documentation (at MSDN) and examples (in the forums) are easy to find, especially since I already pointed out what (keywords) to search for.
Anyway, I meant to point out in my previous post that "conditional tilde" (via the mouse hook) will not be of any benefit. |
|
| Back to top |
|
 |
rodfell
Joined: 05 Oct 2007 Posts: 138 Location: Bundaberg (Bundy), Qld, Australia
|
Posted: Sat Feb 02, 2008 12:45 am Post subject: |
|
|
i have changed the way wheelup and down are used. rather than track wheelup and wheeldown, the script now uses the wheel in a more natural way. for example (see glw example) you can gesture left and if you keep the right button depressed, use the wheel to adjust volume (for example) up and down.
also, i found that using the left mouse click worked more efficiently if it terminated the gesture. for example, if you hold the right button, then click on the left button, the action gc: is run immediately (rather than waiting for the right button to be released) | Code: |
;Simple Mouse Gestures call subroutines based on a gesture made when the right button is held down.
;the script tracks up (u) down (d) left (l) right (r). There is a tolerance of +/- 45 degrees, so it is quite simple and accurate
;by not allowing diagonals, gestures can have curves. eg a circle drawn from the top and clockwise is registered as rdlu (right down left up)
;if a gesture is down (d) and right (r), like an "L", a subroutine called gdr ( for gesture down right) will be called
;if anything is labelled as gdr:, the action will be run
;as a further example, if an "S" is drawn (from top to bottom), gldrdl: (gesture left down right down left) will be called
;these 2 examples are included. See below for further examples
;in addition, gestures can be terminated by a left click (c), which modifies the subroutine called. eg gudc (gesture up down click)
;also, the action of wheelup and wheeldown (w) can be modified depending on gesture. eg if you gesture left, and keep the right button depressed, you can use the wheel (up or down) for any use you define. see glw: example which adjusts volume
CoordMode, Mouse, Screen
winget, window0, id, ahk_class Progman ;window0 is the desktop
hotkey, lbutton, off ;allows normal left click function
rbutton::
hotkey, lbutton, on ;disables normal left click
if (window1<>window0)
window2:=window1 ;window1 is the window underneath the current gesture, window2 is from the previous gesture
mousegetpos,xpos1, ypos1,window1
gesture= ;clear previous tracking results
settimer, gesture, 10
GestureMode = 1
return
rbutton up::
if not gesturemode
return
settimer, gesture, off
hotkey, lbutton, off ;re-enables normal left click
GestureMode = 0
gesture := "g" . gesture ;eg. gdr = gesture down right
if islabel(gesture) ;checks if gesture is labelled
gosub, %gesture% ; eg. gosub, gdr
return
gesture:
if SubStr(gesture, 0)="w" ;if using wheel, this stops mouse drift stopping gesture
return
mousegetpos,xpos2, ypos2
dx:=xpos2-xpos1
dy:=ypos1-ypos2
if (abs(dy)>=abs(dx))
{
if (dy>0)
track=u ;track is up
else
track=d ;down
}
else
{
if (dx>0)
track=r ;right
else
track=l ;left
}
if (abs(dy)<4 and abs(dx)<4)
track= ;not tracking at all if no significant change in x or y
xpos1:=xpos2
ypos1:=ypos2
if (track<>SubStr(gesture, 0, 1)) ;ignore track if not changing since previous track
gesture := gesture . track
return
lbutton:: ;registers a left click. terminates the gesture
gesture := gesture . "c"
gosub, rbutton up ;delete this line if you don't want left clicks to terminate the gesture
gesturemode=0 ;delete this line if you don't want left clicks to terminate the gesture
return
WheelUp::
If GestureMode ;we're currently recording a gesture
{
If (SubStr(gesture, 0) <> "w")
gesture := "g" . gesture . "w"
wheelup=1
if islabel(gesture)
gosub, %gesture%
}
Else ;we're not recording a gesture so just do a wheelup
Sendinput {WheelUp}
Return
WheelDown:: ;ditto for down
If GestureMode
{
If (SubStr(gesture, 0) <> "w")
gesture := "g" . gesture . "w"
wheelup=0
if islabel(gesture)
gosub, %gesture%
}
Else
Sendinput {WheelDown}
Return
g: ;normal right click
click, right, xpos1, ypos1
exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; wheel examples ;;;;;;;;;;
glw: ;change volume with wheel
if wheelup
Send {Volume_Up}
else
Send {Volume_Down}
return ;end wheel gestures with a "return" NOT "exit" !!!!!!!!
;;;;;;;; click examples ;;;;;;;;;;
gc:
msgbox,,,rocker,5
exit ;end all labels (other than wheel gestures) with "exit" NOT "return"
glc:
msgbox,,,you gestured left and clicked,5
exit
;;;;;;;; other examples ;;;;;;;;;;;;;;
gu: ;; gesture up ;; maximize window under cursor. maximize last window if cursor over desktop
if (window1=window0)
{
if (window2<>"")
winmaximize, ahk_id %window2%
}
else
winmaximize, ahk_id %window1%
exit
gd: ;minimize window under cursor
if (window1<>window0) ;don't minimize the desktop
winminimize, ahk_id %window1%
exit
gl: ;browser back
winactivate, ahk_id %window1%
sendinput, {Browser_Back}
exit
gr: ;browser forward
winactivate, ahk_id %window1%
sendinput, {Browser_Forward}
exit
gdr: ;restore last window.
winrestore, ahk_id %window2%
exit
gldr: ;close window under cursor (draw a C)
if (window1<>window0)
winclose, ahk_id %window1%
exit
gldrdl:
msgbox, you drew an S
exit
gurdurd:
msgbox, you drew an M
exit
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|