 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
cor
Joined: 05 Dec 2007 Posts: 5
|
Posted: Wed Dec 05, 2007 8:20 pm Post subject: |
|
|
HAHA! I just knew that if I dropped that, and left it a day, some clever bod would come up with the goods!
Cheers. man!
;o)
(or |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 7698 Location: Germany (but I only speak English)
|
Posted: Thu Dec 06, 2007 12:43 am Post subject: |
|
|
| cor wrote: | | ...and left it a day... |
And by "a day" you mean "7 minutes", right? _________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me. |
|
| Back to top |
|
 |
cor
Joined: 05 Dec 2007 Posts: 5
|
Posted: Thu Dec 06, 2007 1:17 am Post subject: |
|
|
Now let's not get all mixed up! I was referring to my intent, which was in the past tense, so yes, I did mean a day.
HOWEVER, your response was rather quick; I hadn't realized how quick, yes, it deserves mention!
HOWEVER, I posted that before I had a user account, and so didn't receive a notification, and, as intended, returned after a day!
Anyways, I now have a super-dooper KDE-resizing+X-Window hovering script, culled from above and your link, and working superbly, too. Thanks again!
;o)
(or |
|
| Back to top |
|
 |
Thracx
Joined: 12 Mar 2007 Posts: 13
|
Posted: Tue Feb 19, 2008 12:12 am Post subject: |
|
|
Thanks all for your work on this script - I don't know the back story (i.e. I've not familiar with KDE), but regardless, it's a much better way to easily resize windows!
Regarding 'Snapping' - I currently use allSnap like many of you do.. how hard do you it would be to write an AHK script that does everything AHK does? Thanks to cor, this script does some snapping but it only snaps to edges, not other windows or a pre-defined Grid.
I know it's slightly a waste re-inventing the wheel, but I don't think any more work is going to be done with allSnap so if we had an AHK script that does the same thing, I'm sure many people will think of brilliant ways to further enhance it. I for one, would simply like to consolidate all my 'little gadgets' into a single Master Gadget - and AHK is doing that like a charm thus-far! _________________ -Thracx
"Man wants to know, and when he ceases to do so, he is no longer a man."
-Fridtjof Nansen |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 490
|
Posted: Thu Feb 21, 2008 2:58 pm Post subject: |
|
|
Was also this considered here. (I'm using this since I discovered it some days ago.)
? What is better in your KDE-style?
? What is worse ... ? |
|
| Back to top |
|
 |
cor
Joined: 05 Dec 2007 Posts: 5
|
Posted: Thu Feb 28, 2008 1:03 pm Post subject: |
|
|
I use MacroExpress for all my window positioning - most of the macros are many years old, used hundreds of times a day. Ctrl+Alt+Keypad; each key in the grid roughly equating to the position the window gets thrown to. I hadn't considered AHK for this. Anyways, back to *this* script; what is better? and worse?
In truth, I find the auto window raising is too problematic on Windows, and I never have gotten the time to really sink my teeth into a script for that, probably never will. I know the built-in implementation sucks, and can sometimes be a pain to disable again.
ALT-Resizing and Moving is essential, though, and anyone reading this who hasn't yet tried it, you must! Add edge-snapping, and it can make your desktop life infinitely easier; the way you can use the edge as an anchor, and resize from any direction is very intuitive.
By the way, I find KDE's snapping to other windows, irritating. I guess it's just the way I run my desktop. Also, I like space around things, in a compositional sense. Windows jammed up against each other makes me uneasy, unless perhaps the two windows were of exact equal edge lengths, where there could cohere into a unit, like Winamp. But I'm straying..
I have a habit now of resizing (ALT-Right click), throwing windows off-screen (ALT-Left click), and lastly a quick right-click to instantly snap them right back inside the edge of the desktop; a 1-2-3 that's become instinctive and quick. Everyone else's puter is suddenly unusable to me until I install this!
I have a widescreen monitor myself, and tend to keep explorer windows wide and no more than a third of screen-height; scattered left and right of my main task windows, only the edges visible - it's easy to maintain a dozen or more open folders, and get to any of them by simply butting the mouse up to the edge of the screen. Anything to make puter life easier!
;o)
(or |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 490
|
Posted: Thu Feb 28, 2008 3:49 pm Post subject: |
|
|
| Why are you using your complex toolbars rather than the superfast nDroid? |
|
| Back to top |
|
 |
Grogs Guest
|
Posted: Sun Jul 20, 2008 5:53 pm Post subject: |
|
|
| In regards to cor's edited version of the scripts: Is it just me, or does the snap to edges feature only work for resizing, and not for moving? I'd much prefer it if it also applied snapping just when moving windows. |
|
| Back to top |
|
 |
cor
Joined: 05 Dec 2007 Posts: 5
|
Posted: Thu Nov 13, 2008 5:57 pm Post subject: |
|
|
Grogs, I don't know how difficult it might be to make it snap on moving, it's not something I intent to look at; it would interfere with my working style.
As I mentioned, when I want to move a window to the edge, I move it off the edge, and then switch from left to a swift right-click, which snaps it back, takes microseconds. Try it. Also, from there, you can place your mouse at the very edge, and left-click and drag the window up and down the edge of your desktop like it's on rails. Pretty neat.
..
I should mention while I'm here, my version of this script (I did a page for it at corz.org, with an .exe, info, source, etc) got featured on LifeHacker, and has been downloaded over 3000 times, so far. It's also generated quite a few thankful emails, as well as some more AutoHotkey hackers.
Good work, guys!
;o)
(or |
|
| Back to top |
|
 |
Mr. Goodbar
Joined: 21 Nov 2008 Posts: 4
|
Posted: Sat Nov 29, 2008 6:13 am Post subject: |
|
|
| Love the script, but I notice its behavior is quirky with Emacs: moving works fine, but when resizing the mouse doesn't stay inside the Emacs frame. This is with native windows Emacs 22/23. Anyone else seeing this? |
|
| Back to top |
|
 |
nshmourne
Joined: 09 Nov 2008 Posts: 6
|
Posted: Wed Jul 15, 2009 6:59 pm Post subject: |
|
|
The script is awesome!
I'm wondering if anyone had tried removing the double alt part of it? I love the alt move and resize, but despise the double alt actions.
I'm attempting to edit it myself, but I'm really not a great scripter. |
|
| Back to top |
|
 |
jlrjlr
Joined: 23 Jul 2009 Posts: 3
|
Posted: Thu Jul 23, 2009 5:30 pm Post subject: |
|
|
| nshmourne wrote: | | I'm wondering if anyone had tried removing the double alt part of it? |
Here is a version where you can to activate the 'double alt'
by hiting a third key (such LWin).
This does more such as snaping ok with dual screen (the main reason I adapted it). In addition the keys are configurables.
I hope it helps
| 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:
; 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
; Modifier hot keys are configurable (see below example replacing Alt by LWin or Ctrl)
; The "double Alt hit" efect can be also obtain by pressing a third key (crtl+win)
; Cursor changes shape : "hand" when moving; "arrow"ingwhen resizing
; escape" to restore window position (Press "Ecs" while the mouse button is still down)
#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
KDE_P_SnapBorder = 10 ;Border zone (in pixel) where snap occurs
KDE_P_SnapMargin = 1 ;Margin (in pixel) left when snaped
;----------------------
; End of preferences
;Cursor shape constants
IDC_HAND := 32649
IDC_SIZENWSE := 32642
IDC_SIZENESW := 32643
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
;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%Mbutton, On_Mbutton
hotkey,~%KDE_P_HotMod2%, On_DblMod1
SysGet, KDE_ScreenWidth, 78 ;idem A_ScreenWidth in mono screen
SysGet, KDE_ScreenHeight, 79 ;idem A_ScreenHeight in mono screen
;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
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_Mon2Left += KDE_P_SnapMargin
KDE_Mon2Top += KDE_P_SnapMargin
KDE_Mon2Right -= KDE_P_SnapMargin
KDE_Mon2Bottom -= KDE_P_SnapMargin
}
return
IniWinPos:
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
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
return
;LButton function = Move
;----------------
On_LButton:
GetKeyState,KDE_Button,%KDE_P_AltDblKey%,P ; DoubleAlt alternative
If KDE_Button = D
DoubleAlt := true
If DoubleAlt
{
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
if KDE_Button = D ; Escape has been pressed, so drag is cancelled.
{
SetTimer, TrackMouse_LButton, off
RestoreCursors()
WinMove,ahk_id %KDE_id%,,%KDE_WinX0%,%KDE_WinY0% ; Move the window to init saved position.
Return
}
GetKeyState,KDE_Button,LButton,P ; Break if button has been released.
If KDE_Button = U
{
SetTimer, TrackMouse_LButton, off
RestoreCursors()
return
}
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
KDE_Y2 -= KDE_Y1
KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position.
KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
return
;RButton function = Resize
;----------------
On_Rbutton:
GetKeyState,KDE_Button,%KDE_P_AltDblKey%,P ; DoubleAlt alternative
If KDE_Button = D
DoubleAlt := true
If DoubleAlt
{
MouseGetPos,,,KDE_id
; Toggle between maximized and restored state.
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
; Define the window region the mouse is currently in.
; The four regions are Up and Left, Up and Right, Down and Left, Down and Right.
If (KDE_X1 < KDE_WinX1 + KDE_WinW1 / 2)
KDE_WinLeft := 1
Else
KDE_WinLeft := -1
If (KDE_Y1 < KDE_WinY1 + KDE_WinH1 / 2)
KDE_WinUp := 1
Else
KDE_WinUp := -1
;set cursor shape
If (KDE_WinLeft*KDE_WinUp=1)
SetSystemCursor(IDC_SIZENWSE)
Else
SetSystemCursor(IDC_SIZENESW)
; In case of dual screen
; Define the "screen" region the window is currently in.
; set the boundaries
KDE_WinXMin := KDE_Mon1Left
KDE_WinXMax := KDE_Mon1Right
KDE_WinYMin := KDE_Mon1Top
KDE_WinYMax := KDE_Mon1Bottom
If ((KDE_ScreenWidth > A_ScreenWidth) and (KDE_WinX1 + KDE_WinW1 / 2 > A_ScreenWidth )) {
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
if (KDE_WinX1 + KDE_WinW1 > KDE_WinXMax - KDE_P_SnapBorder)
KDE_WinX1 := KDE_WinXMax - KDE_WinW1
if (KDE_WinY1 + KDE_WinH1 > KDE_WinYMax - KDE_P_SnapBorder)
KDE_WinY1 := KDE_WinYMax - KDE_WinH1
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, so drag is cancelled.
{
SetTimer, TrackMouse_RButton, off
RestoreCursors()
WinMove,ahk_id %KDE_id%,, %KDE_WinX0% , %KDE_WinY0% , %KDE_WinW0% ,%KDE_WinH0%
Return
}
GetKeyState,KDE_Button,RButton,P ; Break if button has been released.
If KDE_Button = U
{
SetTimer, TrackMouse_RButton, off
RestoreCursors()
return
}
MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
KDE_Y2 -= KDE_Y1
; Then, compute position according to the defined region.
KDE_WinX2 := KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2 ; X of resized window
KDE_WinY2 := KDE_WinY1 + (KDE_WinUp+1)/2*KDE_Y2 ; Y of resized window
KDE_WinW2 := KDE_WinW1 - KDE_WinLeft *KDE_X2 ; W of resized window
KDE_WinH2 := KDE_WinH1 - KDE_WinUp *KDE_Y2 ; H of resized window
; snap the window to the edge of the screen if closer than KDE_P_SnapBorder pixels..
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
if KDE_WinW2 < 10
KDE_WinW2 := 10
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
if KDE_WinH2 < 10
KDE_WinH2 := 10
; 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
KDE_X1 += KDE_X2 ; Reset the initial cursor position
KDE_Y1 += KDE_Y2
Return
; "Alt + MButton" may be simpler, but I
; like an extra measure of security for
; an operation like this.
;MButton function
;-----------------
On_Mbutton:
GetKeyState,KDE_Button,%KDE_P_AltDblKey%,P ; DoubleAlt alternative
If KDE_Button = D
DoubleAlt := true
If DoubleAlt
{
MouseGetPos,,,KDE_id
WinClose,ahk_id %KDE_id%
DoubleAlt := false
return
}
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
;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 )
}
|
|
|
| Back to top |
|
 |
mai9
Joined: 18 Mar 2008 Posts: 57 Location: Barcelona, Catalonia
|
Posted: Mon Aug 31, 2009 8:20 am Post subject: |
|
|
jlrjlr, thanks for this version that works in dual screens.
I was surprised to see that it left a single pixel when snapping to edges, later I saw that that's an option (not a bug ). if anyone faces that situation take a look at the variable "KDE_P_SnapMargin".
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?
I was using cor's script before (which does not resize on dual screens), which has that behaviour, and I am missing that now. |
|
| Back to top |
|
 |
jlrjlr
Joined: 23 Jul 2009 Posts: 3
|
Posted: Fri Sep 11, 2009 11:54 am Post subject: |
|
|
| 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 )
}
|
|
|
| Back to top |
|
 |
mih Guest
|
Posted: Sun Nov 29, 2009 11:45 pm Post subject: Multi-Monitor |
|
|
Hi there,
sry, I discovered this update just now - until now, I wasn't aware of another multi-monitor support, so I added it as well, based on the version cor had on his page. Mine is layout-independent, so if you don't want to set Dual to -1 or 1 depending on whether the screen is right or left, I might suggest a look at the version on cor's page (
http://corz.org/windows/software/accessories/KDE-resizing-moving-for-XP-or-Vista.php )
Also, a few other things were added, such as ini-file, menu for configuration options, etc.
But it still lacks the configurability options for 3x3 grid, mouse cursors and configurable hotkeys.
I don't have the time right now, but hope to find some time to merge the two versions (or maybe someone else wants to?)
In the meantime, again to all contributer - great script, will never again work without it anymore on Win
Cheers,
Matthias |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|