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.
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