Wolfram Research

Function Repository Resource:

Win32AlignWindow (1.0.0) current version: 1.1.0 »

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.5proportion of the screen the window should occupy
"Screen"1screen on which to place the window
"ResizeSecondaryDimension"Trueif aligning to left/right edge, the secondary dimension is the height, and is otherwise the width

Examples

Basic Examples (1) 

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

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

Options (4) 

Screen (1) 

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

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

Proportion (2) 

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:

In[4]:=
ResourceFunction["Win32AlignWindow"][
 StringStartsQ["Messages - "], Left, "Proportion" -> Automatic]

ResizeSecondaryDimension (1) 

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

In[5]:=
ResourceFunction["Win32AlignWindow"][
 StringStartsQ["Messages - "], Top, "Proportion" -> Automatic, "ResizeSecondaryDimension" -> False]

Applications (1) 

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

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

Possible Issues (1) 

Win32AlignWindow is only supported on Windows operating systems:

In[7]:=
ResourceFunction["Win32AlignWindow"][]
Out[7]=
In[8]:=
$OperatingSystem
Out[8]=

Publisher

Daniel Bigham

Version History

  • 1.1.0 – 24 October 2022
  • 1.0.0 – 07 June 2019

Related Resources

License Information