AutoHotkey Community

It is currently May 26th, 2012, 8:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: July 3rd, 2008, 10:30 pm 
Offline

Joined: April 10th, 2008, 10:08 pm
Posts: 111
Basically, it's this script with the ability to accept middle clicks and a built-in program launcher. I thought it was pretty neat. Example gestures included.

Code:
; ========================================================================
; ============================ Mouse Gestures ============================
; ========================================================================
; Simple Mouse Gestures
; http://www.autohotkey.com/forum/viewtopic.php?t=25330&postdays=0&postorder=asc&start=0

; for the program launcher
NumOfProggies = 4
Proggy1s = Calculator
Proggy1 = calc.exe
Proggy2s = Foobar 2000
Proggy2 = C:\Program Files\foobar2000\foobar2000.exe
Proggy3s = Notepad
Proggy3 = notepad.exe
Proggy4s = Notepad++
Proggy4 = C:\freeware\text\Notepad Plus\notepad++.exe


xbutton1::
rbutton::
if getkeystate("rbutton","p")
xbutton=
else
xbutton=x    ;add an "x" if using 4th mouse button
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

xbutton1 up::
rbutton up::
if not gesturemode
   return
settimer, gesture, off
hotkey, lbutton, off      ;re-enables normal left click
GestureMode = 0
gesture := "g" . xbutton . 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::
wheeldir=wheelup
gosub, wheel
return

WheelDown::
wheeldir=wheeldown
gosub, wheel
return

MButton::
wheeldir=mbutton
gosub, wheel
return

wheel:
If GestureMode ;we're currently recording a gesture
{
   If (SubStr(gesture, 0) <> "w")
       gesture := "g" . xbutton . gesture . "w"   
   if islabel(gesture)
      gosub, %gesture%
}
Else ;we're not recording a gesture so just do a wheelup or wheeldown
{
Sendinput {%wheeldir%}
}
Return


g:          ;normal right click
click, right, xpos1, ypos1
exit


ProggyListUp:
n += 1
if n > %NumOfProggies%
   n = 1
Goto ProggyNextStep
ProggyListDown:
n -= 1
if n < 1
   n = %NumOfProggies%
ProggyNextStep:
Display := Proggy%n%s
Launch := Proggy%n%
ToolTip, %Display%
;SetTimer, ToolKill, -2200
SetTimer, ProggyToolTip, 20
return

ProggySend:
  SetTimer, ProggyToolTip, Off
ToolTip
Run, %Launch%
return

ProggyToolTip:
if GetKeyState("RButton", "P")
  {
  Sleep, 10
  ToolTip, %Display%
  }
else
  {
  ToolTip
  SetTimer, ProggyToolTip, Off
  }
return

; ----- Actual Gestures -----
; end normal gestures (not wheel gestures) with an "exit" instead of "return".


gw:   ; Mini-Program Launcher. Hold Right-Click and scroll through programs with wheel. Middle Click to launch.
ToolTip, Scroll the wheel to select a program
if wheeldir=wheelup
Goto ProggyListUp
else if wheeldir=wheeldown
Goto ProggyListDown
else if wheeldir=mbutton
Goto ProggySend
return


glw:   ;change volume with wheel - gesture left then use wheel keeping the right button down   
if wheeldir=wheelup
Send {Volume_Up}
else if wheeldir=wheeldown
Send {Volume_Down}
else if wheeldir=mbutton
Send {Volume_Mute}
return    ;end wheel gestures with a "return" NOT "exit"    !!!!!!!!


grw:   ; Media Next/Back/Play/Pause controls
if wheeldir=wheelup
Send {Media_Next}
else if wheeldir=wheeldown
Send {Media_Prev}
else if wheeldir=mbutton
Send {Media_Play_Pause}
return


guw:   ; Zoom in/out in Firefox 3
if wheeldir=wheelup
Send {Ctrl down}{+}{Ctrl up}
else if wheeldir=wheeldown
Send {Ctrl down}-{Ctrl up}
else if wheeldir=mbutton
Msgbox Zoom in/out in Firefox 3`n`nGesture Up + Wheel: Scroll up for zooming in, down for zooming out`n(ctrl+, ctrl-)
return





glr:   ; Run URL/Shortcut Paster
Run C:\freeware\system utils\AutoHotkey\#scripts\#sub\mouselink gui shortcuts.ahk
exit

glrlr:   ; Run Xplorer2
Run C:\freeware\system utils\file managers\xplorer2_lite\xplorer2_lite.exe
exit

gudu:   ; Run Screen Lock
Run C:\freeware\system utils\AutoHotkey\#scripts\#sub\screen lock (instant).ahk
exit

guru:   ; Run Notepad++
Run C:\freeware\text\Notepad Plus\notepad++.exe
exit

gudlr:   ; close the current window
WinClose, A
exit

gul:   ; toggle alwaysontop
WinSet, AlwaysOnTop, Toggle, A
exit

_________________
I slit the sheet, the sheet I slit,
and on the slitted sheet I sit. ;~}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], fusion1920, Google [Bot], SKAN, Stigg, tomL and 18 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