AutoHotkey Community

It is currently May 27th, 2012, 6:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 108 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8  Next
Author Message
 Post subject:
PostPosted: March 23rd, 2011, 5:42 am 
Oh... and running default Microsoft Mouse Driver with Microsoft Bluetooth Notebook Mouse 5000 (auto update) with no ALPS Trackpad driver or Intellimouse driver added.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2011, 12:28 pm 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
yeah you have to be careful what m-lr: rocking does. it states in the code that you have to be careful where you click.there's no simple way to stop the initial press of the left mouse button from performing it's native function. if you look at the script, gesture recognition only begins with mouse buttons other than left button. to include the left button from the first click would be too messy. so, either be careful where you left-right click, or choose a macro where it doesn't matter. i use m-lr: to close the window under the mouse, so the initial left click doesn't matter. right-left clicking doesn't cause this problem. if you left-right click where the mouse is not over a control, you can still use it as browser_back


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2011, 7:58 am 
Ah, so that is what that comment really means. Reading through more of the forum, I see that rocker mouse click function is flawed in that the first click still passes through instead of being replaced. I assume there is no way to fix that with AutoHotKey?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2011, 4:01 pm 
Looks like a very good script but could someone provide more examples :oops:

I am not user how to add gestures and associate actions to them
say I wanted to make a C = copy some text I had highlighted ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2011, 11:45 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
to make c a copy macro using the right button ...
Code:
m-r(ldr):
sendinput,^c
return

don't forget to make demomode:=false on line 1


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2011, 11:52 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
HWJ wrote:
I assume there is no way to fix that with AutoHotKey?
i think it would be messy.you'd have to catch the left mouse, without messing up things like double clicking and lbutton mouse dragging.i'll play around with it


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2011, 1:59 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
changed script to allow for better left button gesturing eg left-right rocking.to achieve this i've had to reproduce all of the normal actions of the left mouse button. i think i've got it but let me know if any normal left button actions have been compromised.
EDIT:holding down left button in a scroll bar now doesn't work normally.i don't see a fix for this at the moment.i'll see if i can figure out how to tell if the cursor is over a scroll bar
Code:
demomode:=true    ;demonstration mode on/off. change to false when ready to use
mintrack=20       ;minimum length of registered track sector in pixels 
wheelguard:=true  ;if true, wheel and middle button click can't both be used in the same gesture (recommended)

#MaxHotkeysPerInterval 500  ;prevents problems with rapid wheel movements
winget,windesktop,id,ahk_class Progman   ;desktop id, useful for some macros
gosub cleanup

*mbutton::   ;the asterisk allows for the use of modifier keys
*lbutton::     
*rbutton::     
*xbutton1::
*xbutton2::
stringreplace,lastdown,a_thishotkey,*,,all   ;hotkey name stripped of "*" and "button"
stringreplace,lastdown,lastdown,button,,all
if macrorunning or wheel
   return
if not buttonsdown                   
   mousegetpos xpos1,ypos1,win1  ;win1 is the window underneath the current gesture
gosub modifier
mouseclick:=buttonsdown.=lastdown
winget,winactive,id,A          ;active window id, useful for some macros
if not buttonsup
   settimer,tracking,1           ;will go as fast as timer will allow, either 10 or 15.6ms
return

*mbutton up::
if wheel and wheelguard        ;middle button clicks ignored when using wheel (if wheelguard:=true)
   return
*rbutton up::
*lbutton up::
*xbutton1 up::
*xbutton2 up::
stringreplace,lastup,a_thishotkey,*,,all
stringreplace,lastup,lastup,%a_space%up,,all
stringreplace,lastup,lastup,button,,all
stringreplace,buttonsdown,buttonsdown,%lastup%,,all
buttonsup:=true
settimer,tracking,off            ;no more gesture tracking once a mouse button has been released
if not wheel and (lastdown=lastup)
   gosub callmacro   
if not buttonsdown         
   gosub cleanup
return

*wheelup::
*wheeldown::
if (instr(buttonsdown,"m") and wheelguard) or macrorunning    ;prevents accidental use of mousewheel with middle button gestures   
   return
