AutoHotkey Community

It is currently May 24th, 2012, 1:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: April 13th, 2008, 5:32 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2008, 1:49 pm 
Offline

Joined: February 18th, 2008, 8:26 pm
Posts: 442
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):

Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2008, 2:42 pm 
Offline

Joined: February 25th, 2008, 4:13 pm
Posts: 37
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%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 15th, 2008, 11:23 pm 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
hi, a similar but more compact version can be found here:
http://www.autohotkey.com/forum/viewtop ... 7405#77405

you might also like a variaton of this with mouse gestures:
http://www.autohotkey.com/forum/viewtopic.php?t=12524

Greetings
Daniel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2008, 3:33 pm 
Offline

Joined: February 25th, 2008, 4:13 pm
Posts: 37
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2008, 2:42 am 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
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! :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: cmulcahy, Exabot [Bot], MSN [Bot], tomoe_uehara and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group