 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Sun Apr 13, 2008 5:32 pm Post subject: move an window to edge of screen [Func] |
|
|
| Code: | ; Simply moves an window to edge of screen
; ______________
; |LU RU|
; | |
; | |
; |LB RB|
; `````(``)``````
; /``````\
Edge(wTitle, Pos="LU")
{
IfWinExist, %wTitle%
{
WinGetPos,,,w,h
SysGet, WMax, 16
SysGet, HMax, 17
SysGet, HB, 31
If pos = LU
WinMove, %wTitle%,,0, 0
Else If pos = LB
{
HH := HMax - h + HB
WinMove, %wTitle%,,0, %HH%
}
Else If pos = RU
{
WW := WMax - w
WinMove, %wTitle%,,%WW%, 0
}
Else If pos = RB
{
WW := WMax - w
HH := HMax - h + HB
WinMove, %wTitle%,,%WW%, %HH%
}
}
}
;Example:
F9::Edge("Untitled - Notepad")
F10::Edge("Untitled - Notepad", "RU")
F11::Edge("Untitled - Notepad", "LB")
F12::Edge("Untitled - Notepad", "RB")
|
not much tested |
|
| Back to top |
|
 |
Oberon
Joined: 18 Feb 2008 Posts: 458
|
Posted: Mon Apr 14, 2008 1:49 pm Post subject: |
|
|
That's pretty useful. You've inspired me to write my own version (hope you don't mind):
| Code: | SetTitleMatchMode, 2
MoveWindow(4, false, "Notepad") ; example
MoveWindow(Quadrant = 1, Center = false, WinTitle = "", WinText = "", ExcludeTitle = "", ExcludeText = "") {
IfWinNotExist, %WinTitle%, %WinText%, %ExcludeTitle%, %ExcludeText%
Return
WinGetPos, , , w, h
SysGet, m, MonitorWorkArea
If Center = 1
mRight := w + (mRight - mLeft) // 2, mBottom := h + (mBottom - mTop) // 2
q := Quadrant
If q not in 1,2,3,4
q = 1
If q in 2,3
x = %mLeft%
Else If q in 1,4
x := mRight - w
If q in 1,2
y = %mTop%
Else If q in 3,4
y := mBottom - h
WinMove, %x%, %y%
} |
You can use it to position within the centre bound as well as screen edges (see diagram):
 |
|
| Back to top |
|
 |
airjrdn
Joined: 25 Feb 2008 Posts: 35
|
Posted: Mon Apr 14, 2008 2:42 pm Post subject: |
|
|
I've been using a hacked up version of WindowPad (found here on AHK), but would like a trimmed down version. It allows you to hold a key and use the keys on the numeric keypad to move the active window to any corner or middle screen edge. The key I like to use for that is the Windows key.
Edit - I built a basic version that works using the Windows key & numeric keypad.
| Code: |
#Numpad1::
MoveWin("LB")
return
#Numpad2::
MoveWin("MB")
return
#Numpad3::
MoveWin("RB")
return
#Numpad4::
MoveWin("LM")
return
#Numpad5::
MoveWin("MM")
return
#Numpad6::
MoveWin("RM")
return
#Numpad7::
MoveWin("LT")
return
#Numpad8::
MoveWin("MT")
return
#Numpad9::
MoveWin("RT")
return
MoveWin(MoveToPosition)
{
WinGetActiveTitle, Title
SysGet, m, MonitorWorkArea
WinGetPos, , , w, h, A ; "A" to get the active window's pos.
if InStr(MoveToPosition, "LB") > 0
{
x := 0
y := mBottom - h
}
if InStr(MoveToPosition, "MB") > 0
{
x := (mRight / 2) - (w / 2)
y := mBottom - h
}
if InStr(MoveToPosition, "RB") > 0
{
x := mRight - w
y := mBottom - h
}
if InStr(MoveToPosition, "LM") > 0
{
x := 0
y := (mBottom / 2) - (h / 2)
}
if InStr(MoveToPosition, "MM") > 0
{
x := (mRight / 2) - (w / 2)
y := (mBottom / 2) - (h / 2)
}
if InStr(MoveToPosition, "RM") > 0
{
x := mRight - w
y := (mBottom / 2) - (h / 2)
}
if InStr(MoveToPosition, "LT") > 0
{
x := 0
y := 0
}
if InStr(MoveToPosition, "MT") > 0
{
x := (mRight / 2) - (w / 2)
y := 0
}
if InStr(MoveToPosition, "RT") > 0
{
x := mRight - w
y := 0
}
WinMove, %Title%,, %x%, %y%
}
|
|
|
| Back to top |
|
 |
holomind
Joined: 11 Mar 2006 Posts: 300 Location: Munich, Germany
|
|
| Back to top |
|
 |
airjrdn
Joined: 25 Feb 2008 Posts: 35
|
Posted: Wed Apr 16, 2008 3:33 pm Post subject: |
|
|
| That one is very close, but it resizes the window for keys 2,4,6,8 whereas mine just centers it on those edges. I think I will adjust it to match my functionality because of it's compactness though. Thanks for sharing! |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Thu Apr 17, 2008 2:42 am Post subject: |
|
|
thanks for improvements
and also thanks for the notice holomind
i think it's good as it is that we can gather all related scripts here!  |
|
| 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
|