AutoHotkey Community

It is currently May 27th, 2012, 7:38 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: September 10th, 2006, 4:27 pm 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
Update: New Version with Gui at the end of thread. (i keep the old posts as code-examples, perhaps i will clean up this thread later as the idea with _r is not so good and x-y zones are much easier. also moving the current version to post #1, but i'd like to have the small scripts in the beginning as the version with gui looks complicated at first glance. )

the thumbnails for this screenshot/gui-illustration were created by another script from me.
Save Screen as Thumnail with gdiplus -Script.

Image

and quick download of this script (gui-version)
gesture_movewin.ahk (6 kB)
gesture_movewin.exe (200 kB)

.....


Hi, Based opon other scripts and rewriting some parts i have now a simple gesture script, which then calls normal hotkeys.

The script is inteded to be minimal so you can use gestures without a lot of extra functions. the gestures are all direct lines no complicate corners. only angle and distance

the zones work automatically, zone_x_y_r
which means xpos, ypos, r=radius or distance, the numbers are not negative but "10" = -1, "00" = 0 , "01" = +1, because otherwise i cound not do variable lookup that easy.
the formular perhaps looks a bit weird but this way you can define your hotspots very easy without huge definitions and if clauses.
the x and y are normalized and only have values from -1 to 1 in the funny syntax above, so you get the "angle" with the radius you can add more functions if move further away from the center. if you want to cancel then move your mouse back to the start position. the tooltip always shows your selection and which command will be triggered. if you move to far then the last command will stay, this way its easy to select. you should adjust the variable g_size to feel comfortable (small enough to be fast, and big enough to select different functions easily).

i used some other scripts of the forum for gestures but they were quite complicate.


Code:
#SingleInstance force
Gosub, DetectScreen
g_size    := 30 ; ca. way to drag gesture for 1 radius

zone_x00_y10_r2 = MOVE WIN FULLSIZE|#{Numpad0}
zone_x10_y10_r2 = MOVE WIN UP_LEFT|#{Numpad7}
zone_x10_y10_r1 = MOVE WIN UP_LEFT|#{Numpad7}
zone_x00_y10_r1 = MOVE WIN UP|#{Numpad8}
zone_x01_y10_r1 = MOVE WIN UP_RIGHT|#{Numpad9}
zone_x01_y10_r2 = MOVE WIN UP_RIGHT|#{Numpad9}
zone_x10_y00_r2 = GOTO PREV TASK|!{Esc}
zone_x10_y00_r1 = MOVE WIN LEFT|#{Numpad4}
zone_x00_y00_r1 = |{Esc}
zone_x01_y00_r1 = MOVE WIN RIGHT|#{Numpad6}
zone_x01_y00_r2 = GOTO NEXT TASK|!+{Esc}
zone_x10_y01_r1 = MOVE WIN DOWN_LEFT|#{Numpad1}
zone_x10_y01_r2 = MOVE WIN DOWN_LEFT|#{Numpad1}
zone_x00_y01_r1 = MOVE WIN DOWN|#{Numpad2}
zone_x01_y01_r1 = MOVE WIN DOWN_RIGHT|#{Numpad3}
zone_x01_y01_r2 = MOVE WIN DOWN_RIGHT|#{Numpad3}
zone_x00_y01_r2 = MOVE WIN CENTER_HALF|#{Numpad5}

GestureButton = RButton ; you can change it to MButton if you like
Hotkey, %GestureButton% ,  DoGesture

#Numpad7::WinMove, A,, mLeft      ,mTop      ,mW/2   ,mH/2      ; Top Left     H H
#Numpad8::WinMove, A,, mLeft      ,mTop      ,mW      ,mH/2      ; Top          F H
#Numpad9::WinMove, A,, mLeft+mW/2   ,mTop      ,mW/2   ,mH/2      ; Top Right    H H
#Numpad4::WinMove, A,, mLeft      ,mTop      ,mW/2   ,mH         ; Left         H F
#Numpad5::WinMove, A,, mLeft+mW/6   ,mTop      ,mW/1.5   ,mH         ; Center      H F
#Numpad6::WinMove, A,, mLeft+mW/2   ,mTop      ,mW/2   ,mH         ; Right         H F
#Numpad1::WinMove, A,, mLeft      ,mTop+mH/2   ,mW/2   ,mH/2      ; Bottom Left    H H
#Numpad2::WinMove, A,, mLeft      ,mTop+mH/2   ,mW    ,mH/2      ; Bottom       H F
#Numpad3::WinMove, A,, mLeft+mW/2   ,mTop+mH/2   ,mW/2   ,mH/2      ; Bottom Right    H H
#Numpad0::WinMove, A,, mLeft      ,mTop       ,mW      ,mH         ; Full         F F

DetectScreen:
   WinGetPos,Tx,Ty,Tw,Th,ahk_class Shell_TrayWnd,,,
   mLeft :=                 ( Tw > Th  and  Tx = 0  and  Ty = 0) * Th
   mTop  :=                 ( Tw < Th  and  Tx = 0  and  Ty = 0) * Tw
   mH    := A_ScreenHeight  -  ( Tw > Th  ) * Th
   mW    := A_ScreenWidth   -  ( Tw < Th  ) * Tw
Return

DoGesture:
    MouseGetPos,X1,Y1,id
    MouseGetPos,X2,Y2
    zone =
    zone_cmd2 =
   zone_cmd1 =
   Loop {
       ButtonDown:=GetKeyState( GestureButton ,"P")
       IfNotEqual,ButtonDown,1,Break
       
      MouseGetPos,X2,Y2
       r := sqrt( (X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1) )
      zone := "x" (-(X2-X1) > g_size) "" ((X2-X1) > g_size) "_y" (-(Y2-Y1) > g_size) "" ( (Y2-Y1) > g_size ) "_r" ceil( r /g_size/5)
      StringSplit, zone_cmd,zone_%zone%, |   
       Tooltip,  % zone_cmd1
       Sleep,15 ; To reduce load on CPU
    }
   
   if ( zone_cmd1 <> "" and zone_cmd2 <> "" )
      Send, %zone_cmd2%   ; execute defined command
   else
       Send, {%GestureButton%}
    ToolTip ; clear
Return


the code is related to this one
http://www.autohotkey.com/forum/viewtopic.php?p=76998

I started a new thread as the main purpose here is to show the easy usage of gestures.

A smaller Version with only demonstrating copy and paste with drag up and drag down gestures, should you get started easily
Code:
#SingleInstance force
g_size    := 30 ; ca. way to drag gesture for 1 radius

;area = Comment | hotkey
zone_x00_y10_r1 = Copy|^c           ; gesture drag up for copy
zone_x00_y00_r1 = |{Esc}            ; center = cancle action
zone_x00_y01_r1 = Paste|^v          ; gesture drag down for paste

GestureButton = RButton ; you can chang it to MButton if you like
Hotkey, %GestureButton% ,  DoGesture

DoGesture:
    MouseGetPos,X1,Y1,id
    MouseGetPos,X2,Y2
    zone =
    zone_cmd2 =
   zone_cmd1 =
   Loop {
       ButtonDown:=GetKeyState( GestureButton ,"P")
       IfNotEqual,ButtonDown,1,Break
       
      MouseGetPos,X2,Y2
       r := sqrt( (X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1) )
      zone := "x" (-(X2-X1) > g_size) "" ((X2-X1) > g_size) "_y" (-(Y2-Y1) > g_size) "" ( (Y2-Y1) > g_size ) "_r" ceil( r /g_size/5)
      StringSplit, zone_cmd,zone_%zone%, |   
       Tooltip,  % zone_cmd1
       Sleep,15 ; To reduce load on CPU
    }
   
   if ( zone_cmd1 <> "" and zone_cmd2 <> "" )
      Send, %zone_cmd2%   ; execute defined command
   else
       Send, {%GestureButton%}
    ToolTip ; clear
Return   


This is the pattern of the "zones":
Code:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ x10 y10 r2               +  x00 y10 r2  +                  x01 y10 r2  +
+            ++++++++++++++++++++++++++++++++++++++++++++++              +
+            + x10 y10 r1  +  x00 y10 r1   + x01 y10 r1   +              +
+            ++++++++++++++++++++++++++++++++++++++++++++++              +
+ x10 y00 r2 + x10 y00 r1  +  x00 y00 r1   + x01 y00 r1   +  x01 y00 r2  +
+            ++++++++++++++++++++++++++++++++++++++++++++++              +
+            + x10 y01 r1  +  x00 y01 r1   + x01 y01 r1   +              +
+            ++++++++++++++++++++++++++++++++++++++++++++++              +
+ x10 y01 r2               +  x00 y01 r2   +                 x01 y01 r2  +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Last edited by holomind on September 22nd, 2006, 9:50 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2006, 10:08 pm 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
Another Version, bigger and tweaked, instead of radius, there are only x and y zones. the v and < arrows point to start point. at this point perhaps a real gui or image would be better. but this is enough for the beginning.
I have added a little frame (border) so aiming is much easier. it is shown with delay so it does not interfere to much with normal right-click.

Code:
#SingleInstance force
CoordMode Mouse, Screen
Gosub, DetectScreen
g_size  := 25 ; ca. way to drag gesture for 1 radius

zone_x20_y20 = . >>vv    # Prev|{Backspace}
zone_x10_y20 = . > vv    # FULL Style ---|#8
zone_x00_y20 = .   vv    - FULL SIZE|#{Numpad0}
zone_x01_y20 = .   vv <  # FULL Style +++|#9
zone_x02_y20 = .   vv << # Next|+{Backspace}

zone_x10_y10 = . > v    # UP-LEFT|#{Numpad7}
zone_x00_y10 = .   v    ! UP|#{Numpad8}
zone_x01_y10 = .   v <  # UP-RIGHT|#{Numpad9}

zone_x20_y00 = .  >>    - PREV TASK|!{Esc}
zone_x10_y00 = .   >    - LEFT|#{Numpad4}
zone_x00_y00 =           |{Esc}
zone_x01_y00 = . <      - RIGHT|#{Numpad6}
zone_x02_y00 = . <<     - NEXT TASK|!+{Esc}

zone_x20_y02 = . > ^^   # Expose|{F10}
zone_x10_y01 = . > ^    # DOWN-LEFT|#{Numpad1}
zone_x00_y01 = .   ^    ! DOWN|#{Numpad2}
zone_x01_y01 = .   ^ <  # DOWN-RIGHT|#{Numpad3}
zone_x02_y02 = .   ^^ < # Desktop|{F9}

zone_x00_y02 = .   ^^   - CENTER SIZE|#{Numpad5}

GestureButton = RButton ; you can chang it to MButton if you like
Hotkey, %GestureButton% ,  DoGesture

#Numpad7::WinMove, A,, mLeft        ,mTop       ,mW/2   ,mH/2       ; Top Left      H H
#Numpad8::WinMove, A,, mLeft        ,mTop       ,mW     ,mH/2       ; Top           F H
#Numpad9::WinMove, A,, mLeft+mW/2   ,mTop       ,mW/2   ,mH/2       ; Top Right     H H
#Numpad4::WinMove, A,, mLeft        ,mTop       ,mW/2   ,mH         ; Left          H F
#Numpad5::WinMove, A,, mLeft+mW/6   ,mTop       ,mW/1.5 ,mH         ; Center        H F
#Numpad6::WinMove, A,, mLeft+mW/2   ,mTop       ,mW/2   ,mH         ; Right         H F
#Numpad1::WinMove, A,, mLeft        ,mTop+mH/2  ,mW/2   ,mH/2       ; Bottom Left   H H
#Numpad2::WinMove, A,, mLeft        ,mTop+mH/2  ,mW     ,mH/2       ; Bottom        H F
#Numpad3::WinMove, A,, mLeft+mW/2   ,mTop+mH/2  ,mW/2   ,mH/2       ; Bottom Right  H H
#Numpad0::WinMove, A,, mLeft        ,mTop       ,mW     ,mH         ; Full          F F

#8::WinSet, Style, +0xC00000, A
#9::WinSet, Style, -0xC00000, A
 


DetectScreen:
    WinGetPos,Tx,Ty,Tw,Th,ahk_class Shell_TrayWnd,,,
    border := 4
    mLeft :=                    ( Tw > Th  and  Tx = 0  and  Ty = 0) * Th + border / 2
    mTop  :=                    ( Tw < Th  and  Tx = 0  and  Ty = 0) * Tw + border / 2
    mH    := A_ScreenHeight  -  ( Tw > Th  ) * Th - border
    mW    := A_ScreenWidth   -  ( Tw < Th  ) * Tw - border
Return

DoGesture:
    MouseGetPos,X1,Y1,id
    MouseGetPos,X2,Y2
    SetTimer, DrawFrame , 300 ; Delay

    zone =
    zone_cmd2 =
    zone_cmd1 =
    Loop {
       ButtonDown:=GetKeyState( GestureButton ,"P")
       IfNotEqual,ButtonDown,1,Break
       
       MouseGetPos,X2,Y2
       dx := X2-X1
       dy := Y2-Y1
       
      ; r := sqrt( dx*dx + dy*dy )
       zone := "x"  ceil((-dx > g_size) * abs(dx)/g_size/5)  "" ceil((dx > g_size) * abs(dx)/g_size/5) "_y" ceil((-dy > g_size) * abs(dy)/g_size/5) "" ceil((dy > g_size) * abs(dy)/g_size/5) ; "_r" ceil( r /g_size/5)
       StringSplit, zone_cmd,zone_%zone%, |
       Tooltip,  % zone_cmd1 ; zone
      Sleep,15 ; To reduce load on CPU
    }
   
    if ( zone_cmd1 <> "" and zone_cmd2 <> "" )
    {
        StringLeft zone_cmd2a, zone_cmd2, 1
        if zone_cmd2a = #
            WinActivate, ahk_id %id%
        Send, %zone_cmd2%   ; execute defined command
    }
    else
    {
        SetTimer, DrawFrame, off
        Gui, Hide   
        Send, {%GestureButton%}
    }
    ToolTip ; clear
    Gui, Hide
Return

DrawFrame:
    SetTimer, DrawFrame, off
    Rz := 100
    Gui +AlwaysOnTop -Caption +ToolWindow +E0x20 +0x800000
    Gui Color, 0x00CCCCCC
    MouseGetPos x, y
    Gui, +Lastfound ; Make the GUI window the last found window.
    WinSet TransColor, 0x00CCCCCC
    Gui Show, % "w" 2*Rz " h" 2*Rz " x" x-Rz " y" y-Rz, Frame
Return




Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2006, 11:03 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nice presentation and description. Your ideas will be useful when/if the time comes to integrate mouse gestures into AutoHotkey.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2006, 11:26 am 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
thanks, didnt think about integrating it into ahk directly.
then they would be auto-hot-gestures ;) the idea of mapping the gestures directly to hotkeys (simulate pressing keys) is a bit weird, but this way the scripts get smaller and they are more in the ahk idea, of mapping a keypress with a function.
i personally prefer the version of the second post as its more accurate to choose the zones, after a while of "training" i turned of the frame, as i dont need it anymore.
one drawback is that you cant simulate complicated gestures like "left-right-down" but these were confusing to me all the time, i could not remember them and they are hard to draw and reproduce. this one only pointing into hot-"zones" with tooltip feedback is much more *relaxed*.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2006, 1:10 am 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
Hi,

