AutoHotkey Community

It is currently May 26th, 2012, 5:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 108 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Author Message
 Post subject:
PostPosted: February 27th, 2009, 6:26 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
bug fix. if 2 different mouse buttons were released at the same time, after the multiclick sleep, the a_thishotkey info was wrong. seems, to me, quite stable now. also now distinguishing the gesture, which is the tracking of the mouse, from the action that is called - the macro. as such, have renamed labels from gxxx to mxxx, and renamed a few variables etc.
Code:
multiclicktime=300    ; set to 0 if you don't want double/triple/multi clicking. otherwise set as fast as you can double-click
rockinstant:=false       ; if true, rocking action fires on downclick (which is faster) but stops further tracking
sensitivity=4      ; adjust if required. if too low, a simple "down/up" gesture (V) might be recorded as "down/right/up" (U)
demomode:=true      ; demonstration mode on/off

coordmode,mouse,screen
winget,windowD,id,ahk_class Progman   ;windowD is the desktop
gosub cleanup
return

#MaxThreadsPerHotkey 5    ; needed when multiclicking
browser_search::          ; "find" key on logitech mx620 mouse, used here as an example
lbutton::
rbutton::
mbutton::      ; list whatever mouse buttons you want tracked.
xbutton1::         ;  works best if all available listed
xbutton2::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)   ;buttons named from initial except xbutton2
stringreplace,buttonsdown,buttonsdown,l,,all
buttonsdown.=thishotkey . (getkeystate("lbutton","p") ? "l" : "") 
gosub multiclick
mcalled=0      ; records if the macro has been called to avoid unintended double-click double calls
winget,windowA,id,A     ; windowA is the active window, useful for some gestures
hotkey,lbutton,on         ; disables normal left click during gesture
hotkey,lbutton up,off   ; prevents next line of code from calling on lbutton up
click up      ; prevents drag box appearing when left/right rocking and gesturing eg. gl/r(d)
hotkey,lbutton up,on
if (window1<>windowD)     
   window2:=window1         ; used in some gestures, window2 is the window the previous gesture acted on           
mousegetpos xpos1,ypos1,window1   ; window1 is the window underneath the current gesture
if gtracking
   {
   gosub trackassign
   record.=(getkeystate("lbutton","p") and not record ? "l/" : "") . (record and thishotkey<>substr(record,0,1) ? "/" : "") . thishotkey
   settimer,gtrack,10          ; "/" is the rocking symbol
   }                          
else
   {
   gosub parserecord   ; finds position of last "/" in record for next line of code
   record:=regexreplace(record,"/\w*","/" . thishotkey . multitrack,position,1,position)   ; allows rocking with different buttons
   }      ; why "\w*"? \w* may represent a single, double or multiclick, but not a parenthesis eg /r, /rr, /rrr, as in gl/rrr(ud)
if instr(record,thishotkey . "/") or not instr(buttonsdown,substr(record,1,1))
   {
   gosub cleanup      ; cleanup if otherwise fatal errors detected
   return      
   }
if rock()="rocking" and rockinstant
   {            ; calls action before mouse button released (rockinstant is user defined)
   rockdown:=thishotkey        ; advantage - faster action
   goto rbutton up           ; disadvantage - gesture called so no more tracking      
   }            
rockdown=
return

browser_search up::      
rbutton up::
lbutton up::
mbutton up::
xbutton1 up::
xbutton2 up::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)
if a_thishotkey contains up
   {
   stringreplace,buttonsdown,buttonsdown,%thishotkey%,,all
   if (rockdown=thishotkey)
      return
   }
buttonsup.=thishotkey
multiclick:=false
if not gtrack   ; no need for delay to check for multiclick if button released after gesture tracking
   sleep % multiclicktime-a_tickcount+mtime1  ;delay to check for multiclick
if not buttonsup or multiclick
   return
thishotkey:=substr(buttonsup,1,1)
stringreplace,buttonsup,buttonsup,%thishotkey%,,all
gtracking:=false  ; no more gesture tracking once a mouse button has been released (unless multiclicking)
gosub trackassign
cleanup:=(rock()<>"rocking") ? true : false   ; this allows for repeat rocking   
callmacro:=not wheel and record and not (rock()="rockover" and mcalled) ? true : false
if cleanup         ; these lines allow for cleanup before the gesture action is called.
   gosub cleanup      ; (note that the gesture itself is not erased by the cleanup). this prevents a called
if callmacro         ;  action that takes a significant time stopping further tracking.
   gosub callmacro   
return            
#maxthreadsperhotkey 1      ; autohotkey default setting. set to your usual setting       

callmacro:
mcalled:=true
gesture.=(wheel ? "-" : "") . wheel
if demomode
   msgbox,,Demo,%gesture%, % (wheel ? .5 : strlen(gesture)/5+1)
else
   if islabel(gesture)   ; checks if gesture is labelled
         gosub %gesture%
return

cleanup:
hotkey,lbutton,off             ; restore normal left mouse button function
hotkey,lbutton up,off
settimer,gtrack,off
record=
wheel=
gtracking:=true
gtrack=
return

gtrack: 
critical off      ; don't want this getting in way of double-click checking
mousegetpos xpos2,ypos2
track:=(abs(ypos1-ypos2)>=abs(xpos1-xpos2)) ? (ypos1>ypos2 ? "u" : "d") : (xpos1>xpos2 ? "l" : "r")  ;determines up down left right
if (abs(ypos1-ypos2)>sensitivity or abs(xpos1-xpos2)>sensitivity) and (track<>SubStr(gtrack, 0, 1)) ;track if x or y changing and direction changing
   gtrack.=track
xpos1:=xpos2
ypos1:=ypos2
return

parserecord:      ; script allows for rocking more than once eg gr/l/x:
loop,parse,record        ; finds position of last "/"
   if a_loopfield=/
      position:=a_index
return

multiclick:
mtime2:=mtime1      ; why use time difference and not keywait? in the time between the 2 clicks, you don't want to miss any
mtime1:=a_tickcount   ;  gtracking. the gesture gr(u) can be all over in less time than a double click takes
if (thishotkey=substr(record,0,1) and mtime1-mtime2<multiclicktime)
   {
   multiclick:=true
   multitrack.=thishotkey
   }
else
   {         ; avoids rocking errors when time between clicks is too short
   multiclick:=false
   multitrack=
   }
return