gosub modifier
if (buttonsdown and not buttonsup) or alt or shift or ctrl
   {
   stringtrimleft,wheel,a_thishotkey,1     
   settimer,tracking,off   ;no more tracking once wheel used
   goto callmacro
   }
stringtrimleft,thishotkey,a_thishotkey,1
if not buttonsdown
   sendinput {%thishotkey%}   ;normal wheel command
return
     
callmacro:
macrorunning:=true
macro:="m-" . alt . shift . ctrl . mouseclick . (tracking ? "(" . tracking . ")" : "") . (wheel ? "-" . wheel : "")
if (demomode and macro<>"m-l" and macro<>"m-r")
   msgbox,,DEMO MODE,%macro% ,1   
else
   if islabel(macro)         
         gosub %macro%
macrorunning:=false
return

cleanup:
if (win1<>windesktop)     
   win2:=win1     ; used in some gestures, win2 is the window the previous macro acted on
wheel:="",tracking="",buttonsup="",buttonsdown="",mouseclick="",track2="",alt="",shift="",ctrl=""
return

tracking:
mousegetpos xpos2,ypos2
if (xpos1<>xpos2) or (ypos1<>ypos2)
   if buttonsdown=l      ;stops tracking if left mouse dragging
      {
      settimer,tracking,off
      sendinput {lbutton down}   ;allows left mouse dragging
      return
      }
angle:=abs((xpos1-xpos2)/(ypos1-ypos2+0.001))      ;+0.001 avoids divide by zero error
if (angle>0.7 and angle<1.428) or (abs(ypos1-ypos2)<5 and abs(xpos1-xpos2)<5)   ;ignores angles within 10 degrees of 45 degree diagonal
   return                                                                       ;ignores movement that is too slow
track1:=(abs(ypos1-ypos2)>abs(xpos1-xpos2)) ? (ypos1>ypos2 ? "u" : "d") : (xpos1>xpos2 ? "l" : "r")  ;determines up down left right
if (track1<>track2)            ;remembers mouse position when track direction changes
   xpos0:=xpos2,ypos0:=ypos2
if (track1<>SubStr(tracking, 0, 1)) and (track1=track2) and (abs(xpos0-xpos2)>=mintrack or abs(ypos0-ypos2)>=mintrack)
   tracking.=track1        ;track if x or y changing sufficient to register. track needs confirmation (2 tracks same direction)
xpos1:=xpos2,ypos1:=ypos2,track2:=track1
return

modifier:
alt:=getkeystate("alt","p") ? "!" : ""        ;list modifiers here and in cleanup
shift:=getkeystate("shift","p") ? "+" : ""
ctrl:=getkeystate("ctrl","p") ? "^" : ""
return

esc::exitapp

m-r:                     ;normal right click
sendinput {rbutton}
return

m-l:                     ;normal left click
if not getkeystate("lbutton")
   sendinput {lbutton down}  ;only happens if logical state of lbutton is up
sendinput {lbutton up}
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

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

m-rl:
msgbox,,,if you keep right held down, clicking left will repeat action,5
return

m-lr:                                           
msgbox,,,if you keep left held down. clicking right will repeat action,5
return

m-rl(l):
m-lr(l):
msgbox,,,you combined rocking and gesturing,5
return

;;;;;;;;;;;; gesture examples ;;;;;;;;;;

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

m-r(d):            ;minimize window under cursor
if (win1<>windesktop)    ;don't minimize the desktop
   winminimize, ahk_id %win1%
return

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

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

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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2011, 7:30 pm 
Wow, thank you rodfell. So far this is working great so far!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2011, 6:44 pm 
There are a few problems. Left clicking sticks from time to time and Ctrl or Shift LeftClicking (i.e. selecting multiple files in any file list) does not work at all.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2011, 12:08 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
HWJ wrote:
There are a few problems. Left clicking sticks from time to time and Ctrl or Shift LeftClicking (i.e. selecting multiple files in any file list) does not work at all.
think i fixed this problem. still haven't fixed problem with clicking on scroll bars with lbutton. trying to find solution. in meantime, if you click on a scroll bar with lbutton and hold it, and then make a small movement, a normal "click down" will fire.
Code:
demomode:=true    ;demonstration mode on/off. change to false when ready to use
mintrack=20       ;minimum length of registered track sector in pixels 
wheelguard:=true  ;if true, wheel and middle button click can't both be used in the same gesture (recommended)