the code gets a bit longer, but is getting better.

This version now has a gui for the gesture zones. this way its much much easier to find the zones, also you have an hint which zone to use as you see the text in the beginning. the tooltip is still here to give you feedback.

just try the different functions you cant break anything, (but be cautious with window close). the actions are normally applied onto the window under the mouse. this way you dont have to activeate it with click before. if you click and release your right mousebutton without moving, you still get the context menu. if you really need the drag + context menu (move , copy , alias here) you can disable the gesture with ctrl or shift, as then its not RButton but +RButton. etc.

The "Center" Move Makes Pages in Portrait-Mode (Letter/A4) for easy reading and hides all other stuff. Quite usefull if you read something or want to concentrate. this also removes the titlebar and simulates "fullscreen". if you use another gesture like "move left" then the fullscreenmode is restored. the <- and <= are cursor left or browser-back.

the gui is built on the zone_x..y.. automatically so all definition is in one place.

one could remove the pseudo arrows pointing to center, when using the gui, but i am to lazy in the moment to remove them.

This is how it looks if you rightclick and drag for the gesture, if you are in the zone and release the mouse the gesture-action is executed.

the thumbnails are only in the screenshot, in the real one its only a box with up,right,down,left. but this way you can imagine better what this script does.
Image
The real menu is now smaller than shown in this image