trackassign:
settimer,gtrack,off
if gtrack               ; letters enclosed in parentheses
   record.="(" . gtrack . ")"      ;  are gesture directions 
gtrack=               
gesture:="m" . record
return

esc::
exitapp
return

wheelup::
wheeldown::
wheel:=a_thishotkey
if record and gtracking   
      {
   gosub trackassign   
      gosub callmacro
   }
if not record
   sendinput {%wheel%}
return

rock()
{
global
if record contains /      ; "/" is the rocking symbol
   {
   gosub parserecord   ; "position+1" is the first letter after the forward slash
   if (thishotkey=substr(record,position+1,1))
         return "rocking"
   else
      return "rockover"   ; in the button up section, if the button down and
               ;  the button up don't match, rocking is finished
   }
}

mr:          ;normal right click
click right,xpos1,ypos1
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; wheel examples ;;;;;;;;;;

mr-wheelup:      ;change volume with wheel -  hold right button down and use wheel
Send {Volume_Up}
return

mr-wheeldown:
Send {Volume_Down}
return 

;;;;;;;; multi click examples ;;;;;;;;;;

mrr:
msgbox,,,double right click,5
return

mrr(l):
msgbox,,,double right click then gesture left ,5
return

mrr/ll:
msgbox,,,double right click then rock with double right ,5
return

mr/l/m:
msgbox,,,right click then rock with left and then middle ,5
return

;;;;;;;; rocker examples ;;;;;;;;;;

mr/l:
msgbox,,,keep right held down and click left will repeat action,5
return

ml/r:                                           
msgbox,,,rocker left then right. careful where you click,5
return

mr(l)/l:
msgbox,,,you gestured left and clicked,5
return

;;;;;;;;;;;; 4th mouse button example ;;;;;;;;;;

mx(l):
msgbox,,,you've gestures left with the 4th mouse button,5
return

mx/r:
msgbox,,,rocker 4th button then right,5
return

mr/x:
msgbox,,,rocker right then 4th button,5
return

;;;;;;;; other examples ;;;;;;;;;;;;;;

mr(u):             ;; gesture up ;; maximize window under cursor. maximize last window if cursor over desktop
if (window1=windowD)
   {
   if (window2<>"")
   winmaximize, ahk_id %window2%
   }
else
   winmaximize ahk_id %window1%
return

mrd:            ;minimize window under cursor
if (window1<>windowD)    ;don't minimize the desktop
   winminimize, ahk_id %window1%
return

mr(l):            ;browser back
winactivate ahk_id %window1%   
sendinput {Browser_Back}
return

mr(r):            ;browser forward
winactivate ahk_id %window1%   
sendinput {Browser_Forward}
return

mr(dr):            ;restore last window.
winrestore ahk_id %window2%
return

mr(ldr):            ;close window under cursor (draw a C)
if (window1<>windowD)
   winclose ahk_id %window1%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2009, 9:46 am 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
this sir, is nothing short of a swift stroke of genius in the making! it's certainly an honor to have any part to play as you say, even if it's just to give some extra incentive to whip up a binary storm, online, in line to time 2009. jeeez, I so hope it gets the credit it's certainly due. we're spoiled for choice these days. so much it seems next to impossible to just settle on something that works. this works. not just coz it's feature rich to cater for the rocker/gesture happy. but coz it's tight, tidy, modest on resources, robust, yet friendly enough for a non-coder, this poster, to fathom and work with. it's cool how your not letting it get top heavy, yet extending functionality exponentially.
had some woes with the regular scroll wheel causing the script to lose focus and requiring a second gesture or rocker to bring it back in check. this was just using windows generic drivers however and it's been sorted using setpoint software alongside uberoptions.
*okay, so backing up a touch, seems I was a tit bit quick off the gun in the assumption there's still this issue to take issue concerning ye ol defecto scroll wheel up and down movements.
seems they take focus away from ahk, and a second gesture or rocker is required to get the whole show back on the road. alas it's short lived as another scroll to move up or down the page snatches ownership and attention off of the gesture script.
tried a fair few flavors now, windows generic driver on it's own, setpoint 4.70 on it's own, setpoint with uberoptions, setting wheelup::wheelup within the script, setting it to pgup, using universal scroll in uberoptions, using generic, switching it off altogether. anything I try meets with the same outcome unless I switch in uberoptions the scroll wheel to be the up/down key. this has the counter strike of being too slow to scroll and flips the wheel the other way anyway, back to front basically....
sheeesh, I've been at this for a while, prolly just missing something obvious that can be set in the script. I hope so coz tried the same on my thinkpad laptop with it's scrolling function, it works as it should no probs whatsoever.
anyway, I'll have to come back to it later, but if there's any suggestions as to what could be causing the loss in function following scrolling with the wheel and having to gesture twice to bring back control, I'd much appreciate your opinion.
incidentally, middle click seems to have lost it's way also, which is the second function of the scroll wheel on my logitech trackman wheel. can't be a hardware fault coz I have two of these babies and both have the same issue that needs given the once around if ya happen to know which way to go though.
nice one, I'll jump back to the former code for now just to see me through until the work around is found, prolly just an oversight on my part, but I can't see for looking at this point so best be getting on.
thanks now rodfell, proper good job though I must say.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2009, 12:02 pm 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
can you elaborate on what happens when you have wheel problems. try the slightly altered code below first tho. the middle button seems to work ok for me. can you elaborate on what happens.
Code:
multiclicktime=300    ; set to 0 if you don't want double/triple/multi clicking. otherwise set as fast as you can double-click
rockinstant:=false       ; if true, rocking action fires on downclick (which is faster) but stops further tracking
sensitivity=4      ; adjust if required. if too low, a simple "down/up" gesture (V) might be recorded as "down/right/up" (U)
demomode:=true      ; demonstration mode on/off

coordmode,mouse,screen
winget,windowD,id,ahk_class Progman   ;windowD is the desktop
gosub cleanup
return

#MaxThreadsPerHotkey 5    ; needed when multiclicking
browser_search::          ; "find" key on logitech mx620 mouse, used here as an example
lbutton::      
rbutton::      ; list whatever mouse buttons you want tracked.
mbutton::      ; works best if all available listed
xbutton1::         ; lbutton only tracked when other mouse buttons start tracking
xbutton2::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)   ;buttons named from initial except xbutton2
buttonsdown.=thishotkey . (getkeystate("lbutton","p") ? "l" : "") 
gosub multiclick
mcalled=0      ; records if the macro has been called to avoid unintended double-click double calls
winget,windowA,id,A     ; windowA is the active window, useful for some gestures
hotkey,lbutton,on         ; disables normal left click during gesture
hotkey,lbutton up,off   ; prevents next line of code from calling on lbutton up
click up      ; prevents drag box appearing when left/right rocking and gesturing eg. m-l/r(d)
hotkey,lbutton up,on
if (window1<>windowD)     
   window2:=window1         ; used in some gestures, window2 is the window the previous macro acted on           