#MaxHotkeysPerInterval 500  ;prevents problems with rapid wheel movements
winget,windesktop,id,ahk_class Progman   ;desktop id, useful for some macros
gosub cleanup

*mbutton::   ;the asterisk allows for the use of modifier keys
*lbutton::     
*rbutton::     
*xbutton1::
*xbutton2::
stringreplace,lastdown,a_thishotkey,*,,all   ;hotkey name stripped of "*" and "button"
stringreplace,lastdown,lastdown,button,,all
if macrorunning or wheel
   return
if not buttonsdown                   
   mousegetpos xpos1,ypos1,win1  ;win1 is the window underneath the current gesture
gosub modifier
mouseclick:=buttonsdown.=lastdown
winget,winactive,id,A          ;active window id, useful for some macros
if not buttonsup
   settimer,tracking,1           ;will go as fast as timer will allow, either 10 or 15.6ms
return

*mbutton up::
if wheel and wheelguard        ;middle button clicks ignored when using wheel (if wheelguard:=true)
   return
*rbutton up::
*lbutton up::
*xbutton1 up::
*xbutton2 up::
stringreplace,lastup,a_thishotkey,*,,all
stringreplace,lastup,lastup,%a_space%up,,all
stringreplace,lastup,lastup,button,,all
stringreplace,buttonsdown,buttonsdown,%lastup%,,all
buttonsup:=true
settimer,tracking,off            ;no more gesture tracking once a mouse button has been released
if not wheel and (lastdown=lastup)
   gosub callmacro   
if not buttonsdown         
   gosub cleanup
return

*wheelup::
*wheeldown::
if (instr(buttonsdown,"m") and wheelguard) or macrorunning    ;prevents accidental use of mousewheel with middle button gestures   
   return
gosub modifier
if (buttonsdown and not buttonsup) or alt or shift or ctrl
   {
   stringtrimleft,wheel,a_thishotkey,1     
   settimer,tracking,off   ;no more tracking once wheel used
   goto callmacro
   }
stringtrimleft,thishotkey,a_thishotkey,1
if not buttonsdown
   sendinput {%thishotkey%}   ;normal wheel command
return
     
callmacro:
macrorunning:=true
macro:="m-" . alt . shift . ctrl . mouseclick . (tracking ? "(" . tracking . ")" : "") . (wheel ? "-" . wheel : "")
if (demomode and macro<>"m-l" and macro<>"m-r")
   msgbox,,DEMO MODE,%macro% ,1   
else
   if islabel(macro)         
         gosub %macro%
macrorunning:=false
return

cleanup:
if (win1<>windesktop)     
   win2:=win1     ; used in some gestures, win2 is the window the previous macro acted on
wheel:="",tracking="",buttonsup="",buttonsdown="",mouseclick="",track2="",alt="",shift="",ctrl=""
return

tracking:
mousegetpos xpos2,ypos2
if (xpos1<>xpos2) or (ypos1<>ypos2)
   if (buttonsdown="l" and not alt and not shift and not ctrl)      ;stops tracking if left mouse dragging
      {
      settimer,tracking,off
      click down   ;allows left mouse dragging
      return
      }
angle:=abs((xpos1-xpos2)/(ypos1-ypos2+0.001))      ;+0.001 avoids divide by zero error
if (angle>0.7 and angle<1.428) or (abs(ypos1-ypos2)<5 and abs(xpos1-xpos2)<5)   ;ignores angles within 10 degrees of 45 degree diagonal
   return                                                                       ;ignores movement that is too slow
track1:=(abs(ypos1-ypos2)>abs(xpos1-xpos2)) ? (ypos1>ypos2 ? "u" : "d") : (xpos1>xpos2 ? "l" : "r")  ;determines up down left right
if (track1<>track2)            ;remembers mouse position when track direction changes
   xpos0:=xpos2,ypos0:=ypos2