and quick download of this script
gesture_movewin.ahk (6 kB)

Version 0.1 Init
Version 0.2 Bugfix for screendetect top and left were swapped

Code:
#SingleInstance force
CoordMode Mouse, Screen
Gosub, DetectScreen

g_size  := 17 ; ca. way to drag gesture for 1 radius
g_border := 0
zone_x20_y20 = Desktop|{F9}
zone_x10_y20 = 360 mph|#-
zone_x00_y20 = Maximized (title)|#{Numpad0}
zone_x01_y20 = minimize|#ö
zone_x02_y20 = Fullscreen (all)|#ü

zone_x20_y10 = `n<-c|{Left}
zone_x10_y10 = @-`n-- --|#{Numpad7}
zone_x00_y10 = .@ @`n-- --|#{Numpad8}
zone_x01_y10 = -- @`n-- --|#{Numpad9}
zone_x02_y10 = `nc->|{Right}

zone_x20_y00 = PREV`nTASK|!{Esc}
zone_x10_y00 = @ --`n@ --|#{Numpad4}
zone_x00_y00 = |{Esc}
zone_x01_y00 = -- @`n-- @|#{Numpad6}
zone_x02_y00 = NEXT`nTASK|!+{Esc}

zone_x20_y01 = `n<=b|{Backspace}
zone_x10_y01 = -- --`n @ --|#{Numpad1}
zone_x00_y01 = -- --`n @ @|#{Numpad2}
zone_x01_y01 = -- --`n -- @|#{Numpad3}
zone_x02_y01 = `nb=>|+{Backspace}

