AutoHotkey Community

It is currently May 26th, 2012, 3:03 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 337 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 23  Next
Author Message
 Post subject:
PostPosted: December 20th, 2008, 7:38 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2008, 10:04 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
Thanks a lot man! It worked! :)

_________________
AHK is perfect.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2008, 3:39 pm 
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
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2008, 3:40 pm 
I forgot to mention, it works but some of the window is cropped outside the screen because of the res difference. Thats the problem


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2008, 10:38 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Use SysGet to get the monitor's size and position, then WinMove to move and resize it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: question
PostPosted: January 14th, 2009, 8:12 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2009, 8:22 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
At the top of this page I posted instructions on how to configure # (Win) as a hotkey. Modifier symbols (alternatives to #) are listed here.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 5:36 pm 
Offline

Joined: January 21st, 2009, 1:06 pm
Posts: 63
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!! :D :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject: did i missed something?
PostPosted: January 31st, 2009, 3:40 pm 
Offline

Joined: January 31st, 2009, 3:32 pm
Posts: 4
:D 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... :cry:

: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??


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2009, 6:32 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2009, 9:56 pm 
Offline

Joined: January 31st, 2009, 3:32 pm
Posts: 4
:D thanks for replying...

but... :!: :!:

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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2009, 1:28 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2009, 6:38 am 
Lexikos,

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

Ciao!
Pedro


Report this post
Top
  
Reply with quote  
PostPosted: February 3rd, 2009, 6:31 pm 
Offline

Joined: December 18th, 2008, 6:01 pm
Posts: 2
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2009, 10:25 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 337 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 23  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], Uberi 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