mai9 wrote:
I have one suggestion: could you recode it in a way that on a window that it is snapped to a corner (let's say low-right) when I click on the low-right part of it and then move the cursor low-right, that makes the window grow on the other corner?
Thanks for your interest and sorry for losing this resize behavior once snapped.
With this updated code there are config parameters (the KDE_P_.. variables) to turn on/off all changes I made from the original behavior.
In this code all options are set to behave 'as in the original'.
Code:
; Easy Window Dragging -- KDE style (requires XP/2k/NT) -- by Jonny
; http://www.autohotkey.com
; This script makes it much easier to move or resize a window:
; 1) Hold down the ALT key and LEFT-click anywhere inside a window to drag it to a new location;
; 2) Hold down ALT and RIGHT-click-drag anywhere inside a window to easily resize it;
; 3) Press ALT twice, but before releasing it the second time,
; left-click to minimize the window under the mouse cursor,
; right-clickt o maximize it, or middle-click to close it.
; This script was inspired by and built on many like it
; in the forum. Thanks go out to ck, thinkstorm, Chris,
; and aurelian for a job well done.
; Change history:
; Sept 09; 2009: Restore the resizing mode once window is snapped (see option KDE_P_SnapOpposite)
; July 23; 2009: Adapted to dual screen; configuarble hot keys, escape restes move/resize (cf JlrJlr)
; December 04, 2007: Window snap-to-edge - just like KDE, but with extra fun! (or @ corz.org ;o)
; November 07, 2006: Optimized resizing code in !RButton, courtesy of bluedawn.
; February 05, 2006: Fixed double-alt (the ~Alt hotkey) to work with latest versions of AHK.
; The Double-Alt modifier is activated by pressing
; Alt twice, much like a double-click. Hold the second
; press down until you click.
;
; The shortcuts:
; Alt + Left Button : Drag to move a window.
; Alt + Right Button : Drag to resize a window.
; Double-Alt + Left Button : Minimize a window.
; Double-Alt + Right Button : Maximize/Restore a window.
; Double-Alt + Middle Button : Close a window.
;
; You can optionally release Alt after the first
; click rather than holding it down the whole time.
;
; Snap-To Edges. by (or .. Tuesday Dec 04, 2007
;
; I added snap-to for the windows. If their edge comes within ten pixels
; of your desktop edge, the window snaps to it. Very neat; it's what KDE
; does. But there's more..
;
; If you keep mousing after the window snaps, you get a beautiful
; resizing control which keeps on going. Also you can Alt-right-click
; any oversized windows and pop them straight back into the desktop.
; Note: If you are quick enough, you can break the snap when needed.
; Have fun!
; ;o)
;
;jlr
;added
; Snap is ok with dual Screens and task bar (see options KDE_P_SnapBorder and KDE_P_SnapMargin)
; if window is moved into the 'other' dual screen it can jump direcly (see option KDE_P_DualJump)
; Modifier hot keys, and Mouse bouton, are configurable (see below example replacing Alt by LWin or Ctrl)
; The "double Alt hit" effect can be also obtain by pressing a third key (crtl+win)
; Cursor changes shape : "hand" when moving; "arrow" when resizing
; Escape to restore window position (Press "Ecs" while a mouse button is still down)
; window is divided in 3x3 grid. (see option KDE_P_Resize33Grid)
; Depending where the cursor is at start, the opposite part of window does not move
; i.e. if mouse in 9 => 1 does not move .. if in 5 "center" does not move
; LButton (Move) pressed while RButton (Resize) is down makes move override the resize
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;============================= Set your preferences ============================
;-------------------------------------------------------------------------------
; The original Alt
KDE_P_HotMod1 = ! ;HotKey modifier as prefix of HotKey for L/R/M Buttons
KDE_P_HotMod2 = Alt ;key name corresponding to KDE_P_HotMod1
KDE_P_AltDblKey = Lwin ;Alternative Key for 'Double' for L/R/M Button
; Use Win
;KDE_P_HotMod1 = # ;Hotkey modifier as prefix of Hotkey for L/R/M Buttons
;KDE_P_HotMod2 = LWin ;key name corresponding to KDE_P_HotMod1
;KDE_P_AltDblKey = Ctrl ;Alternative Key for 'Double' for L/R/M Button
; Use Ctrl
;KDE_P_HotMod1 = ^ ;HotKey modifier as prefix of HotKey for L/R/M Buttons
;KDE_P_HotMod2 = Ctrl ;key name corresponding to KDE_P_HotMod1
;KDE_P_AltDblKey = Lwin ;Alternative Key for 'Double' for L/R/M Button
; mouse button Selection for Move/Resize
KDE_P_LButton = LButton ;Original Move Button
KDE_P_RButton = RButton ;Original Resize Button
;KDE_P_LButton = RButton ;Original Move Button
;KDE_P_RButton = LButton ;Original Resize Button
;Snap zone and margin :
KDE_P_SnapBorder = 10 ;Border zone (in Pixel) where snap occurs
KDE_P_SnapMargin = 0 ;Margin (in Pixel) left when snaped
;KDE_P_SnapBorder = 20 ;Border zone (in Pixel) where snap occurs
;KDE_P_SnapMargin = 1 ;Margin (in Pixel) left when snaped
;Resize behaviour once snapped :
KDE_P_SnapOpposite := true ;once snapped Resize opposite corner (true) -original-
;KDE_P_SnapOpposite := false ;once snapped Stop resize (False)
;Moved behaviour when window enter other dual screen
KDE_P_DualJump := false ;when moved window Enter the other dual Screen Continue moving smoothly (false)
;KDE_P_DualJump := true ;when moved window enter the other dual screen Jump to it (true)
; Divide win in nXn grid. Depending where the cursor is at start, the opposite part of win does not move
KDE_P_Resize33Grid := false ; 2x2 -Original-
;KDE_P_Resize33Grid := true ; 3x3 Rezising can be limited to borders and Special rezising of center
;-------------------------------------------------------------------------------
; ========================== End of preferences ================================
;Cursor shape constants
IDC_HAND := 32649
IDC_SIZENWSE := 32642
IDC_SIZENESW := 32643
IDC_SIZEWE := 32644
IDC_SIZENS := 32645
IDC_SIZEALL := 32646
If (A_AhkVersion < "1.0.39.00")
{
MsgBox,20,,This script may not work properly with your version of AutoHotkey. Continue?
IfMsgBox,No
ExitApp
}
; This is the setting that runs smoothest on my
; system. Depending on your video card and cpu
; power, you may want to raise or lower this value.
SetWinDelay,2
CoordMode,Mouse,Screen
;Dynamique seting of hot kets acording to preferences
;Hotkey,*%KDE_P_HotMod1%LButton, On_LButton
;Hotkey,*%KDE_P_HotMod1%RButton, On_Rbutton
Hotkey,*%KDE_P_HotMod1%%KDE_P_LButton%, On_LButton
Hotkey,*%KDE_P_HotMod1%%KDE_P_RButton%, On_Rbutton
Hotkey,*%KDE_P_HotMod1%MButton, On_Mbutton
Hotkey,*%KDE_P_HotMod1%Escape, On_Escape
hotkey,~%KDE_P_HotMod2%, On_DblMod1
;Screen area is reduced to exclude the area occupied by the taskbar and other registered desktop toolbars.
; with additional margin if required KDE_P_SnapMargin
KDE_Dual := 0 ;KDE_Dual 0 => No DualScreen, 1 => Second Screen is Right, -1 Second Screen is Left
SysGet, KDE_Mon1, MonitorWorkArea , 1
KDE_Mon1Left += KDE_P_SnapMargin
KDE_Mon1Top += KDE_P_SnapMargin
KDE_Mon1Right -= KDE_P_SnapMargin
KDE_Mon1Bottom -= KDE_P_SnapMargin
SysGet, KDE_Mon2, MonitorWorkArea , 2
If KDE_Mon2Left !=
{
KDE_Dual := KDE_Mon2Left>0 ? 1 : -1 ;KDE_Dual 0 => No DualScreen, 1 => Second Screen is Right, -1 Second Screen is Left
KDE_Mon2Left += KDE_P_SnapMargin
KDE_Mon2Top += KDE_P_SnapMargin
KDE_Mon2Right -= KDE_P_SnapMargin
KDE_Mon2Bottom -= KDE_P_SnapMargin
}
Return
;Return in what screen is a given X value (for dual screen)
;----------------------------------------------------------
WhatScreen(x)
; x : x coordinate of a point in screen
;Returns 1 or 2 depending wether X is in Dual Screen 1 or 2
; if called for non dual seting, it always return 1
{
global KDE_Dual
If KDE_Dual
{
If (KDE_Dual=1) { ;Second Screen is on the Right
ii := x<A_ScreenWidth ? 1 : 2
}Else{ ;Second Screen is on the left
ii := x>0 ? 1 : 2
}
Return ii
}
Else
Return 1
}
;Set variables with init window and mouse poistion
;------------------------------------------------
IniWinPos:
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
;Save Mouse pos
KDE_X0 := KDE_X1
KDE_Y0 := KDE_Y1
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win ;1 if Maximized
KDE_id=
Else
; Get the initial window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW1,KDE_WinH1,ahk_id %KDE_id%
;Save win pos to be able to cancel move/resize
KDE_WinX0 := KDE_WinX1
KDE_WinY0 := KDE_WinY1
KDE_WinW0 := KDE_WinW1
KDE_WinH0 := KDE_WinH1
If KDE_Id00=
{
KDE_WinX00 := KDE_WinX1
KDE_WinY00 := KDE_WinY1
KDE_WinW00 := KDE_WinW1
KDE_WinH00 := KDE_WinH1
KDE_Id00 := KDE_id
}
Return
;Escape proc
;---------------
On_Escape:
;Restaure last moved window
If KDE_id00!=
{
WinMove,ahk_id %KDE_id00%,, %KDE_WinX00% , %KDE_WinY00% , %KDE_WinW00% ,%KDE_WinH00%
WinActivate, ahk_id %KDE_id00%
}
Return
;LButton proc = Move
;----------------
On_LButton:
GetKeyState,KDE_Button,%KDE_P_AltDblKey%,P ; DoubleAlt alternative
If KDE_Button = D
DoubleAlt := true
If DoubleAlt ;Minimize window
{
MouseGetPos,,,KDE_id
; This message is mostly equivalent to WinMinimize,
; but it avoids a bug with PSPad.
PostMessage,0x112,0xf020,,,ahk_id %KDE_id%
DoubleAlt := false
Return
}
;Move mode
;------------
; Get the initial mouse position in KDE_X1;KDE_Y1 and window pos in KDE_Win X Y H W 1
; abort if the window is maximized. KDE_id returned empty
Gosub IniWinPos
If KDE_id=
Return
;set cursor shape
SetSystemCursor(IDC_HAND)
SetTimer, TrackMouse_LButton, 10 ; Track the Mouse as the user drags it.
Return
TrackMouse_LButton:
GetKeyState, KDE_Button, Escape, P ; Cancel drag by pressing 'Escape'
If KDE_Button = D
{
SetTimer, TrackMouse_LButton, off
RestoreCursors()
WinMove,ahk_id %KDE_id00%,,%KDE_WinX00%,%KDE_WinY00% ; Move the window to init saved position.
Return
}
; GetKeyState,KDE_Button,LButton,P ; Break if Button has been released.
GetKeyState,KDE_Button,%KDE_P_LButton%,P ; Break if Button has been released.
If KDE_Button = U
{
SetTimer, TrackMouse_LButton, off
RestoreCursors()
If (KDE_Dual and KDE_P_DualJump) ;in dual mode if win move stops in Between 2 Screens, force to fully move to other Screen
Gosub Do_DualJump
;Check if Rbutton still down
; GetKeyState,KDE_Button,RButton,P
GetKeyState,KDE_Button,%KDE_P_RButton%,P
If KDE_Button = D
Gosub On_Rbutton
Else
KDE_Id00=
Return
}
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current Mouse position.
KDE_DX := KDE_X2 - KDE_X1 ; Obtain an offset from the previous Mouse position.
KDE_DY := KDE_Y2 - KDE_Y1
If (KDE_DX=0 and KDE_DY=0 )
Return
KDE_X1 := KDE_X2 ; set the initial cursor position to new one
KDE_Y1 := KDE_Y2
Gosub Do_Move
Return
Do_Move:
; move the window
KDE_WinX2 := KDE_WinX1 + KDE_DX ; Apply this offset to the window position.
KDE_WinY2 := KDE_WinY1 + KDE_DY
WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
;get ready for next action
KDE_WinX1 := KDE_WinX2 ;reset window position (like WinGetPos)
KDE_WinY1 := KDE_WinY2
If (KDE_Dual and KDE_P_DualJump) ;in dual mode if win move stops in Between 2 Screens, force to fully move to other Screen
Gosub Do_DualJump
Return
Do_DualJump:
;In dual Screen, if moved window has entered the other screen, finishes the move
;Return if it does not cross the limit
If (WhatScreen(KDE_WinX2) <> WhatScreen(KDE_WinX2+KDE_WinW0)) { ;Window across 2 dual Screens
CoordMode,Mouse,Relative
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current Mouse position.
If (WhatScreen(KDE_WinX0)=2) {
KDE_WinX2 := KDE_WinX0 - KDE_Dual*KDE_Mon1Right ; move from 2 to 1, finish move in 1
} Else {
KDE_WinX2 := KDE_WinX0 + KDE_Dual*KDE_Mon1Right ; move from 2 to 1, finish move in 1
}
WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
WinActivate, ahk_pid %KDE_id%
MouseMove, KDE_X2,KDE_Y2 , 0 ; Speed instant move cursor on to window
CoordMode,Mouse,Screen
Gosub IniWinPos
}
Return
;RButton function = Resize
;----------------
On_Rbutton:
GetKeyState,KDE_Button,%KDE_P_AltDblKey%,P ; DoubleAlt alternative
If KDE_Button = D
DoubleAlt := true
If DoubleAlt ; Toggle Between Maximized and Restored state.
{
MouseGetPos,,,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
WinRestore,ahk_id %KDE_id%
Else
WinMaximize,ahk_id %KDE_id%
DoubleAlt := false
Return
}
;Resize mode
;-----------
; Get the initial mouse position in KDE_X1;KDE_Y1 and window pos in KDE_Win X Y H W 1
; abort if the window is maximized. KDE_id returned empty
Gosub IniWinPos
If KDE_id=
Return
; mouse position in window on grid
If (KDE_P_Resize33Grid) {
; mouse position in window in 3X3 grid
; WinLeft -1;0;1 and WinUp -1;0;1
; =>coordinate (WinLeft;WinUp) are From uperleft corner (-1;-1) to lower rigth (1;1) center is (0;0)
MPosX := (3*(KDE_X1-KDE_WinX1)) // KDE_WinW1
KDE_WinLeft := (MposX<1) ? 1 : (Mposx<2) ? 0 : -1
MPosy := (3*(KDE_Y1-KDE_WinY1)) // KDE_WinH1
KDE_WinUp := (Mposy<1) ? 1 : (Mposy<2) ? 0 : -1
} Else {
; mouse position in window in 2X2 grid
; WinLeft -1;1 and WinUp -1;1
; =>coordinate (WinLeft;WinUp) are From uperleft corner (-1;-1) to lower rigth (1;1)
MPosX := (2*(KDE_X1-KDE_WinX1)) // KDE_WinW1
KDE_WinLeft := (MposX<1) ? 1 : -1
MPosy := (2*(KDE_Y1-KDE_WinY1)) // KDE_WinH1
KDE_WinUp := (Mposy<1) ? 1 : -1
}
;set cursor shape according to grid position
If (KDE_WinLeft*KDE_WinUp = 1)
SetSystemCursor(IDC_SIZENWSE)
Else If (KDE_WinLeft = 0 and KDE_WinUp = 0)
SetSystemCursor(IDC_SIZEALL)
Else If (KDE_WinLeft = 0 )
SetSystemCursor(IDC_SIZENS)
Else If (KDE_WinUp = 0 )
SetSystemCursor(IDC_SIZEWE)
Else
SetSystemCursor(IDC_SIZENESW)
; In case of dual screen
; Define the "screen" region the window is currently in.
; set the boundaries
If (WhatScreen(KDE_WinX1 + (KDE_WinW1 / 2)) = 1) {
KDE_WinXMin := KDE_Mon1Left
KDE_WinXMax := KDE_Mon1Right
KDE_WinYMin := KDE_Mon1Top
KDE_WinYMax := KDE_Mon1Bottom
} Else {
KDE_WinXMin := KDE_Mon2Left
KDE_WinXMax := KDE_Mon2Right
KDE_WinYMin := KDE_Mon2Top
KDE_WinYMax := KDE_Mon2Bottom
}
;if initial window position is past screen right, or screen botom, get it back
KDE_WinX1 := KDE_WinX1<1 ? 1 : KDE_WinX1
If (KDE_WinX1 + KDE_WinW1 > KDE_WinXMax - KDE_P_SnapBorder)
KDE_WinX1 := KDE_WinXMax - KDE_WinW1
KDE_WinY1 := KDE_WinY1<1 ? 1 : KDE_WinY1
If (KDE_WinY1 + KDE_WinH1 > KDE_WinYMax - KDE_P_SnapBorder)
KDE_WinY1 := KDE_WinYMax - KDE_WinH1
KDE_X1 += 1 ;force a small move of cursor for immediate calculate of TrackMouse_RButton
SetTimer, TrackMouse_RButton, 10 ; Track the Mouse as the user drags it.
Return
TrackMouse_RButton:
GetKeyState, KDE_Button, Escape, P
If KDE_Button = D ; Escape has been pressed, rezise is Cancelled. => restaure win to init pos and size
{
SetTimer, TrackMouse_RButton, off
RestoreCursors()
WinMove,ahk_id %KDE_id00%,, %KDE_WinX00% , %KDE_WinY00% , %KDE_WinW00% ,%KDE_WinH00%
KDE_Id00=
Return
}
GetKeyState,KDE_Button,%KDE_P_LButton%,P ; if LButton has been pressed. switch to Move mode
If KDE_Button = D
{
SetTimer, TrackMouse_RButton, off
RestoreCursors()
Gosub On_LButton
Return
}
GetKeyState,KDE_Button,%KDE_P_RButton%,P ; Break if Button has been released.
If KDE_Button = U
{
SetTimer, TrackMouse_RButton, off
RestoreCursors()
KDE_Id00=
Return
}
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current Mouse position.
KDE_DX := KDE_X2 - KDE_X1 ; Obtain an offset from the previous Mouse position.
KDE_DY := KDE_Y2 - KDE_Y1
If (KDE_DX=0 and KDE_DY=0 )
Return
KDE_X1 := KDE_X2 ; set the initial cursor position to new one
KDE_Y1 := KDE_Y2
;calculation of Rezised new dimension according to grid position
If (KDE_WinLeft=0 and KDE_WinUp=0) {
;Resize on center => balloon
KDE_WinX2 := Round(KDE_WinX1 - 0.5*KDE_DX) ; X of Resized window
KDE_WinY2 := Round(KDE_WinY1 - 0.5*KDE_DY) ; Y of Resized window
KDE_WinW2 := KDE_WinW1 + KDE_DX ; W of Resized window
KDE_WinH2 := KDE_WinH1 + KDE_DY ; H of Resized window
} Else {
; Then, compute position according to the defined region.
KDE_WinX2 := Round(KDE_WinX1 + (KDE_WinLeft=1 ? 1 : 0) *KDE_DX) ; X of Resized window
KDE_WinY2 := Round(KDE_WinY1 + (KDE_WinUp=1 ? 1 : 0) *KDE_DY) ; Y of Resized window
KDE_WinW2 := Round(KDE_WinW1 - KDE_WinLeft *KDE_DX) ; W of Resized window
KDE_WinH2 := Round(KDE_WinH1 - KDE_WinUp *KDE_DY) ; H of Resized window
}
; snap the window to the edge of the screen if closer than KDE_P_SnapBorder pixels..
; X and Width
If (KDE_P_SnapOpposite) { ;if off Limit make sanp and keep Resize on opposite side
If (KDE_WinX2 < KDE_WinXMin + KDE_P_SnapBorder) {
KDE_WinW2 := Min((KDE_WinW2 + (KDE_WinXMin - KDE_WinX2)), KDE_WinXMax)
KDE_WinX2 := KDE_WinXMin
}
If (KDE_WinX2 + KDE_WinW2 > KDE_WinXMax - KDE_P_SnapBorder) {
KDE_WinX2 := Max(KDE_WinXMin,(KDE_WinXMax - KDE_WinW2))
KDE_WinW2 := KDE_WinXMax - KDE_WinX2
}
} Else { ;if off Limit snap then block resizing
If (KDE_WinX2 < KDE_WinXMin + KDE_P_SnapBorder)
KDE_WinX2 := KDE_WinXMin
If (KDE_WinX2 + KDE_WinW2 > KDE_WinXMax - KDE_P_SnapBorder)
KDE_WinW2 := KDE_WinXMax - KDE_WinX2
}
KDE_WinW2 := Min(Max(100,KDE_WinW2),KDE_WinXMax)
; KDE_WinW2 := Min(KDE_WinW2,KDE_WinXMax)
; Y and Height
If (KDE_P_SnapOpposite) { ;if off Limit make sanp and keep Resize on opposite side
If (KDE_WinY2 < KDE_WinYMin + KDE_P_SnapBorder) {
KDE_WinH2 := Min((KDE_WinH2 + (KDE_WinYMin - KDE_WinY2)), KDE_WinYMax)
KDE_WinY2 := KDE_WinYMin
}
If (KDE_WinY2 + KDE_WinH2 > KDE_WinYMax - KDE_P_SnapBorder) {
KDE_WinY2 := Max(KDE_WinYMin,(KDE_WinYMax - KDE_WinH2))
KDE_WinH2 := KDE_WinYMax - KDE_WinY2
}
} Else { ;if off Limit snap then block resizing
If (KDE_WinY2 < KDE_WinYMin + KDE_P_SnapBorder)
KDE_WinY2 := KDE_WinYMin
If (KDE_WinY2 + KDE_WinH2 > KDE_WinYMax - KDE_P_SnapBorder)
KDE_WinH2 := KDE_WinYMax - KDE_WinY2
}
KDE_WinH2 := Max(KDE_WinH2,100)
KDE_WinH2 := Min(KDE_WinH2,KDE_WinYMax)
; Then, act according to the new position
WinMove,ahk_id %KDE_id%,, %KDE_WinX2% , %KDE_WinY2% , %KDE_WinW2% ,%KDE_WinH2%
;get ready for next action
KDE_WinX1 := KDE_WinX2 ;reset window position (like WinGetPos)
KDE_WinY1 := KDE_WinY2
KDE_WinW1 := KDE_WinW2
KDE_WinH1 := KDE_WinH2
Return
;MButton function : move in sight all far away windows
;-----------------
On_Mbutton:
GetKeyState,KDE_Button,%KDE_P_AltDblKey%,P ; DoubleAlt alternative
If KDE_Button = D
DoubleAlt := true
If DoubleAlt ; Exit window
{
MouseGetPos,,,KDE_id
WinClose,ahk_id %KDE_id%
DoubleAlt := false
Return
}
; all windows OUt of sight are moved back
;---------------------------------------
;in dual mode min max including 2 screens
KDE_WinYMin := KDE_Mon1Top
KDE_WinYMax := KDE_Mon1Bottom
KDE_WinXMin := KDE_Dual=-1 ? KDE_Mon2Left : KDE_Mon1Left
KDE_WinXMax := KDE_Dual=1 ? KDE_Mon2Right : KDE_Mon1Right
WinGet, id, list
Loop, %id%
{
this_id := id%A_Index%
WinGet,KDE_Win,MinMax,ahk_id %this_id%
WinGetTitle, this_title, ahk_id %this_id%
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW1,KDE_WinH1,ahk_id %this_id%
IsWinOut := false
; check all windows if far out (mignht be in 'ab'normal state) => if so resize on main screen
If (KDE_WinX1<-32000 or KDE_WinW1>(KDE_WinXMax+100)) {
IsWinOut := true
KDE_WinX1 := 10
KDE_WinW1 := 500
}
If (KDE_WinY1<-32000 or KDE_WinH1>(KDE_WinYMax+100)) {
IsWinOut := true
KDE_WinY1 := 10
KDE_WinH1 := 300
}
;for all window 'normal' check if out => if so move bac on view (snap) on main screen
If (KDE_Win>-1 and this_title!="" and !IsWinOut) ;-1 Minimize, 0=Normal 1=Maxi, skip window with no tittle (of Class "static" such as vbScroll et Siber Agent)
{
If (KDE_WinH1 < 100) {
IsWinOut := true
KDE_WinH1 := 100
}
If (KDE_WinW1 < 100) {
IsWinOut := true
KDE_WinW1 := 100
}
If (KDE_WinW1 > KDE_Mon1Right) {
IsWinOut := true
KDE_WinW1 := KDE_Mon1Right-KDE_P_SnapBorder
}
If (KDE_WinX1 > KDE_WinXMax-KDE_P_SnapBorder) {
IsWinOut := true
KDE_WinX1 := KDE_WinXMax - KDE_WinW1
} Else If (KDE_WinX1+KDE_WinW1 < KDE_WinXMin+KDE_P_SnapBorder) {
IsWinOut := true
KDE_WinX1 := KDE_WinXMin
}
If (KDE_WinY1 > KDE_WinYMax - KDE_P_SnapBorder) {
IsWinOut := true
KDE_WinY1 := KDE_WinYMax - KDE_WinH1
} Else If (KDE_WinY1+KDE_WinH1 < KDE_WinYMin+KDE_P_SnapBorder) {
IsWinOut := true
KDE_WinY1 := KDE_WinYMin
}
}
; else
; msgbox, Skip of <%this_title%> KDE_Win <%KDE_Win%>
If (IsWinOut) {
MsgBox,4,,Come back of <%this_title%> KDE_Win <%KDE_Win%> ?
IfMsgBox Yes
{
WinMove,ahk_id %this_id%,, %KDE_WinX1% , %KDE_WinY1% , %KDE_WinW1% ,%KDE_WinH1%
WinActivate, ahk_id %this_id%
}
}
}
Return
; This detects "double-press" of the Mod1 key.
;------------------------------------------
On_DblMod1:
DoubleAlt := A_PriorHotkey = "~"KDE_P_HotMod2 AND A_TimeSincePriorHotkey < 1000
Sleep 0
KeyWait %KDE_P_HotMod2% ; This prevents the keyboard's auto-Repeat feature from interfering.
Return
;############# Min # Return lower value of two values ###########################
Min( value1, value2 )
{
If ( value1 < value2 )
Return value1
Else
Return value2
}
;############# Max # Return upper value of two values ###########################
Max( value1, value2 )
{
If ( value1 > value2 )
Return value1
Else
Return value2
}
;############# SetSystemCursor # Set cursor shape ###########################
;############# RestoreCursors # ReSet cursor shape ###########################
;by Serenity on Sat Sep 13, 2008 7:14 pm;
;Post : Changing the system cursor
;http://www.autohotkey.com/forum/topic35600.html+icon+set
;IDC_ARROW := 32512
;IDC_IBEAM := 32513
;IDC_WAIT := 32514
;IDC_CROSS := 32515
;IDC_UPARROW := 32516
;IDC_SIZE := 32640
;IDC_ICON := 32641
;IDC_SIZENWSE := 32642
;IDC_SIZENESW := 32643
;IDC_SIZEWE := 32644
;IDC_SIZENS := 32645
;IDC_SIZEALL := 32646
;IDC_NO := 32648
;IDC_HAND := 32649
;IDC_APPSTARTING := 32650
;IDC_HELP := 32651
SetSystemCursor(IDC_x)
{
CursorHandle := DllCall( "LoadCursor", Uint,0, Int,IDC_x )
Cursors = 32512,32513,32514,32515,32516,32640,32641,32642,32643,32644,32645,32646,32648,32649,32650,32651
Loop, Parse, Cursors, `,
{
DllCall( "SetSystemCursor", Uint,CursorHandle, Int,A_Loopfield )
}
}
RestoreCursors()
{
SPI_SETCURSORS := 0x57
DllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 )
}