AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

WindowPad - multi-monitor window-moving tool
Goto page Previous  1, 2, 3 ... 9, 10, 11 ... 14, 15, 16  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Lexikos



Joined: 17 Oct 2006
Posts: 4367
Location: Qld, Australia

PostPosted: Sat Dec 20, 2008 6:38 am    Post subject: Reply with quote

Da Rossa wrote:
But let's be honest: CapsLock+[qweasdzxc] are not very comfortable,
Speak for yourself. The Capslock layout has proven to be the most efficient for me.
Quote:
Win+NumpadX, if we could use both at the same time, would be great...
The script does not impose a restriction on how many hotkeys you can use. The syntax of the INI is similar to an AHK script. It differs in the following ways:
  • = is used instead of ::
  • Each hotkey must be single-line.
  • Only custom commands are supported - these are outlined in the help file. Variables and expressions aren't supported.
  • [Hotkeys:...] sections are used to group hotkeys; hotkeys under [Hotkeys] are applied automatically. The concept is not dissimilar to #IfWin.

Try the following:
  • Open the default INI.
  • Copy the contents of the [Hotkeys: Active Window (Numpad)] section to the [Hotkeys] section.
  • Find and replace * with #.
  • Done.
Back to top
View user's profile Send private message Visit poster's website
Da Rossa



Joined: 06 Dec 2007
Posts: 326

PostPosted: Sat Dec 20, 2008 9:04 am    Post subject: Reply with quote

Thanks a lot man! It worked! Smile
_________________
AHK is perfect.
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Dec 21, 2008 2:39 pm    Post subject: Reply with quote

Hi Lexikos

Im using some of your code from windowpad to move a program in FS to a secondary display. It works great but i have a problem with quicktime. I tried solving it with the code commented out but it doesnt work anymore because i dont have the same res on the secondary display. There is probably a much better way to do this, maybe you could enlight me?



Code:
; From Windowpad by Lexikos

#<::
    WinGet, active_id, ID, A
;~    if WinActive( "ahk_class QuickTimePlayerMain" ) {
;~         Send $^f
;~         WinWaitActive, ahk_class FullScreenWindow,,,
;~         WindowScreenMove(N)
;~         }
;~         else {
;~         if( "active_id != ahk_class QuickTimePlayerMain" ) {
        WindowScreenMove(N)
        WinGet, state, MinMax, A
        if state
            WinRestore A
        else
            WinMaximize A
;~         }
;~     }
   Return
   

