AutoHotkey Community

It is currently May 25th, 2012, 11:24 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 108 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next
Author Message
 Post subject:
PostPosted: January 27th, 2008, 8:27 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
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? :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2008, 4:19 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: diagonals
PostPosted: January 31st, 2008, 7:02 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 7:35 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 8:06 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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. :lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 8:47 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 9:32 am 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 10:39 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2008, 3:11 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2008, 12:32 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2008, 3:11 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2008, 7:48 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
could you elaborate on WH_MOUSE_LL and SetWindowsHookEx


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 1st, 2008, 7:54 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2008, 9:53 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2008, 1:45 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
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



Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 108 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg, tic and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group