WindowPadX-Actions library

Implementation of different useful actions for handling windows in general and within a multi-monitor setup in special.

Functions starting with the prefix WPXA are designed to be used as user-actions within WindowPadX, whereas functions starting with the prefix wp are internal helper functions.

Author

hoppfrosch

License

WTFPL (http://sam.zoy.org/wtfpl/)

Credits

Lexikosfor his great work and his Original WindowPad - multi-monitor window-moving tool (http://www.autohotkey.com/forum/topic21703.html)
ShinyWongfor his GetMonitorIndexFromWindow function (http://www.autohotkey.com/forum/viewtopic.php?p=462080#462080) - used in wp_GetMonitorFromWindow
Skrommelfor his MouseMark function (http://www.donationcoder.com/Software/Skrommel/MouseMark/MouseMark.ahk) - used in WPXA_MouseLocator
x97animalfor his clipCursor Function (http://www.autohotkey.com/forum/viewtopic.php?p=409537#409537) - used in wp_ClipCursor
ipstone todayfor his initial implementation (http://www.autohotkey.com/forum/viewtopic.php?p=521482#521482) for WPXA_TileLast2Windows
Seanfor his WinTrayMin functionality (http://http://www.autohotkey.com/community/viewtopic.php?f=2&t=33263) - used in <wp_WinTrayMin>
gwarblefor his great Notify function (http://www.autohotkey.com/community/viewtopic.php?f=2&t=48668)

Changelog

0.2.0[-] Removed <wp_RollWindow> [-] Removed <wp_UnrollWindow> [+] wp_RollWindowToggle: Toggles Roll/Unroll State of window.  (Corrected behaviour after manually resizing a previously rolled window) [*] Adapted WPXA_RollToggle to use wp_RollWindowToggle
0.1.12[*] Internal Changes: Update to Notify 0.499 (http://www.autohotkey.com/community/viewtopic.php?f=2&t=48668), Introduced Global variables for easier configuration ...
0.1.11[+] wp_WinTraymin : Minimize a window to a tray icon (see: http://http://www.autohotkey.com/community/viewtopic.php?f=2&t=33263 - thanks to Sean) {+] WPXA_TrayMinWindow: Mininmize a window to a tray icon (see <wp_TrayMin>)
0.1.10[+] wp_GetMonitorFromMouse: Determines monitor from current mouseposition.  [*] WPXA_MinimizeWindowsOnMonitor: added minimization of all windows on screen where mouse is.
0.1.9[+] WPXA_TileLast2Windows: Tile active and last window (see: http://www.autohotkey.com/forum/viewtopic.php?p=521482#521482 - thanks to ipstone today).
0.1.8[*] WPXA_MaximizeToggle: Bugfix to actually toggle Maximization (see: http://www.autohotkey.com/forum/post-508122.html#508122 - thanks to sjkeegs).
0.1.7[+] WPXA_RollToggle: Toggles Roll/Unroll State of window.  [+] <wp_RollWindow>: Rolls up a window to its titlebar.  [+] <wp_UnRollWindow>: Unrolls a previously rolled up window (restores original height).
0.1.6[*] WPXA_TopToggle: Reanimated Notification (removed Parameter ShowNotification).  [*] Extended Debug-Logging via OutputDebug.  (Unified Output format, Created posibillity to remove debug information (via Tag DBG)).
0.1.5[-] WPXA_MouseLocator: Using integer coordinates for Gui Show.
Summary
WindowPadX-Actions libraryImplementation of different useful actions for handling windows in general and within a multi-monitor setup in special.
Functions
WPXA_versionReturns the current version of WPXA
wp_ClipCursorClips (restricts/confines) the mouse to a given area
wp_GetMonitorAtGet the index of the monitor containing the specified x and y coordinates.
wp_GetMonitorFromMouseGet the index of the monitor where the mouse is
wp_GetMonitorFromWindowGet the index of the monitor containing the specified window.
wp_GetPropGet window property.
wp_IsAlwaysOnTopDetermine whether fiven window is set to always on top
wp_IsResizableDetermine if we should attempt to resize the last found window.
wp_IsWhereWePutItRestores windows position and size previously stored with wp_RememberPos
wp_RememberPosHelper function for detection of window movement by user.
wp_RemovePropRemove window property.
wp_RestoreRestores windows to state according properties
wp_RollWindowToggleToggles Rollup of a window (Rollup to caption bar)
wp_SetPropSet window property.
wp_SetRestorePosStores windows position for restoring it later
wp_WinExistCustom WinExist() for implementing a couple extra “special” values.
wp_WinGetTitleCustom WinGetTitle() for getting either title of “last found” window or window given by title
wp_WinLastMinimizedGet most recently minimized window.
wp_WinPreviouslyActiveGet next window beneath the active one in the z-order.
wp_WinTrayminMinimizes a window to a tray icon.
WPXA_ClipCursorToMonitorClips (Restricts) mouse to given monitor
WPXA_ClipCursorToCurrentMonitorToggleToogles clipping mouse to current monitor
WPXA_FillVirtualScreenExpand the window to fill the virtual screen (all monitors).
WPXA_GatherWindowsOnMonitor“Gather” windows on a specific screen.
WPXA_MaximizeToggleMaximize or restore the window.
WPXA_MinimizeWindowsOnMonitorMinimize all windows on the given Screen or all windows on screen where where the mouse currently lives
WPXA_Movemove and resize window based on a “pad” concept.
WPXA_MoveMouseToMonitorMoves mouse to center of given monitor
WPXA_MoveWindowToMonitorMove window between screens, preserving relative position and size.
WPXA_MouseLocatorEasy find the mouse
WPXA_RollToggleToogles “Roll/Unroll” for given window
WPXA_TileLast2WindowsTile active and last window
WPXA_TopToggleToogles “Always On Top” for given window
WPXA_TrayMinWindowMinimizes a window to a tray icon.

Functions

WPXA_version

WPXA_version()

Returns the current version of WPXA

Versioning scheme according to http://semver.org

Returns

current version number of the module

Author(s)

20110713hoppfrosch - Original

wp_ClipCursor

wp_ClipCursor(Confine = True,
x1 = 0 ,
y1 = 0,
x2 = 1,
y2 = 1)

Clips (restricts/confines) the mouse to a given area

Parameters

ConfineToogle for Clipping
x1,y1,x2,y2Bounding coordinates (upper left, lower right) of confined area

Returns

If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero.  To get extended error information, call GetLastError.

Author(s)

Originalx79animal - http://www.autohotkey.com/forum/viewtopic.php?p=409537#409537
20110127hoppfrosch - Modifications

wp_GetMonitorAt

wp_GetMonitorAt(x,  
y,  
default = 1)

Get the index of the monitor containing the specified x and y coordinates.

Parameters

x,yCoordinates
defaultDefault monitor

Returns

Index of the monitor at specified coordinates

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_GetMonitorFromMouse

wp_GetMonitorFromMouse(default = 1)

Get the index of the monitor where the mouse is

Parameters

defaultDefault monitor

Returns

Index of the monitor where the mouse is

Author(s)

20120322- hoppfrosch: Initial

wp_GetMonitorFromWindow

wp_GetMonitorFromWindow(hWnd)

Get the index of the monitor containing the specified window.

Parameters

hWndWindow handle

Returns

Index of the monitor of specified window

Author(s)

OriginalShinyWong - http://www.autohotkey.com/forum/viewtopic.php?p=462080#462080

wp_GetProp

wp_GetProp(hwnd,  
property_name,  
type = "int")

Get window property.

Parameters

hwndWindow handle
property_nameName of the property
typeType of the property - should be int, uint or float.

Returns

Value of the property, otherwise NULL if property does not exist

See also

wp_SetProp, wp_RemoveProp

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html
ReferenceMSDN - http://msdn.microsoft.com/en-us/library/ms633564%28v=vs.85%29.aspx

wp_IsAlwaysOnTop

wp_IsAlwaysOnTop(WinTitle,  
IsSetByWP = )

Determine whether fiven window is set to always on top

Parameters

WinTitleTitle of the window
IsSetByWPChecks whether “AlwaysOnTop” was set with WindowPadX (needed to restore state ...)

Returns

True or False

Author(s)

20110811hoppfrosch - Initial

wp_IsResizable

wp_IsResizable()

Determine if we should attempt to resize the last found window.

Returns

True or False

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_IsWhereWePutIt

wp_IsWhereWePutIt(hwnd,
x,
y,
w,
h)

Restores windows position and size previously stored with wp_RememberPos

Parameters

hwndWindow handle

Returns

x,y,w,hlast position and size

See also

wp_RememberPos

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_RememberPos

wp_RememberPos(hwnd)

Helper function for detection of window movement by user.  Stores the current position.  The stored position can be recovered by wp_IsWhereWePutIt

Parameters

hwndWindow handle

See also

wp_SetProp, wp_IsWhereWePutIt

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_RemoveProp

wp_RemoveProp(hwnd,
property_name)

Remove window property.

Parameters

hwndWindow handle
property_nameName of the property

Returns

HandleThe return value identifies the specified data.  If the data cannot be found in the specified property list, the return value is NULL.

See also

wp_GetProp, wp_SetProp

Author(s)

ReferenceMSDN (http://msdn.microsoft.com/en-us/library/ms633567%28v=vs.85%29.aspx)
20110713hoppfrosch - AutoHotkey-Implementation

wp_Restore

wp_Restore()

Restores windows to state according properties

Following states are restored

  • AlwaysOnTop
  • RolledWindow

Author(s)

20110713hoppfrosch - AutoHotkey-Implementation

wp_RollWindowToggle

wp_RollWindowToggle(hwnd)

Toggles Rollup of a window (Rollup to caption bar)

Parameters

hWndWindow handle

Author(s)

20120620hoppfrosch - Original

wp_SetProp

wp_SetProp(hwnd,  
property_name,  
data,  
type = "int")

Set window property.

Parameters

hwndWindow handle
property_nameName of the property
dataValue of the property
typeType of the property - should be int, uint or float

Returns

True or False

See also

wp_GetProp, wp_RemoveProp

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_SetRestorePos

wp_SetRestorePos(hwnd,
x,
y,
w,
h)

Stores windows position for restoring it later

Parameters

hwndWindow handle
x,y,w,hNext time user requests the window be “restored” use this position and size.

See also

wp_SetProp

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_WinExist

wp_WinExist(WinTitle)

Custom WinExist() for implementing a couple extra “special” values.

Parameters

WinTitleTitle of the window

Returns

Windowshandle

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_WinGetTitle

wp_WinGetTitle(WinTitle)

Custom WinGetTitle() for getting either title of “last found” window or window given by title

Parameters

WinTitleTitle of the window

Returns

WinTitleTitle of the window

Author(s)

20110607hoppfrosch - Original

wp_WinLastMinimized

wp_WinLastMinimized()

Get most recently minimized window.

Returns

True or false

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_WinPreviouslyActive

wp_WinPreviouslyActive()

Get next window beneath the active one in the z-order.

Returns

Windowshandle

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

wp_WinTraymin

wp_WinTraymin(hWnd =  "",
nFlags =  "")

Minimizes a window to a tray icon.

Parameters

hWndWindows-Handle
nFlagsFlag to allow manipulate properites: wp_WinTraymin(hWnd,0), where 0 can be omitted.  Removing all trayminned trayicons: wp_WinTraymin(0,-1).  Other values than 0 & -1 are reserved for internal use.

Author(s)

OriginalSean - http://http://www.autohotkey.com/community/viewtopic.php?f=2&t=33263

WPXA_ClipCursorToMonitor

WPXA_ClipCursorToMonitor(md)

Clips (Restricts) mouse to given monitor

Parameters

mdmonitor-id

Author(s)

20110126hoppfrosch - Initial

WPXA_ClipCursorToCurrentMonitorToggle

WPXA_ClipCursorToCurrentMonitorToggle()

Toogles clipping mouse to current monitor

Author(s)

20110126hoppfrosch - Initial

WPXA_FillVirtualScreen

WPXA_FillVirtualScreen(winTitle)

Expand the window to fill the virtual screen (all monitors).

Parameters

winTitlewindows title

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

WPXA_GatherWindowsOnMonitor

WPXA_GatherWindowsOnMonitor(md)

”Gather” windows on a specific screen.

Parameters

mdmonitor id

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

WPXA_MaximizeToggle

WPXA_MaximizeToggle(winTitle)

Maximize or restore the window.

Parameters

winTitlewindows title

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

WPXA_MinimizeWindowsOnMonitor

WPXA_MinimizeWindowsOnMonitor(md)

Minimize all windows on the given Screen or all windows on screen where where the mouse currently lives

Parameters

mdmonitor-id, if 0 determine monitor from mouse pos

Author(s)

20110125hoppfrosch - Initial
20120322hoppfrosch - minimize windows on screen where mouse is (md = 0)

WPXA_Move

WPXA_Move(sideX,
sideY,
widthFactor,
heightFactor,
winTitle)

move and resize window based on a “pad” concept.

Parameters

sideX, sideY, widthFactor, heightFactor**TODO**
winTitlewindows title (“A” - Active Window, “P” - Previous Window)

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

WPXA_MoveMouseToMonitor

WPXA_MoveMouseToMonitor(md)

Moves mouse to center of given monitor

Parameters

mdmonitor-id

Author(s)

20110125hoppfrosch - Initial

WPXA_MoveWindowToMonitor

WPXA_MoveWindowToMonitor(md,
winTitle)

Move window between screens, preserving relative position and size.

Parameters

mdMonitor id
winTitlewindows title

Author(s)

OriginalLexikos - http://www.autohotkey.com/forum/topic21703.html

WPXA_MouseLocator

WPXA_MouseLocator()

Easy find the mouse

Requirements

Windings-Font

Author(s)

OriginalSkrommel - http://www.donationcoder.com/Software/Skrommel/MouseMark/MouseMark.ahk
20110127hoppfrosch - Modifications

WPXA_RollToggle

WPXA_RollToggle(WinTitle)

Toogles “Roll/Unroll” for given window

Parameters

WinTitleTitle of the window

Author(s)

20120116hoppfrosch - Original

WPXA_TileLast2Windows

WPXA_TileLast2Windows()

Tile active and last window

Author(s)

20120316ipstone today - Initial (http://www.autohotkey.com/forum/viewtopic.php?p=521482#521482)

WPXA_TopToggle

WPXA_TopToggle(WinTitle)

Toogles “Always On Top” for given window

Parameters

WinTitleTitle of the window

Author(s)

20110811hoppfrosch - Initial

WPXA_TrayMinWindow

WPXA_TrayMinWindow(WinTitle)

Minimizes a window to a tray icon.

Parameters

WinTitleTitle of the window

Author(s)

20120509hoppfrosch - Initial
WPXA_version()
Returns the current version of WPXA
wp_ClipCursor(Confine = True,
x1 = 0 ,
y1 = 0,
x2 = 1,
y2 = 1)
Clips (restricts/confines) the mouse to a given area
wp_GetMonitorAt(x,  
y,  
default = 1)
Get the index of the monitor containing the specified x and y coordinates.
wp_GetMonitorFromMouse(default = 1)
Get the index of the monitor where the mouse is
wp_GetMonitorFromWindow(hWnd)
Get the index of the monitor containing the specified window.
wp_GetProp(hwnd,  
property_name,  
type = "int")
Get window property.
wp_IsAlwaysOnTop(WinTitle,  
IsSetByWP = )
Determine whether fiven window is set to always on top
wp_IsResizable()
Determine if we should attempt to resize the last found window.
wp_IsWhereWePutIt(hwnd,
x,
y,
w,
h)
Restores windows position and size previously stored with wp_RememberPos
wp_RememberPos(hwnd)
Helper function for detection of window movement by user.
wp_RemoveProp(hwnd,
property_name)
Remove window property.
wp_Restore()
Restores windows to state according properties
wp_RollWindowToggle(hwnd)
Toggles Rollup of a window (Rollup to caption bar)
wp_SetProp(hwnd,  
property_name,  
data,  
type = "int")
Set window property.
wp_SetRestorePos(hwnd,
x,
y,
w,
h)
Stores windows position for restoring it later
wp_WinExist(WinTitle)
Custom WinExist() for implementing a couple extra “special” values.
wp_WinGetTitle(WinTitle)
Custom WinGetTitle() for getting either title of “last found” window or window given by title
wp_WinLastMinimized()
Get most recently minimized window.
wp_WinPreviouslyActive()
Get next window beneath the active one in the z-order.
wp_WinTraymin(hWnd =  "",
nFlags =  "")
Minimizes a window to a tray icon.
WPXA_ClipCursorToMonitor(md)
Clips (Restricts) mouse to given monitor
WPXA_ClipCursorToCurrentMonitorToggle()
Toogles clipping mouse to current monitor
WPXA_FillVirtualScreen(winTitle)
Expand the window to fill the virtual screen (all monitors).
WPXA_GatherWindowsOnMonitor(md)
“Gather” windows on a specific screen.
WPXA_MaximizeToggle(winTitle)
Maximize or restore the window.
WPXA_MinimizeWindowsOnMonitor(md)
Minimize all windows on the given Screen or all windows on screen where where the mouse currently lives
WPXA_Move(sideX,
sideY,
widthFactor,
heightFactor,
winTitle)
move and resize window based on a “pad” concept.
WPXA_MoveMouseToMonitor(md)
Moves mouse to center of given monitor
WPXA_MoveWindowToMonitor(md,
winTitle)
Move window between screens, preserving relative position and size.
WPXA_MouseLocator()
Easy find the mouse
WPXA_RollToggle(WinTitle)
Toogles “Roll/Unroll” for given window
WPXA_TileLast2Windows()
Tile active and last window
WPXA_TopToggle(WinTitle)
Toogles “Always On Top” for given window
WPXA_TrayMinWindow(WinTitle)
Minimizes a window to a tray icon.
Close