mousegetpos xpos1,ypos1,window1   ; window1 is the window underneath the current gesture
if gtracking
   {
   gosub trackassign
   record.=(getkeystate("lbutton","p") and not record ? "l/" : "") . (record and thishotkey<>substr(record,0,1) ? "/" : "") . thishotkey
   settimer,gtrack,10          ; "/" is the rocking symbol
   }                          
else
   {
   gosub parserecord   ; finds position of last "/" in record for next line of code
   record:=regexreplace(record,"/\w*","/" . thishotkey . multitrack,position,1,position)   ; allows rocking with different buttons
   }      
if instr(record,thishotkey . "/") or not instr(buttonsdown,substr(record,1,1))
   {
   gosub cleanup      ; cleanup if otherwise fatal errors detected
   return      
   }
if rock()="rocking" and rockinstant
   {            ; calls action before mouse button released (rockinstant is user defined)
   rockdown:=thishotkey        ; advantage - faster action
   goto rbutton up           ; disadvantage - gesture called so no more tracking      
   }            
rockdown=
return

browser_search up::      
rbutton up::
lbutton up::
mbutton up::
xbutton1 up::
xbutton2 up::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)
if a_thishotkey contains up
   {
   stringreplace,buttonsdown,buttonsdown,%thishotkey%,,all
   if (rockdown=thishotkey)
      return
   }
buttonsup.=thishotkey
multiclick:=false
if not gtrack   ; no need for delay to check for multiclick if button released after gesture tracking
   sleep % multiclicktime-a_tickcount+time1  ;delay to check for multiclick
if multiclick or not buttonsup
   return
thishotkey:=substr(buttonsup,1,1)
stringreplace,buttonsup,buttonsup,%thishotkey%,,all
gtracking:=false  ; no more gesture tracking once a mouse button has been released (unless multiclicking)
gosub trackassign
cleanup:=(rock()<>"rocking") ? true : false   ; this allows for repeat rocking   
callmacro:=not wheel and record and not (rock()="rockover" and mcalled) ? true : false
if cleanup         ; these lines allow for cleanup before the macro action is called.
   gosub cleanup      ; (note that the gesture itself is not erased by the cleanup). this prevents a called
if callmacro         ;  action that takes a significant time stopping further tracking.
   gosub callmacro   
return            
#maxthreadsperhotkey 1      ; autohotkey default setting. set to your usual setting       

callmacro:
mcalled:=true
macro.=(wheel ? "-" : "") . wheel
if demomode
   msgbox,,Demo,%macro%, % (wheel ? .5 : strlen(gesture)/5+1)
else
   if islabel(macro)   ; checks if macro is labelled
         gosub %macro%
return

cleanup:
hotkey,lbutton,off             ; restore normal left mouse button function
hotkey,lbutton up,off
settimer,gtrack,off
record=
wheel=
gtracking:=true
gtrack=
return

gtrack: 
critical off      ; don't want this getting in way of double-click checking
mousegetpos xpos2,ypos2
track:=(abs(ypos1-ypos2)>=abs(xpos1-xpos2)) ? (ypos1>ypos2 ? "u" : "d") : (xpos1>xpos2 ? "l" : "r")  ;determines up down left right
if (abs(ypos1-ypos2)>sensitivity or abs(xpos1-xpos2)>sensitivity) and (track<>SubStr(gtrack, 0, 1)) ;track if x or y changing and direction changing
   gtrack.=track
xpos1:=xpos2
ypos1:=ypos2
return

parserecord:      ; script allows for rocking more than once eg gr/l/x:
loop,parse,record        ; finds position of last "/"
   if a_loopfield=/
      position:=a_index
return

multiclick:
time2:=time1      
time1:=a_tickcount   
if (thishotkey=substr(record,0,1) and time1-time2<multiclicktime)
   {
   multiclick:=true
   multitrack.=thishotkey
   }
else
   {         ; avoids rocking errors when time between clicks is too short
   multiclick:=false
   multitrack=
   }
return

trackassign:
settimer,gtrack,off
if gtrack               ; letters enclosed in parentheses
   record.="(" . gtrack . ")"      ;  are gesture directions 
gtrack=               
macro:="m-" . record
return

esc::
exitapp
return

wheelup::
wheeldown::
wheel:=a_thishotkey
if record and gtracking   
      {
   gosub trackassign   
      gosub callmacro
   }
else
      sendevent {%wheel%}
return

rock()
{
global
if record contains /      ; "/" is the rocking symbol
   {
   gosub parserecord   ; "position+1" is the first letter after the forward slash
   if (thishotkey=substr(record,position+1,1))
         return "rocking"
   else
      return "rockover"   ; in the button up section, if the button down and
               ;  the button up don't match, rocking is finished
   }
}

m-r:          ;normal right click
click right,xpos1,ypos1
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; wheel examples ;;;;;;;;;;

m-r-wheelup:      ;change volume with wheel -  hold right button down and use wheel
Send {Volume_Up}
return

m-r-wheeldown:
Send {Volume_Down}
return 

;;;;;;;; multi click examples ;;;;;;;;;;

m-rr:
msgbox,,,double right click,5
return

m-rr(l):
msgbox,,,double right click then gesture left ,5
return

m-rr/ll:
msgbox,,,double right click then rock with double right ,5
return

m-r/l/m:
msgbox,,,right click then rock with left and then middle ,5
return

;;;;;;;; rocker examples ;;;;;;;;;;

m-r/l:
msgbox,,,keep right held down and click left will repeat action,5
return

m-l/r:                                           
msgbox,,,rocker left then right. careful where you click,5
return

m-r(l)/l:
msgbox,,,you gestured left and clicked,5
return

;;;;;;;;;;;; 4th mouse button example ;;;;;;;;;;

m-x(l):
msgbox,,,you've gestures left with the 4th mouse button,5
return

m-x/r:
msgbox,,,rocker 4th button then right,5
return

m-r/x:
msgbox,,,rocker right then 4th button,5
return