zone_x20_y02 = Expose|{F10}
zone_x10_y02 = Left 2/3|#n
zone_x00_y02 = CENTER SIZE|#{Numpad5}
zone_x01_y02 = Close Tab|^w
zone_x02_y02 = Close Window|#0


file_320mph           = %A_ScriptDir%\..\320mph\320mph.ahk


GestureButton = RButton ; you can chang it to MButton if you like
Hotkey, %GestureButton% ,  DoGesture

#Numpad7::WinMove, A,, mLeft        ,mTop       ,mW/2   ,mH/2       ; Top Left      H H
#Numpad8::WinMove, A,, mLeft        ,mTop       ,mW     ,mH/2       ; Top           F H
#Numpad9::WinMove, A,, mLeft+mW/2   ,mTop       ,mW/2   ,mH/2       ; Top Right     H H
#Numpad4::WinMove, A,, mLeft        ,mTop       ,mW/2   ,mH         ; Left          H F
#n::WinMove, A,, mLeft        ,mTop       ,mW/3*2.1   ,mH         ; Left          H F
#Numpad6::WinMove, A,, mLeft+mW/2   ,mTop       ,mW/2   ,mH         ; Right         H F
#Numpad1::WinMove, A,, mLeft        ,mTop+mH/2  ,mW/2   ,mH/2       ; Bottom Left   H H
#Numpad2::WinMove, A,, mLeft        ,mTop+mH/2  ,mW     ,mH/2       ; Bottom        H F
#Numpad3::WinMove, A,, mLeft+mW/2   ,mTop+mH/2  ,mW/2   ,mH/2       ; Bottom Right  H H