; Does the grunt work of the script.
MoveWindowInDirection(sideX, sideY, widthFactor, heightFactor)
{
    WinGetPos, x, y, w, h
   
    ; Determine which monitor contains the center of the window.
    m := GetMonitorAt(x+w/2, y+h/2)
   
    ; Get work area of active monitor.
    gosub CalcMonitorStats
    ; Calculate possible new position for window.
    gosub CalcNewPosition

    ; If the window is already there,
    if (newx "," newy "," neww "," newh) = (x "," y "," w "," h)
    {   ; ..move to the next monitor along instead.
   
        if (sideX or sideY)
        {   ; Move in the direction of sideX or sideY.
            SysGet, monB, Monitor, %m% ; get bounds of entire monitor (vs. work area)
            x := (sideX=0) ? (x+w/2) : (sideX>0 ? monBRight : monBLeft) + sideX
            y := (sideY=0) ? (y+h/2) : (sideY>0 ? monBBottom : monBTop) + sideY
            newm := GetMonitorAt(x, y, m)
        }
        else
        {   ; Move to center (Numpad5)
            newm := m+1
            SysGet, mon, MonitorCount
            if (newm > mon)
                newm := 1
        }
   
        if (newm != m)
        {   m := newm
            ; Move to opposite side of monitor (left of a monitor is another monitor's right edge)
            sideX *= -1
            sideY *= -1
            ; Get new monitor's work area.
            gosub CalcMonitorStats
        }
        ; Calculate new position for window.
        gosub CalcNewPosition
    }

    ; Restore before resizing...
    WinGet, state, MinMax
    if state
        WinRestore

    ; Finally, move the window!
    SetWinDelay, 0
    WinMove,,, newx, newy, neww, newh
   
    return

CalcNewPosition:
    ; Calculate new size.
    if (IsResizable()) {
        neww := Round(monWidth * widthFactor)
        newh := Round(monHeight * heightFactor)
    } else {
        neww := w
        newh := h
    }
    ; Calculate new position.
    newx := Round(monLeft + (sideX+1) * (monWidth  - neww)/2)
    newy := Round(monTop  + (sideY+1) * (monHeight - newh)/2)
    return

CalcMonitorStats:
    ; Get work area (excludes taskbar-reserved space.)
    SysGet, mon, MonitorWorkArea, %m%
    monWidth  := monRight - monLeft
    monHeight := monBottom - monTop
    return
}

; Get the index of the monitor containing the specified x and y co-ordinates.
GetMonitorAt(x, y, default=1)
{
    SysGet, m, MonitorCount
    ; Iterate through all monitors.
    Loop, %m%
    {   ; Check if the window is on this monitor.
        SysGet, Mon, Monitor, %A_Index%
        if (x >= MonLeft && x <= MonRight && y >= MonTop && y <= MonBottom)
            return A_Index
    }

    return default
}

IsResizable()
{
    WinGet, Style, Style
    return (Style & 0x40000) ; WS_SIZEBOX
}

WindowPad_WinExist(WinTitle)
{
    if WinTitle = P
        return WinPreviouslyActive()
    if WinTitle = M
    {
        MouseGetPos,,, win
        return WinExist("ahk_id " win)
    }
    return WinExist(WinTitle!="" ? WinTitle : "A")
}

; Note: This may not work properly with always-on-top windows. (Needs testing)
WinPreviouslyActive()
{
    active := WinActive("A")
    WinGet, win, List

    ; Find the active window.
    ; (Might not be win1 if there are always-on-top windows?)
    Loop, %win%
        if (win%A_Index% = active)
        {
            if (A_Index < win)
                N := A_Index+1
           
            ; hack for PSPad: +1 seems to get the document (child!) window, so do +2
            ifWinActive, ahk_class TfPSPad
                N += 1
           
            break
        }

    ; Use WinExist to set Last Found Window (for consistency with WinActive())
    return WinExist("ahk_id " . win%N%)
}


;
; Switch without moving/resizing (relative to screen)
;
WindowScreenMove(P)
{
    SetWinDelay, 0
   
    StringSplit, P, P, `,, %A_Space%%A_Tab%
    ; 1:Next|Prev|Num, 2:Window
   
    WindowPad_WinExist(P2)

    WinGet, state, MinMax
    if state = 1
        WinRestore

    WinGetPos, x, y, w, h
   
    ; Determine which monitor contains the center of the window.
    ms := GetMonitorAt(x+w/2, y+h/2)
   
    SysGet, mc, MonitorCount

    ; Determine which monitor to move to.
    if P1 in ,N,Next
    {
        md := ms+1
        if (md > mc)
            md := 1
    }
    else if P1 in P,Prev,Previous
    {
        md := ms-1
        if (md < 1)
            md := mc
    }
    else if P1 is integer
        md := P1
   
    if (md=ms or (md+0)="" or md<1 or md>mc)
        return
   
    ; Get source and destination work areas (excludes taskbar-reserved space.)
    SysGet, ms, MonitorWorkArea, %ms%
    SysGet, md, MonitorWorkArea, %md%
    msw := msRight - msLeft, msh := msBottom - msTop
    mdw := mdRight - mdLeft, mdh := mdBottom - mdTop
   
    ; Calculate new size.
    if (IsResizable()) {
        w *= (mdw/msw)
        h *= (mdh/msh)
    }
   
    ; Move window, using resolution difference to scale co-ordinates.
    WinMove,,, mdLeft + (x-msLeft)*(mdw/msw), mdTop + (y-msTop)*(mdh/msh), w, h

    if state = 1
        WinMaximize
}
Back to top
Guest






PostPosted: Sun Dec 21, 2008 2:40 pm    Post subject: Reply with quote

I forgot to mention, it works but some of the window is cropped outside the screen because of the res difference. Thats the problem
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 4367
Location: Qld, Australia

PostPosted: Sun Dec 21, 2008 9:38 pm    Post subject: Reply with quote

Use SysGet to get the monitor's size and position, then WinMove to move and resize it.
Back to top
View user's profile Send private message Visit poster's website
johnlax
Guest





PostPosted: Wed Jan 14, 2009 7:12 am    Post subject: question Reply with quote

Hello,
I am trying to get one of the hot keys to be a shift or control key because i am using a laptop.I am having no luck changing it myself.
Please help,
John
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 4367
Location: Qld, Australia

PostPosted: Wed Jan 14, 2009 7:22 am    Post subject: Reply with quote

At the top of this page I posted instructions on how to configure # (Win) as a hotkey. Modifier symbols (alternatives to #) are listed here.
Back to top
View user's profile Send private message Visit poster's website
strictlyfocused02



Joined: 21 Jan 2009
Posts: 45

PostPosted: Wed Jan 21, 2009 4:36 pm    Post subject: Reply with quote

Wow, this script is absolutely amazing. I had been looking for a way to mimic the window sizing hotkeys found in Windows 7 for use on my computer at work. I use four 22" widescreen monitors to monitor an OpenVMS cluster as well as a web server farm and various other servers so as you can imagine I constantly have dozens of windows open. This makes managing all the different applications I run everyday a breeze.

I made some modifications (removed gather functions, changed hotkeys, etc) and loaded this into my background script that runs when Im logged into the machine and I couldnt be happier.

Excellent work, thank you (and everyone else who contributed) very much!! Very Happy Very Happy
Back to top
View user's profile Send private message
pinkkiss110



Joined: 31 Jan 2009
Posts: 4

PostPosted: Sat Jan 31, 2009 2:40 pm    Post subject: did i missed something? Reply with quote

Very Happy Sorry, i am totally new to AHK, I read about windowpad in lifehacker and I am totally amazed by the idea... so here I am, diving really deep into this thing and i am pretty confident that I am lost... Crying or Very sad

Arrow Okay, so I first download the latest version zip file

Arrow then I extracted into c:/documents and settings/.../my documents/autohotkey/windowpad/

Arrow then I double-clicked the WindowPad.exe.... and the program icon is in the tray area...

That's about it... I try to click the Window key + a numberpad key... doesnt' work...

I am pretty sure that I have to edit something in the windowpad.ini, right??
or is there a trigger?? I am so sorry I couldn't get it....

Okay, if I just want to have my current window moved to the right have of the screen(that correspond to the num4 key right?), how do I accomplish that??
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4367
Location: Qld, Australia

PostPosted: Sat Jan 31, 2009 5:32 pm    Post subject: Reply with quote

First of all, by "latest version zip file" you must mean the zip file posted on LifeHacker. I have never provided a compiled exe.

Secondly, the LifeHacker compiled script is based on an outdated version of WindowPad, which does not use an ini file. The first post in this thread contains a link to the latest version in source code form. I do not support outdated versions.

Finally, version 1.54 was not configured with Win+Numpad hotkeys by default. I have just uploaded version 1.55.
Quote:
Version 1.55:

  • WindowPadMove now increases a window's width by 50% if a "centre" hotkey is used, the window is already in place, and there is only one monitor.
  • Added Win+Numpad configuration to default ini.
  • Added comments to the default ini for users who don't read the manual.
  • Updated documentation to clarify hotkey configuration and behaviour of WindowPadMove.

If you've installed AutoHotkey, double-click WindowPad.ahk to start it. If you don't wish to install AutoHotkey, you may download the AutoHotkey zip which does not require installation. You may then run a script by dragging it onto AutoHotkey.exe, or compile it with Ahk2Exe.exe.
Back to top
View user's profile Send private message Visit poster's website
pinkkiss110



Joined: 31 Jan 2009
Posts: 4

PostPosted: Sat Jan 31, 2009 8:56 pm    Post subject: Reply with quote

Very Happy thanks for replying...

but... Exclamation Exclamation

I actually download the zip file on the front page, then i unzipped it and there were 4 items and one folder...
Folder:icons
WindowPad.ahk
WindowPad.exe
WindowPad.html
WindowPad.ini

I double clicked it, the exe file.

and my ini file
Quote:
[Options]
; TitleMatchMode=2

[Exclude Windows]
; Window=Virtual PC
; Window=Remote Desktop

[Gather: Exclude Windows]
Window=ahk_class SideBar_AppBarWindow
Window=ahk_class SideBar_HTMLHostWindow
Window=ahk_class BasicWindow

[Gather: Exclude Processes]
; Process=sidebar.exe


[Hotkeys]
CapsLock = Hotkeys, Active Window (WADS)
Numpad0 = Hotkeys, Active Window (Numpad)
NumpadDot = Hotkeys, Previous Window (Numpad)

[Hotkeys: Active Window (WADS)]
z = WindowPadMove, -1, +1, 0.5, 0.5
x = WindowPadMove, 0, +1, 1.0, 0.5
c = WindowPadMove, +1, +1, 0.5, 0.5
a = WindowPadMove, -1, 0, 0.5, 1.0
s = WindowPadMove, 0, 0, 0.5, 1.0
d = WindowPadMove, +1, 0, 0.5, 1.0
q = WindowPadMove, -1, -1, 0.5, 0.5
w = WindowPadMove, 0, -1, 1.0, 0.5
e = WindowPadMove, +1, -1, 0.5, 0.5
Tab = MaximizeToggle
Space = WindowScreenMove, Next
LAlt = WindowScreenMove, Prev
1 = GatherWindows, 1
2 = GatherWindows, 2

[Hotkeys: Active Window (Numpad)]
*Numpad1 = WindowPadMove, -1, +1, 0.5, 0.5
*Numpad2 = WindowPadMove, 0, +1, 1.0, 0.5
*Numpad3 = WindowPadMove, +1, +1, 0.5, 0.5
*Numpad4 = WindowPadMove, -1, 0, 0.5, 1.0
*Numpad5 = WindowPadMove, 0, 0, 0.5, 1.0
*Numpad6 = WindowPadMove, +1, 0, 0.5, 1.0
*Numpad7 = WindowPadMove, -1, -1, 0.5, 0.5
*Numpad8 = WindowPadMove, 0, -1, 1.0, 0.5
*Numpad9 = WindowPadMove, +1, -1, 0.5, 0.5
*NumpadAdd = MaximizeToggle
*NumpadEnter = WindowScreenMove, Next
*NumpadDiv = GatherWindows, 1
*NumpadMult = GatherWindows, 2

[Hotkeys: Previous Window (Numpad)]
*Numpad1 = WindowPadMove, -1, +1, 0.5, 0.5, P
*Numpad2 = WindowPadMove, 0, +1, 1.0, 0.5, P
*Numpad3 = WindowPadMove, +1, +1, 0.5, 0.5, P
*Numpad4 = WindowPadMove, -1, 0, 0.5, 1.0, P
*Numpad5 = WindowPadMove, 0, 0, 0.5, 1.0, P
*Numpad6 = WindowPadMove, +1, 0, 0.5, 1.0, P
*Numpad7 = WindowPadMove, -1, -1, 0.5, 0.5, P
*Numpad8 = WindowPadMove, 0, -1, 1.0, 0.5, P
*Numpad9 = WindowPadMove, +1, -1, 0.5, 0.5, P
*NumpadAdd = MaximizeToggle, P
*NumpadEnter = WindowScreenMove, Next, P
*NumpadDiv = GatherWindows, 1
*NumpadMult = GatherWindows, 2


I have not changed a thing yet...

sorry, I am so confused....[/quote]
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4367
Location: Qld, Australia

PostPosted: Sun Feb 01, 2009 12:28 am    Post subject: Reply with quote

Quote:
I have never provided a compiled exe.
...says Lexikos at 3:30am. At least I gave you the answer:
I wrote:
Finally, version 1.54 was not configured with Win+Numpad hotkeys by default. I have just uploaded version 1.55.

I've added a compiled version to the zip file. Please download the updated zip.
Back to top
View user's profile Send private message Visit poster's website
WindowpadFan
Guest





PostPosted: Sun Feb 01, 2009 5:38 am    Post subject: Reply with quote

Lexikos,

thanks a lot! This is the greatest script ever!!!

Ciao!
Pedro
Back to top
Hubauer



Joined: 18 Dec 2008
Posts: 2
Location: Germany

PostPosted: Tue Feb 03, 2009 5:31 pm    Post subject: "mixed use" of windowpad - Reply with quote

Hello Lexikos,

I am working on a device for my microlight aircraft (based on XP, 2 displays) that combines navigation software, engine monitoring, USB-CAM for rear view (e.g. towing gliders), antikollision... . For this the concerning windows have to be moved, scaled and overlayed on both displays. The condition,what has to be displayed and where, comes

1. from the pilot via buttons (button --> keyboardcontroller --> key)

2. from the messuring devices (e.g. allert, if EGT ist to high or altitude is low -->stall)

So far Windowpad is the best script I ever had and is very usefull for (1), Thank you for this great work.

For (2) I tried to add the necessary routines/conditions to the script. My actual barrier is (I am a "newbie") that I don't know how to use Windowpad out of a script.
E.g. - messuring device sends a key (not in ini) via contoller (I know)
- key starts routine in script (I know)
- routine calls a hotkey defined in ini (I don't know)

I have studied all threads before without success.

Could you give me a hint?

Thanks a lot
Hubert
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4367
Location: Qld, Australia

PostPosted: Tue Feb 03, 2009 9:25 pm    Post subject: Reply with quote

To trigger a particular action as assigned to a hotkey, set the Params variable then use gosub. For instance,
Code:
; x = WindowPadMove,  0, +1,  1.0, 0.5
Params = 0, +1,  1.0, 0.5
gosub WindowPadMove
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 9, 10, 11 ... 14, 15, 16  Next
Page 10 of 16

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group