;;;;;;;; other examples ;;;;;;;;;;;;;;

m-r(u):             ;; gesture up ;; maximize window under cursor. maximize last window if cursor over desktop
if (window1=windowD)
   {
   if (window2<>"")
   winmaximize, ahk_id %window2%
   }
else
   winmaximize ahk_id %window1%
return

m-rd:            ;minimize window under cursor
if (window1<>windowD)    ;don't minimize the desktop
   winminimize, ahk_id %window1%
return

m-r(l):            ;browser back
winactivate ahk_id %window1%   
sendinput {Browser_Back}
return

m-r(r):            ;browser forward
winactivate ahk_id %window1%   
sendinput {Browser_Forward}
return

m-r(dr):            ;restore last window.
winrestore ahk_id %window2%
return

m-r(ldr):            ;close window under cursor (draw a C)
if (window1<>windowD)
   winclose ahk_id %window1%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2009, 2:28 pm 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
appreciate the hasty reply.
first I'll have a go of the slightly revamped code and let you know how it works out, hold up pls....

nah, nothing doing I'm afraid sir, however I'll do my best to describe the issue at hand over here and what I've tried to come up with a solution, even just temporary if need be for now.
it's all centered around the mouse scroll wheel on my logitech trackman trackball mouse. this also performs double duty as a middle button.
there's always been a slight issue I should really point out, in that even with prior versions of the gesture script, the middle button always had to have the following function appended to the ahk code, without which it didn't do much of anything.
gm:
send, {click middle}
exit
the scrolling was fine at the time though, which is where major spanner flies straight into hampering an otherwise sweet script.
so, basically what happens is I'll scroll using the wheel to page through a document in notepad, or perhaps the windows folder in explorer, or a webpage in firefox. it scrolls as per usual. but somehow, the very act of the scroll function removes the script from recognizing the next movement from being picked up and processed to perform it's action. it takes a second gesture or rocker motion to restore normal operations until the next time I use the scroll wheel to sift through a page.
I've tried many possible alternatives in thinking it wasn't something in the code itself, but rather the fact of just using the windows 7 generic drivers to operate the mouse. so first course of action was to simply toy around with the windows control panel mouse settings, then install the logitech setpoint software and set up different scenarios like setting the wheel to universal scroll, generic scroll (windows), and no scroll action. I coupled this with adding the ahk wheelup::wheelup
return
wheeldown::wheeldown
return
to the simple gesture script below the running code, saving and reloading the script.
next step was to set the wheel to the up and down arrows keys in the logitech setpoint software. this rendered the scrolling steps on a line by line basis and also made the wheel function backward, up for down and down for up. it did allow for the gesture code to execute immediately after using the wheel though. so it'd seem the scroll message itself is somehow causing the bizarre behavior whether it's set to generic windows control or the logitech universal setting.
the same held true for when I installed the uberoptions software to augment the setpoint software.
I've encountered the same results on two laptops and two mice to the same effect in windows 7. my other laptop has proper function when using it's native trackpoint software and scroll action.
so, yip. I'm at a loss rodfell. just fingers crossed you'll steer me clear and get this puppie up n' running with my setup.
lemme know if there's anything I can do though. thanks now.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 5:31 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
any chance this helps the wheel issue??
Code:
multiclicktime=300    ; set to 0 if you don't want double/triple/multi clicking. otherwise set as fast as you can double-click
rockinstant:=true       ; if true, rocking action fires on downclick (which is faster) but stops further tracking
sensitivity=4      ; adjust if required. if too low, a simple "down/up" gesture (V) might be recorded as "down/right/up" (U)
demomode:=true      ; demonstration mode on/off

coordmode,mouse,screen
winget,windowD,id,ahk_class Progman   ;windowD is the desktop
gosub cleanup
return

#MaxThreadsPerHotkey 5    ; needed when multiclicking
browser_search::          ; "find" key on logitech mx620 mouse, used here as an example
lbutton::      
rbutton::      ; list whatever mouse buttons you want tracked.
mbutton::      ; works best if all available listed
xbutton1::         ; lbutton only tracked when other mouse buttons start tracking
xbutton2::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)   ;buttons named from initial except xbutton2
buttonsdown.=thishotkey . (getkeystate("lbutton","p") ? "l" : "") 
gosub multiclick
mcalled=      ; records if the macro has been called to avoid unintended double-click double calls
winget,windowA,id,A     ; windowA is the active window, useful for some gestures
hotkey,lbutton,on         ; disables normal left click during gesture
hotkey,lbutton up,off   ; prevents next line of code from calling on lbutton up
click up      ; prevents drag box appearing when left/right rocking and gesturing eg. m-l/r(d)
hotkey,lbutton up,on
if (window1<>windowD)     
   window2:=window1         ; used in some gestures, window2 is the window the previous macro acted on           
mousegetpos xpos1,ypos1,window1   ; window1 is the window underneath the current gesture
if gtracking
   {
   gosub trackassign
   record.=(getkeystate("lbutton","p") and not record ? "l/" : "") . (record and thishotkey<>substr(record,0,1) ? "/" : "") . thishotkey
   settimer,gtrack,10          ; "/" is the rocking symbol
   }                          
else
   {
   gosub parserecord   ; finds position of last "/" in record for next line of code
   record:=regexreplace(record,"/\w*","/" . thishotkey . multitrack,position,1,position)   ; allows rocking with different buttons
   }      
if instr(record,thishotkey . "/") or not instr(buttonsdown,substr(record,1,1))
   {
   gosub cleanup      ; cleanup if otherwise fatal errors detected
   return      
   }
if rock()="rocking" and rockinstant
   {            ; calls action before mouse button released (rockinstant is user defined)
   rockdown:=thishotkey        ; advantage - faster action
   goto rockdown           ; disadvantage - gesture called so no more tracking      
   }            
rockdown=
return

browser_search up::      
rbutton up::
lbutton up::
mbutton up::
xbutton1 up::
xbutton2 up::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)
stringreplace,buttonsdown,buttonsdown,%thishotkey%,,all
if (rockdown=thishotkey)
   return
rockdown:
buttonsup.=thishotkey
multiclick:=false
if not gtrack   ; no need for delay to check for multiclick if button released after gesture tracking
   sleep % multiclicktime-a_tickcount+time1  ;delay to check for multiclick
if multiclick or not buttonsup
   return