#Numpad0::Gosub, WinMove_Full_WithTitle
#ü::Gosub, WinMove_Full_NoTitle
#ö::WinMinimize, ahk_id %id%

Run320Mph:
#-::
    RunWait,%file_320mph%
Return

; MButton & WheelUp::Send, !{ESC}
; MButton & WheelDown::Send, !+{ESC}

#Numpad5::Gosub, WinMove_Center

#0::Gosub, WinClose_UnderMouse

WinMove_Full_WithTitle:
   Send, #8
   WinMove, A ,, mLeft   ,mTop       ,mW ,mH         ; Center        H F
return

WinMove_Full_NoTitle:
   Send, #9
   WinMove, A ,, mLeft   ,mTop       ,mW ,mH         ; Center        H F
return


WinMove_Center:
   Send, #9    ; hide titlebar
   WinMove, ahk_id %id% ,, A_ScreenWidth/6   ,mTop       ,A_ScreenWidth/1.5 ,mH         ; Center        H F
   Gosub, WinFocus
   focused =1
return

#8::WinSet, Style, +0xC00000, A
#9::WinSet, Style, -0xC00000, A


WinClose_UnderMouse:
   if id =
      MouseGetPos,X1,Y1,id
   WinClose, ahk_id %id%
Return

WinFocus:
   Gui 1: +Owner +AlwaysOnTop -Disabled -SysMenu -Caption
   Gui 1: Color, 000001
   Gui 1: Show,NoActivate X0 Y0 W%A_ScreenWidth% H%A_ScreenHeight%,WINDOW2
   ;WinSet,Transparent,200,WINDOW2
   WinActivate,  ahk_id %id%
   WinGetActiveStats,wint,winw,winh,winx,winy
