 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Laszlo
Joined: 14 Feb 2005 Posts: 4016 Location: Pittsburgh
|
Posted: Tue Aug 01, 2006 2:31 am Post subject: Select the position and size of windows, with preview |
|
|
GroupBoxes are highlighted if they are of style 0x1000. Their title text is left justified in style 0x1100, otherwise it is centered on the top edge. This feature allows dynamic changing of the GUI, like when some GroupBoxes represent window positions, the current selection can be shown.
The following script allows choosing the size and position of the active window from a number of predetermined ones. When Win-W is pressed a little GUI window pops up, with the outline of all the possible window positions. It remains on screen until the Win key is released. When this GUI is visible, pressing the keys 0,1…7 highlights the corresponding window position in the GUI. Pressing a new digit changes the highlight. When the Win key is finally released, the last selected position and size is assigned to the active window. Esc cancels the process, without changing the foreground window.
| Code: | SysGet m, MonitorWorkArea
mW := mRight-mLeft
mH := mBottom-mTop
mX := mW//4
mY := mH//5
mA := mW//10
mB := mH//10
#w::
WinGet ID, ID, A
A = ahk_ID %ID%
Gui Add, GroupBox, x10 y05 w400 h300, 0
Gui Add, GroupBox, x25 y20 w300 h240, 1
Gui Add, GroupBox, x95 y20 w300 h240, 2
Gui Add, GroupBox, x25 y50 w300 h240, 4
Gui Add, GroupBox, x95 y50 w300 h240, 3
Gui Add, GroupBox, x70 y70 w280 h170, 5
Gui Add, GroupBox, x88 y88 w244 h144, 6
Gui Add, GroupBox, x106 y106 w208 h118, 7
Gui +AlwaysOnTop -Caption +Border
Gui Show
Postn =
Loop {
Loop 8
If GetKeyState(A_Index-1,"P") {
GuiControl -0x1100,%Postn% ; Remove highlight of last GroupBox
GuiControl hide, %Postn%
GuiControl show, %Postn% ; Redraw last GroupBox
Postn := A_Index-1 ; New selection
GuiControl +0x1100,%Postn% ; Highlight new GroupBox
}
If !GetKeyState("LWin","P") ; Repeat while LWin is pressed
Break
If GetKeyState("Esc","P") { ; Cancel
Gui Destroy
Return
}
Sleep 10 ; Give time for others
}
Gui Destroy ; Close position-selecting GUI
IfEqual Postn,0, WinMaximize %A%
Else {
WinGet MM, MinMax, %A%
IfEqual MM,1, WinRestore %A% ; Moved a maximized window behaves as maximized
IfEqual Postn,1, WinMove %A%,, mLeft, mTop, mW-mX, mH-mY
Else IfEqual Postn,2, WinMove %A%,, mLeft+mX, mTop, mW-mX, mH-mY
Else IfEqual Postn,3, WinMove %A%,, mLeft+mX, mTop+mY, mW-mX, mH-mY
Else IfEqual Postn,4, WinMove %A%,, mLeft, mTop+mY, mW-mX, mH-mY
Else IfEqual Postn,5, WinMove %A%,, mLeft+mA, mTop+mB, mW-mA*2, mH-mB*2
Else IfEqual Postn,6, WinMove %A%,, mLeft+mA*2, mTop+mB*2, mW-mA*4, mH-mB*4
Else IfEqual Postn,7, WinMove %A%,, mLeft+mA*3, mTop+mB*3, mW-mA*6, mH-mB*6
}
Return |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 5887
|
Posted: Tue Aug 01, 2006 6:32 am Post subject: |
|
|
Very nice utility Mr.Laszlo!
Just 56 lines! ... If I had tried, it would have been 200+.
Thanks for sharing. It will be very helpful for me.
Regards,  _________________ SKAN - Suresh Kumar A N |
|
| Back to top |
|
 |
Eleria
Joined: 09 May 2006 Posts: 92
|
Posted: Tue Aug 01, 2006 8:54 am Post subject: |
|
|
Utterly amazing Laszlo...
Though the script itself is not complicated, you did get the idea and thats great ^_^ _________________
Looking for a game/anime ost? |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Tue Aug 01, 2006 9:04 am Post subject: |
|
|
Wonderful! I liked the way you used the GroupBoxes and Buttons together. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
vogg Guest
|
Posted: Sun Aug 06, 2006 10:13 am Post subject: |
|
|
| That's really nice! |
|
| Back to top |
|
 |
nick Guest
|
Posted: Tue Aug 08, 2006 11:28 am Post subject: |
|
|
Here's the pic.
 |
|
| Back to top |
|
 |
_adam Guest
|
Posted: Fri Mar 21, 2008 6:41 pm Post subject: |
|
|
wow, that's nice. a bigger/clearer preview would be nice. I've been looking for a window move/resize script/s and I'm getting a lot of ideas here for personal use.
thanks laszlo. beautiful script. |
|
| Back to top |
|
 |
Azerty
Joined: 19 Dec 2006 Posts: 72 Location: France
|
Posted: Fri Mar 21, 2008 11:32 pm Post subject: |
|
|
Hi Laszlo
Nice one. Would be nicer though combined with iason's positioning
If anyone has time to mix-match, it would be great |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4016 Location: Pittsburgh
|
Posted: Sat Mar 22, 2008 12:10 am Post subject: |
|
|
| How should it work, then? |
|
| 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
|