thishotkey:=substr(buttonsup,1,1)
stringreplace,buttonsup,buttonsup,%thishotkey%,,all
gtracking:=false  ; no more gesture tracking once a mouse button has been released (unless multiclicking)
gosub trackassign
cleanup:=(rock()<>"rocking") or wheel ? true : false   ; this allows for repeat rocking   
callmacro:=not wheel and record and not (rock()="rockover" and mcalled) ? true : false
if cleanup         ; these lines allow for cleanup before the macro action is called.
   gosub cleanup      ; (note that the gesture itself is not erased by the cleanup). this prevents a called
if callmacro         ;  action that takes a significant time stopping further tracking.
   gosub callmacro   
return            
#maxthreadsperhotkey 1      ; autohotkey default setting. set to your usual setting       

callmacro:
mcalled:=true
macro.=(wheel ? "-" : "") . wheel
if demomode
   msgbox,,Demo,%macro%, % (wheel ? .7 : strlen(gesture)/5+1)
else
   if islabel(macro)   ; checks if macro is labelled
         gosub %macro%
return

cleanup:
hotkey,lbutton,off             ; restore normal left mouse button function
hotkey,lbutton up,off
settimer,gtrack,off
record=
wheel=
gtrack=
gtracking:=true

return

gtrack: 
critical off      ; don't want this getting in way of double-click checking
mousegetpos xpos2,ypos2
track:=(abs(ypos1-ypos2)>=abs(xpos1-xpos2)) ? (ypos1>ypos2 ? "u" : "d") : (xpos1>xpos2 ? "l" : "r")  ;determines up down left right
if (abs(ypos1-ypos2)>sensitivity or abs(xpos1-xpos2)>sensitivity) and (track<>SubStr(gtrack, 0, 1)) ;track if x or y changing and direction changing
   gtrack.=track
xpos1:=xpos2,ypos1:=ypos2
return

parserecord:      ; script allows for rocking more than once eg gr/l/x:
loop,parse,record        ; finds position of last "/"
   if a_loopfield=/
      position:=a_index
return

multiclick:
time2:=time1,time1:=a_tickcount      
if (thishotkey=substr(record,0,1) and time1-time2<multiclicktime)
   multiclick:=true,multitrack.=thishotkey
else
   multiclick:=false,multitrack=""
return

trackassign:
settimer,gtrack,off
if gtrack               ; letters enclosed in parentheses
   record.="(" . gtrack . ")"      ;  are gesture directions 
gtrack=               
macro:="m-" . record
return

esc::
exitapp
return

wheelup::
wheeldown::
wheel:=a_thishotkey
if record and gtracking   
      {
   gosub trackassign   
      gosub callmacro
   }
else
      sendevent {%wheel%}
return

rock()
{
global
if record contains /      ; "/" is the rocking symbol
   {
   gosub parserecord   ; "position+1" is the first letter after the forward slash
   if (thishotkey=substr(record,position+1,1))
         return "rocking"
   else
      return "rockover"   ; in the button up section, if the button down and
               ;  the button up don't match, rocking is finished
   }
}

m-r:          ;normal right click
click right,xpos1,ypos1
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; wheel examples ;;;;;;;;;;

m-r-wheelup:      ;change volume with wheel -  hold right button down and use wheel
Send {Volume_Up}
return

m-r-wheeldown:
Send {Volume_Down}
return 

;;;;;;;; multi click examples ;;;;;;;;;;

m-rr:
msgbox,,,double right click,5
return

m-rr(l):
msgbox,,,double right click then gesture left ,5
return

m-rr/ll:
msgbox,,,double right click then rock with double right ,5
return

m-r/l/m:
msgbox,,,right click then rock with left and then middle ,5
return

;;;;;;;; rocker examples ;;;;;;;;;;

m-r/l:
msgbox,,,keep right held down and click left will repeat action,5
return

m-l/r:                                           
msgbox,,,rocker left then right. careful where you click,5
return

m-r(l)/l:
msgbox,,,you gestured left and clicked,5
return

;;;;;;;;;;;; 4th mouse button example ;;;;;;;;;;

m-x(l):
msgbox,,,you've gestures left with the 4th mouse button,5
return

m-x/r:
msgbox,,,rocker 4th button then right,5
return

m-r/x:
msgbox,,,rocker right then 4th button,5
return

;;;;;;;; other examples ;;;;;;;;;;;;;;

m-r(u):             ;; gesture up ;; maximize window under cursor. maximize last window if cursor over desktop
if (window1=windowD)
   {
   if (window2<>"")
   winmaximize, ahk_id %window2%
   }
else
   winmaximize ahk_id %window1%
return

m-rd:            ;minimize window under cursor
if (window1<>windowD)    ;don't minimize the desktop
   winminimize, ahk_id %window1%
return

m-r(l):            ;browser back
winactivate ahk_id %window1%   
sendinput {Browser_Back}
return

m-r(r):            ;browser forward
winactivate ahk_id %window1%   
sendinput {Browser_Forward}
return

m-r(dr):            ;restore last window.
winrestore ahk_id %window2%
return

m-r(ldr):            ;close window under cursor (draw a C)
if (window1<>windowD)
   winclose ahk_id %window1%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 10:23 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
ok, found the wheel bug and fixed it. tell me more about the middle button.
Code:
multiclicktime=300    ; set to 0 if you don't want double/triple/multi clicking. otherwise set as fast as you can double-click
rockinstant:=false       ; if true, rocking action fires on downclick (which is faster) but stops further tracking
sensitivity=4      ; adjust if required. if too low, a simple "down/up" gesture (V) might be recorded as "down/right/up" (U)
demomode:=true      ; demonstration mode on/off

coordmode,mouse,screen
winget,windowD,id,ahk_class Progman   ;windowD is the desktop
gosub cleanup
return

#MaxThreadsPerHotkey 5    ; needed when multiclicking
browser_search::          ; "find" key on logitech mx620 mouse, used here as an example
lbutton::      
rbutton::      ; list whatever mouse buttons you want tracked.
mbutton::      ; works best if all available listed
xbutton1::         ; lbutton only tracked when other mouse buttons start tracking
xbutton2::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)   ;buttons named from initial except xbutton2
buttonsdown.=thishotkey . (getkeystate("lbutton","p") ? "l" : "") 
gosub multiclick
mcalled=      ; records if the macro has been called to avoid unintended double-click double calls
winget,windowA,id,A     ; windowA is the active window, useful for some gestures
hotkey,lbutton,on         ; disables normal left click during gesture
hotkey,lbutton up,off   ; prevents next line of code from calling on lbutton up
click up      ; prevents drag box appearing when left/right rocking and gesturing eg. m-l/r(d)
hotkey,lbutton up,on
if (window1<>windowD)     
   window2:=window1         ; used in some gestures, window2 is the window the previous macro acted on           
