Wolfram Research

Function Repository Resource:

Win32AlignWindow

Source Notebook

Align a window to an edge of a screen

Contributed by: Daniel Bigham

ResourceFunction["Win32AlignWindow"][hwnd,edge]

aligns a window specified by hwnd with the given edge of a screen.

ResourceFunction["Win32AlignWindow"][func,edge]

finds the window for which the given function returns True when passed the window's title and aligns it with the given edge of the screen.

Details and Options

Window handles are integers used by the Windows operating system to refer to currently open windows. You can use ResourceFunction["Win32AlignWindow"] to generate a list of window handles for all existing windows.
ResourceFunction["Win32AlignWindow"] is only supported on Windows machines.
ResourceFunction["Win32AlignWindow"] has the following options:
"Proportion" 0.5 proportion of the screen the window should occupy
"Screen" 1 screen on which to place the window
"ResizeSecondaryDimension" True if aligning to left/right edge, the secondary dimension is the height, and is otherwise the width

Examples

Basic Examples

Align the Messages window with the right half of the screen:

In[1]:=
ResourceFunction["Win32AlignWindow"][
 StringStartsQ["Messages - "], Right]

Options

Screen

Align the Messages window with the right half of the second screen:

In[2]:=
ResourceFunction["Win32AlignWindow"][
 StringStartsQ["Messages - "], Right, "Screen" -> 2]

Proportion

Align the Messages window with the right third of the screen:

In[3]:=
ResourceFunction["Win32AlignWindow"][
 StringStartsQ["Messages - "], Right, "Proportion" -> 1/3]

Align the Messages window with the left side of the screen, but do not alter its width:

ResizeSecondaryDimension

Align the Messages window to the top edge of the screen, but do not change its width or height:

Applications

Create scripts to arrange your windows for working on particular types of problems:

In[4]:=
ResourceFunction["Win32WindowToFront"][StringStartsQ["Working.nb"]]
ResourceFunction["Win32AlignWindow"][StringStartsQ["Working.nb"], Left]
ResourceFunction["Win32WindowToFront"][StringEndsQ[" - Eclipse IDE"]]
ResourceFunction["Win32AlignWindow"][
 StringEndsQ[" - Eclipse IDE"], Right]

Possible Issues

Win32AlignWindow is only supported on Windows operating systems:

In[5]:=
ResourceFunction["Win32AlignWindow"][]
Out[5]=
In[6]:=
$OperatingSystem
Out[6]=

Resource History

See Also

License Information