if (track1<>SubStr(tracking, 0, 1)) and (track1=track2) and (abs(xpos0-xpos2)>=mintrack or abs(ypos0-ypos2)>=mintrack)
   tracking.=track1        ;track if x or y changing sufficient to register. track needs confirmation (2 tracks same direction)
xpos1:=xpos2,ypos1:=ypos2,track2:=track1
return

modifier:
alt:=getkeystate("alt","p") ? "!" : ""        ;list modifiers here and in cleanup
shift:=getkeystate("shift","p") ? "+" : ""
ctrl:=getkeystate("ctrl","p") ? "^" : ""
return

esc::exitapp

m-r:                     ;normal right click
sendinput {rbutton}
return

m-l:                     ;normal left click
if not getkeystate("lbutton")
   sendinput {lbutton down}  ;only happens if logical state of lbutton is up
sendinput {lbutton up}
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

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

m-rl:
msgbox,,,if you keep right held down, clicking left will repeat action,5
return

m-lr:                                           
msgbox,,,if you keep left held down. clicking right will repeat action,5
return

m-rl(l):
m-lr(l):
msgbox,,,you combined rocking and gesturing,5
return

;;;;;;;;;;;; gesture examples ;;;;;;;;;;

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

m-r(d):            ;minimize window under cursor
if (win1<>windesktop)    ;don't minimize the desktop
   winminimize, ahk_id %win1%
return

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

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

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

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2011, 10:23 pm 
Pfft, I did not realize I had to create "m-+l:" entries and the like...

Code:
m-+l:                    ;shift
sendinput +{lbutton}
return

m-^l:                    ;ctrl
sendinput ^{lbutton}
return

m-!l:                    ;alt
sendinput !{lbutton}
return


Using your last code now too. Working good so far.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2011, 8:02 pm 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
hi again rodfell!
forever been using your script and still love it no doubt.
there's a few niggling issues I'd like to work through though.
most likely my oversight or lack of ahk ability.
I see it's been covered before in the thread but don't know if it's strictly possible.
I've been toying with some other mouse programs that provide autoscroll via middle click, or scroll via middle click and drag.
this script seems to override their functionality for the middle button however and I'm at a bit of a loss.
I don't need middle click gestures, or middle click rockers, I could even live without the scroll functionality if need be.
but full access to my middle click button seems to be essential for these programs to function alongside your script.
can you help, am I just missing the bleeding obvious here?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2011, 11:29 am 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
hey.
2 simple ways to do it
one way is just comment out *mbutton and *mbuttonup, then everything with mbutton clicks will be the same and you can still use wheelup and wheeldown macros normally. mbutton gestures and rocking won't be possible.
other option is to insert this code
Code:
m-m:                   
sendinput {mbutton}
return
mbutton can still be used for autoscroll if mbutton is pushed and released, but still works for rocking and gestures.
i don't use autoscroll so i never missed it. i think i'll add the second option to the front page script
as a general concept, gesture programs have problems dealing with windows actions that involve mouse click down as distinct from a mouse click. with lbutton this includes dragging and clicking on menu bars. mbutton is autoscroll. rbutton down is needed for right button dragging


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2011, 8:29 pm 
Offline

Joined: November 11th, 2008, 8:49 pm
Posts: 10
my bad, sorry for the delay getting back.
tbh, I didn't think it'd be so easy as deleting the mbutton entries as you mentioned, the thought occured.
it works!
well, with MouseImp Pro.
Just been toying with a proggie called Deskangel however, which has a great function to autoscroll on a middle click, and stop with another m click.
This seems to end in a total freeze, a step in the right direction to be sure however.
Thanks v much indeed, tried so many gesture programs, scripts etc, this is the one for me.
Also though, I'm having problems with assigning an alt-tab rocker eg.
~lbutton & ~rbutton::alttab
return
can you suggest a way to do this with your script pls?
Ta n' best wishes
:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2011, 2:10 pm 
Offline

Joined: October 5th, 2007, 2:21 am
Posts: 138
Location: Bundaberg (Bundy), Qld, Australia
don't understand why deleting mbutton entries wouldn't stop interference with your deskangel program

getting something like lbutton & rbutton::alttab to work along side a rocking program is a big ask.

i'm going to rewrite this code over the next few months to see if some of these kinks can be sorted out


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo and 23 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