mousegetpos xpos1,ypos1,window1   ; window1 is the window underneath the current gesture
if gtracking
   {
   gosub trackassign
   record.=(getkeystate("lbutton","p") and not record ? "l/" : "") . (record and thishotkey<>substr(record,0,1) ? "/" : "") . thishotkey
   settimer,gtrack,10          ; "/" is the rocking symbol
   }                          
else
   {
   gosub parserecord   ; finds position of last "/" in record for next line of code
   record:=regexreplace(record,"/\w*","/" . thishotkey . multitrack,position,1,position)   ; allows rocking with different buttons
   }      
if instr(record,thishotkey . "/") or not instr(buttonsdown,substr(record,1,1))
   {
   gosub cleanup      ; cleanup if otherwise fatal errors detected
   return      
   }
if rock()="rocking" and rockinstant
   {            ; calls action before mouse button released (rockinstant is user defined)
   rockdown:=thishotkey        ; advantage - faster action
   goto rockdown           ; disadvantage - gesture called so no more tracking      
   }            
rockdown=
return

browser_search up::      
rbutton up::
lbutton up::
mbutton up::
xbutton1 up::
xbutton2 up::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)
stringreplace,buttonsdown,buttonsdown,%thishotkey%,,all
if (rockdown=thishotkey)
   return
rockdown:
buttonsup.=thishotkey
multiclick:=false
if not gtrack   ; no need for delay to check for multiclick if button released after gesture tracking
   sleep % multiclicktime-a_tickcount+time1  ;delay to check for multiclick
if multiclick or not buttonsup
   return
thishotkey:=substr(buttonsup,1,1)
stringreplace,buttonsup,buttonsup,%thishotkey%,,all
gtracking:=false  ; no more gesture tracking once a mouse button has been released (unless multiclicking)
gosub trackassign
cleanup:=(rock()<>"rocking") or wheel ? true : false   ; this allows for repeat rocking   
callmacro:=not wheel and record and not (rock()="rockover" and mcalled) ? true : false
if cleanup         ; these lines allow for cleanup before the macro action is called.
   gosub cleanup      ; (note that the gesture itself is not erased by the cleanup). this prevents a called
if callmacro         ;  action that takes a significant time stopping further tracking.
   gosub callmacro   
return            
#maxthreadsperhotkey 1      ; autohotkey default setting. set to your usual setting       

callmacro:
mcalled:=true
macro.=(wheel ? "-" : "") . wheel
if demomode
   msgbox,,Demo,%macro%, % (wheel ? .7 : strlen(gesture)/5+1)
else
   if islabel(macro)   ; checks if macro is labelled
         gosub %macro%
return

cleanup:
hotkey,lbutton,off             ; restore normal left mouse button function
hotkey,lbutton up,off
settimer,gtrack,off
record=
wheel=
gtrack=
gtracking:=true

return

gtrack: 
critical off      ; don't want this getting in way of double-click checking
mousegetpos xpos2,ypos2
track:=(abs(ypos1-ypos2)>=abs(xpos1-xpos2)) ? (ypos1>ypos2 ? "u" : "d") : (xpos1>xpos2 ? "l" : "r")  ;determines up down left right
if (abs(ypos1-ypos2)>sensitivity or abs(xpos1-xpos2)>sensitivity) and (track<>SubStr(gtrack, 0, 1)) ;track if x or y changing and direction changing
   gtrack.=track
xpos1:=xpos2,ypos1:=ypos2
return

parserecord:      ; script allows for rocking more than once eg gr/l/x:
loop,parse,record        ; finds position of last "/"
   if a_loopfield=/
      position:=a_index
return

multiclick:
time2:=time1,time1:=a_tickcount      
if (thishotkey=substr(record,0,1) and time1-time2<multiclicktime)
   multiclick:=true,multitrack.=thishotkey
else
   multiclick:=false,multitrack=""
return

trackassign:
settimer,gtrack,off
if gtrack               ; letters enclosed in parentheses
   record.="(" . gtrack . ")"      ;  are gesture directions 
gtrack=               
macro:="m-" . record
return

esc::
exitapp
return

wheelup::
wheeldown::
if record and gtracking   
      {
   wheel:=a_thishotkey
   gosub trackassign   
      gosub callmacro
   }
else
      sendinput {%a_thishotkey%}
return

rock()
{
global
if record contains /      ; "/" is the rocking symbol
   {
   gosub parserecord   ; "position+1" is the first letter after the forward slash
   if (thishotkey=substr(record,position+1,1))
         return "rocking"
   else
      return "rockover"   ; in the button up section, if the button down and
               ;  the button up don't match, rocking is finished
   }
}

m-r:          ;normal right click
click right,xpos1,ypos1
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; wheel examples ;;;;;;;;;;

m-r-wheelup:      ;change volume with wheel -  hold right button down and use wheel
Send {Volume_Up}
return

m-r-wheeldown:
Send {Volume_Down}
return 

;;;;;;;; multi click examples ;;;;;;;;;;

m-rr:
msgbox,,,double right click,5
return

m-rr(l):
msgbox,,,double right click then gesture left ,5
return

m-rr/ll:
msgbox,,,double right click then rock with double right ,5
return

m-r/l/m:
msgbox,,,right click then rock with left and then middle ,5
return

;;;;;;;; rocker examples ;;;;;;;;;;

m-r/l:
msgbox,,,keep right held down and click left will repeat action,5
return

m-l/r:                                           
msgbox,,,rocker left then right. careful where you click,5
return

m-r(l)/l:
msgbox,,,you gestured left and clicked,5
return

;;;;;;;;;;;; 4th mouse button example ;;;;;;;;;;

m-x(l):
msgbox,,,you've gestures left with the 4th mouse button,5
return

m-x/r:
msgbox,,,rocker 4th button then right,5
return

m-r/x:
msgbox,,,rocker right then 4th button,5
return

;;;;;;;; other examples ;;;;;;;;;;;;;;

m-r(u):             ;; gesture up ;; maximize window under cursor. maximize last window if cursor over desktop
if (window1=windowD)
   {
   if (window2<>"")
   winmaximize, ahk_id %window2%
   }