winw+=winx
winh+=winy
If winx<0
  winx=0
If winy<0
  winy=0
If wint=
{
  winx=0
  winy=0
  winw=%A_ScreenWidth%
  winh=%A_ScreenHeight%
}

   WinSet,Region,0-0 %A_ScreenWidth%-0 %A_ScreenWidth%-%A_ScreenHeight% 0-%A_ScreenHeight% 0-0  %winx%-%winy% %winw%-%winy% %winw%-%winh% %winx%-%winh% %winx%-%winy%,WINDOW2
Return

GuiInit:
    SetTimer, GuiShow, off
    ;MouseGetPos,X2,Y2
    Gui 2: Destroy
 
   Gui 2: +Owner +AlwaysOnTop -Disabled -SysMenu -Caption
      Gui 2: Color, 000002  ; use some odd unlikely to be used already
    Gui 2: +LastFound
      WinSet, TransColor, 000002
   ;WinSet, Transparent, 50
   Xmenu := ceil( X1 - ( size * g_size * 4 ) ) + g_size + g_size / 2
   Ymenu := ceil( Y1 - ( size * g_size * 4 ) ) + 2*g_size + g_size / 2
   Wmenu := ceil( size * 2 * g_size * 4) - 4* g_size
   Hmenu := ceil( size * 2 * g_size * 4) - 4* g_size

   Gui 2: Show, Hide NoActive X%Xmenu% Y%Ymenu% W%Wmenu% H%Hmenu%, MENU2

     zones = 30|20|10|00|01|02|03
    size = 3
      Loop, parse, zones , |
      {
      yzone := A_LoopField
      y := A_Index -size -1
      Loop, parse, zones , |
          {
         xzone := A_LoopField
         x := A_Index -size -1
         zone := zone_x%xzone%_y%yzone%
         if zone <>
         {
            zone_gcmd1 =
                StringSplit, zone_gcmd,zone, |
            X3 := x * 4*g_size + 8*g_size
            Y3 := y * 4*g_size + 8*g_size
            b_w := 4*g_size-g_border/2            
            b_h := 4*g_size-g_border/2
            if zone_gcmd1 <>
               Gui 2: Add, Text, x%X3% y%Y3% w%b_w% h%b_h% +Border +Center -Background , `n%zone_gcmd1%
         }
      }
   }         
   Gui 2: Show
   guivisible = 1
Return

GuiShow:
   SetTimer, GuiShow, off
   Gosub, GuiInit
   Gui 2: Show
Return


GuiHide:
   SetTimer, GuiShow, off
    if guivisible = 1
      Gui 2: Destroy
   guivisible = 0
Return


WinUnFocus:
   Send, #8    ; hide titlebar
   Gui 1: Destroy
   focused =
Return

DetectScreen:
    WinGetPos,Tx,Ty,Tw,Th,ahk_class Shell_TrayWnd,,,
    border := 4
    mTop  :=                    ( Tw > Th  and  Tx = 0  and  Ty = 0) * Th + border / 2
    mLeft :=                    ( Tw < Th  and  Tx = 0  and  Ty = 0) * Tw + border / 2
    mH    := A_ScreenHeight  -  ( Tw > Th  ) * Th - border
    mW    := A_ScreenWidth   -  ( Tw < Th  ) * Tw - border
Return

DoGesture:
    ;tooltip, do gesture
   MouseGetPos,X1,Y1,id
    MouseGetPos,X2,Y2
    X4 := X2 -  g_size * size
    Y4 := X2 -  g_size * size
    ;Gui 2: Show, X%X4% Y%Y4%  +Owner +AlwaysOnTop -Disabled -SysMenu -Caption
   SetTimer, GuiShow, 250
   
    zone =
    zone_cmd1 =
   Loop {
       ButtonDown:=GetKeyState( GestureButton ,"P")
       
      if ( ButtonDown <> 1 )
      {
         tooltip, error   
         Break
      }
       
       MouseGetPos,X2,Y2
       dx := X2-X1
       dy := Y2-Y1
       
      ; r := sqrt( dx*dx + dy*dy )
       zone := "x"  ceil((-dx > g_size) * abs(dx)/g_size/5.5)  "" ceil((dx > g_size) * abs(dx)/g_size/5.5) "_y" ceil((-dy > g_size) * abs(dy)/g_size/5.5) "" ceil((dy > g_size) * abs(dy)/g_size/5.5)
      zone_cmd1 =
       StringSplit, zone_cmd,zone_%zone%, |
      Tooltip,  % zone_cmd1 ; zone
      Sleep,15 ; To reduce load on CPU
    }
   Gosub, GuiHide
    Sleep, 50
    if ( zone_cmd1 <> "" and zone_cmd2 <> "" )
    {
        StringLeft zone_cmd2a, zone_cmd2, 1
        if zone_cmd2a = #
        {
          if focused = 1
            Gosub, WinUnFocus
      
         WinActivate, ahk_id %id%
      }   
        Send, %zone_cmd2%   ; execute defined command
    }
    else
    {
      Send, {%GestureButton%}
    }
    ToolTip ; clear

Return





Last edited by holomind on October 9th, 2006, 10:14 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2006, 8:40 am 
Offline

Joined: August 8th, 2006, 3:55 pm
Posts: 49
cool !!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2006, 12:39 pm 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
robiandi wrote:
cool !!


Thanks, i looked for your posts and found your optimized version of autocad menu.

hmm, with this technique, my script could be much smaller i, guess.
also the two scripts are now quite similar in usage ;)
i ignored the autocad script up to now, as i dont have autocad. perhaps a bad name for the script, as you can easily use it for any programm, like you also can use this gesturescript with any gosubs or hotkeys.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2006, 3:31 pm 
Offline

Joined: August 8th, 2006, 3:55 pm
Posts: 49
holomind wrote
Quote:
also the two scripts are now quite similar in usage
I wrote a script which combines the two ideas:
- Dragging the RBUTTON gives your gui :2
- In the areas is instead of for example NEXT TASK the name of another ahk-script ( for example test.ahk )
- when the tooltip shows test.ahk, this will trigger the start of test.ahk ( and shows the gui of test.ahk )
- in test.ahk you have OnMessage(0x205,"WM_RBUTTONUP")
- you move the mouse over the gui of test.ahk and releasing the RBUTTON will trigger the button on which is hovering the mouse

By this method you can trigger by one right-mouse-click & dragging an arbitrary set of actions on an arbitray set of gui's
( to repeat it: you press only once the RBUTTON)

(BTW, I also do not have autocad.
Maybe I shouldn't speak about 2 ideas, but it is one idea which is already contained in your gesturescript)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2006, 4:01 pm 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
@robiandi:

interesting idea, seems to be similar to the cascading radialmenu (radialm) in this forum. you could post your code so everybody can test the idea.
you even could map the startmenu into this, but for me this would be too much clutter. instead of cascading menues the radialm also supports context of the window behind, so you get different actions if you are in browser, wordprocessor or explorer etc. but this is too confusing for me. i mainly use this script to "manage" windows (moving, sizing, and back/forward)

having the gui the zones could be made much smaller, as its easier to find the target. but with big regions its easier to select (not the wrong).

i also experimented with buttons similar to the autocad-menu, but i liked the flat text-boxes more. you even can get the buttonlabel when hovering with the mouse over it. to test it simply replace the "text" with "button" in the Gui...Add... section.

for more compatibilty of the normal rightclick behavior, (moving files) one could add a function to toggle/pause the gesture script with double-right-click.
(RButton:: ... wait 250ms , if RButton again, pause := !pause ... if pause <> suspend script etc.)

i'd also like to have some transparency of the menu, so its more "smooth", but i didnt manage it, as you cant have WinSet, Transparency and WinSet TransColor at the same time. One solution would be to make a gui for each Button/Zone, which seems to inefficient.
if your Gesture-Menu is Square-size one also could make the window just as big to fit the buttons and have no background ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 18th, 2006, 5:17 am 
Offline

Joined: August 8th, 2006, 3:55 pm
Posts: 49
holomind wrote
Quote:
nteresting idea, seems to be similar to the cascading radialmenu (radialm) in this forum. you could post your code so everybody can test the idea.

Many thanks for your response and for your new version gesture_movewin.ahk

I think that it will take some time before I can have a look at radialmenu and post my code
(because of the work to be done at my job)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: thanks
PostPosted: October 5th, 2006, 12:27 pm 
Offline

Joined: August 21st, 2006, 4:29 am
Posts: 30
holomind, thank you for this script - I think it is wonderful. I used to use UltraMouse but they don't support it now.. This is a far superior replacement which I can use anywhere and I've easily merged it into my script and modified it to suit my needs..

I have removed the window re-posistioning functions and replaced with features like Restore Window, Next/Prev Tab, Always on Top & Min2Tray.

I really love this script - Thanks for your work!! :)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: nothing 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