else
   winmaximize ahk_id %window1%
return

m-rd:            ;minimize window under cursor
if (window1<>windowD)    ;don't minimize the desktop
   winminimize, ahk_id %window1%
return

m-r(l):            ;browser back
winactivate ahk_id %window1%   
sendinput {Browser_Back}
return

m-r(r):            ;browser forward
winactivate ahk_id %window1%   
sendinput {Browser_Forward}
return

m-r(dr):            ;restore last window.
winrestore ahk_id %window2%
return

m-r(ldr):            ;close window under cursor (draw a C)
if (window1<>windowD)
   winclose ahk_id %window1%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2009, 11:24 pm 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
Sheesh, is this coming straight outta the Bat cave I have to wonder?
That tweak worked a treat! Back in business no less.
Really, very much appreciated Rodfell.
Do excuse my lateness in reply seeing as your going to all this trouble, hopefully not just on my behalf, everyone deserves a punt at this time saver extraordinaire.
K, with regard to the middle mouse click. Seems I'm back to the workaround from the earlier code. Basically I just set up a little line to state:
m-m:
send {click middle}
exit
without this the middle button doesn't do much of anything which is interesting, but far from a deal breaker.
anyway, I'm gonna give the script a hammer for a while and let you know how it goes.
love'in it so far, *hat's off, takes a bow*
*does a little jig* ;-)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2009, 4:00 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
i don't get it. for m-m: to be called, the mbutton must work. what happens if you don't have m-m: set up as you say. Surely m-m would still be called?no? if you have, say
Code:
m-m:
msgbox middle button clicked
return
does that not bring up a message box. what happens when you middle click in demomode with the existing code?? btw, do you prefer rockinstant set at true or false


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2009, 9:11 am 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
sure, it is mighty strange it's just not avin none of it without the ol send {click middle} routine.
if I switch off the gesture script, the middle mouse button springs back into action. yip, like you say it did indeed pop up the message box if set up with the msgbox function, just as it does if set to send {click middle}. just if it's not appended with a code, nothing seems to happen.
still, it's a minor setback and something I've lived with up until now with previous versions. can see your wanting to get to the cause though, so just let me know if there's anything else I can try to iron out compatibility issues, or ghosts in the machine.
haha, ummm. well actually I was a bit scared off by the setting the rockinstant to true just in case I wanted to rock out some, then gesture. chances are with all the added options this won't be necessary so yeah, I'll give it a go and let cha know :o)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2009, 10:28 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
by the sounds of things it isn't really a bug. you set what you want the middle button to be. if you set it to {click middle} then you're asking the mouse drivers what action should be run. i just use generic drivers and use m-m: to do what i want it to do. (incidentally, i use the middle button for delete ie sendinput {delete}) you'll notice that i have defined the right button as "click right" because it would be silly to lose this button's natural functions.
as an aside, this script does make right dragging disappear. the line $#rbutton::rbutton allows you to right drag if you hold down the windows key


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2009, 8:47 pm 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
ahhh, that's defo good to know. can't see that there's any drawback to having to run an extra two lines of code to set up middle mouse action. all still seems solid and stable, although I have managed to crash the code a few times, but can't seem to recreate just how it's done but gonna keep a close eye to see if there's any tell tail signs that can trigger an auto-shutdown situation.
having the middle mouse for delete is indeed a nifty idea. I have firefox set to use the middle button to open links in a new tab, copy a link from the clipboard and open it in a new tab, and also to function as paste in text boxes. it's also set to work in conjunction with various keys to open different keyword searches a la google, 1 month search, 3 month search, 6 month search, year search, and waaaaay back yonder search. the command structure is really getting fairly extensive with the pointer spinning around the screen firing a bunch of repetitive actions, basically so I don't have to. it's kinda cool to see it all automated like that, but still needs some work for optimum hassle free computing, and maximum productivity day to day.
so weighing up the options with the new code in mind and how best to employ the labyrinth it's opened up for extra commands.
sweet script sir, gonna give it another once around before hitting the hay for today.
cheers now.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 11:09 pm 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
Just to say I'm really very impressed with the HUGE leap in functionality the new version provides rodfell.
Its tight, tidy and well executed and plays nicely mostly.
Actually, it's ironic just how too much choice and options a plenty can perplex as how best employ to deploy in end user implementation :o)
Just having some fun with pretty wild ideas just now, I'll report back soon as my tweaking isn't so needing... tweaking.
100% top effort though!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2009, 10:02 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
just a bit of fine tuning and code compression. i ditched the "rockinstant". let me know if anyone still uses it. i never used it myself.
Code:
multiclicktime=300    ; set to 0 if you don't want double/triple/multi clicking. otherwise set as fast as you can double-click
sensitivity=4      ; adjust if required. if too low, a simple "down/up" gesture (V) might be recorded as "down/right/up" (U)
demomode:=true      ; demonstration mode on/off

coordmode,mouse,screen
winget,windowD,id,ahk_class Progman   ;windowD is the desktop, useful for some gestures
gosub cleanup
#maxthreadsbuffer on
browser_search::          ; "find" key on logitech mx620 mouse, used here as an example
lbutton::      
rbutton::      ; list whatever mouse buttons you want tracked.
mbutton::      ; works best if all available listed
xbutton1::         ; lbutton only tracked when other mouse buttons start tracking
xbutton2::
thishotkey:=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)   ;buttons named from initial except xbutton2
gosub multiclick
winget,windowA,id,A     ; windowA is the active window, useful for some gestures
hotkey,lbutton,on         ; disables normal left click during gesture
hotkey,lbutton up,off   ; prevents next line of code from firing "lbutton up:"
click up      ; prevents drag box appearing when left/right rocking and gesturing eg. m-l/r(d)
hotkey,lbutton up,on
if (window1<>windowD)     
   window2:=window1         ; used in some gestures, window2 is the window the previous macro acted on           
mousegetpos xpos1,ypos1,window1   ; window1 is the window underneath the current gesture
if gtracking
   {
   gosub trackassign
   record.=(getkeystate("lbutton","p") and not record ? "l/" : "") . (record and thishotkey<>substr(record,0,1) ? "/" : "") . thishotkey
   settimer,gtrack,10          
   }                          
else
   {
   gosub parserecord   ; finds position of last "/" in record for next line of code
   record:=regexreplace(record,"/\w*","/" . thishotkey . multitrack,position,1,position) 
   }      
if instr(record,thishotkey . "/")
   gosub cleanup      ; cleanup if unlikely but fatal error detected
return

browser_search up::      
rbutton up::
lbutton up::
mbutton up::
xbutton1 up::
xbutton2 up::
buttonsup.=a_thishotkey="xbutton2" ? "f" : substr(a_thishotkey,1,1)
multiclick:=false
if not gtrack   ; no need for delay to check for multiclick if button released after gesture tracking
   sleep % multiclicktime-a_tickcount+time1  ;delay to check for multiclick
if multiclick or not buttonsup
   return
thishotkey:=substr(buttonsup,1,1)
stringreplace,buttonsup,buttonsup,%thishotkey%,,all
gtracking:=false  ; no more gesture tracking once a mouse button has been released (unless multiclicking)
gosub trackassign
cleanup:=(rock()<>"rocking") or wheel ? true : false   ; this allows for repeat rocking   
callmacro:=not wheel and record and not (rock()="over" and mcalled) ? true : false
if cleanup         ; these lines allow for cleanup before the macro action is called.
   gosub cleanup      ; (note that the gesture itself is not erased by the cleanup). this prevents a called
if callmacro         ;  action that takes a significant time stopping further tracking.
   gosub callmacro   
return            
#maxthreadsbuffer off
      
callmacro:
mcalled:=true
macro.=(wheel ? "-" : "") . wheel
if demomode
   msgbox,,Demo,%macro%, % (wheel ? .7 : strlen(gesture)/4+1)
else
   if islabel(macro)   ; checks if macro is labelled
         gosub %macro%
return

cleanup:
hotkey,lbutton,off             ; restore normal left mouse button function
hotkey,lbutton up,off
settimer,gtrack,off
record:="",wheel="",gtrack="",mcalled="",gtracking=true
return

gtrack: 
critical off      ; don't want this getting in way of double-click checking
mousegetpos xpos2,ypos2
track:=(abs(ypos1-ypos2)>=abs(xpos1-xpos2)) ? (ypos1>ypos2 ? "u" : "d") : (xpos1>xpos2 ? "l" : "r")  ;determines up down left right
if (abs(ypos1-ypos2)>sensitivity or abs(xpos1-xpos2)>sensitivity) and (track<>SubStr(gtrack, 0, 1)) ;track if x or y changing and direction changing
   gtrack.=track
xpos1:=xpos2,ypos1:=ypos2
return

parserecord:      ; script allows for rocking more than once eg m-r/l/x:
loop,parse,record        ; finds position of last "/"
   if a_loopfield=/
      position:=a_index
return

multiclick:
time2:=time1,time1:=a_tickcount      
if (thishotkey=substr(record,0,1) and time1-time2<multiclicktime)
    multiclick:=true,multitrack.=thishotkey
else
   multiclick:=false,multitrack:=""
return

trackassign:
settimer,gtrack,off
if gtrack               ; letters enclosed in parentheses
   record.="(" . gtrack . ")"         ;  are gesture directions 
gtrack=               
macro:="m-" . record
return

esc::
exitapp
return

wheelup::
wheeldown::
if record and gtracking   
      {
   wheel:=a_thishotkey
   gosub trackassign   
      gosub callmacro
   }
else
      sendinput {%a_thishotkey%}
return

rock()
{
global
if record contains /      ; "/" is the rocking symbol
   {
   gosub parserecord   
   return (thishotkey=substr(record,position+1,1)) ? "rocking" : "over"
   }         ; "position+1" is the first letter after the forward slash
}

m-r:          ;normal right click
click right
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; wheel examples ;;;;;;;;;;

m-r-wheelup:      ;change volume with wheel -  hold right button down and use wheel
Send {Volume_Up}
return

m-r-wheeldown:
Send {Volume_Down}
return 

;;;;;;;; multi click examples ;;;;;;;;;;

m-rr:
msgbox,,,double right click,5
return

m-rr(l):
msgbox,,,double right click then gesture left ,5
return

m-rr/ll:
msgbox,,,double right click then rock with double right ,5
return

m-r/l/m:
msgbox,,,right click then rock with left and then middle ,5
return

;;;;;;;; rocker examples ;;;;;;;;;;

m-r/l:
msgbox,,,keep right held down and click left will repeat action,5
return

m-l/r:                                           
msgbox,,,rocker left then right. careful where you click,5
return

m-r(l)/l:
msgbox,,,you gestured left and clicked,5
return

;;;;;;;;;;;; 4th mouse button example ;;;;;;;;;;

m-x(l):
msgbox,,,you've gestures left with the 4th mouse button,5
return

m-x/r:
msgbox,,,rocker 4th button then right,5
return

m-r/x:
msgbox,,,rocker right then 4th button,5
return

;;;;;;;; other examples ;;;;;;;;;;;;;;

m-r(u):             ;; gesture up ;; maximize window under cursor. maximize last window if cursor over desktop
if (window1=windowD)
   {
   if (window2<>"")
   winmaximize, ahk_id %window2%
   }
else
   winmaximize ahk_id %window1%
return

m-rd:            ;minimize window under cursor
if (window1<>windowD)    ;don't minimize the desktop
   winminimize, ahk_id %window1%
return

m-r(l):            ;browser back
winactivate ahk_id %window1%   
sendinput {Browser_Back}
return

m-r(r):            ;browser forward
winactivate ahk_id %window1%   
sendinput {Browser_Forward}
return

m-r(dr):            ;restore last window.
winrestore ahk_id %window2%
return

m-r(ldr):            ;close window under cursor (draw a C)
if (window1<>windowD)
   winclose ahk_id %window1%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2009, 11:12 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
i have updated the first entry in this thread


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 2:08 pm 
Offline

Joined: May 29th, 2009, 11:33 am
Posts: 12
WOW!!! This script excites me...

This is probably one of the most well-documented ahk script I found.... but, ironically i have not been able to figure out how to make it work properly for me.

I dont need the gestures part of the script (I use StrokeIt! for that).
I need only the rockers part.

Moreover, when I activate this script, the following stop working:
1. A program called "MouseImpPro Live" to scroll using my right mouse button.
2. A firefox extension "Snap Links Plus" which uses Middle mouse button to draw rectangles to open links.
3. Another script which uses double middle click.

I badly want to use this script... so, PLZZZZZZZZZ HELP!


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, 6, 7, 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 10 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