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

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
"WindowsUIScale"1value of Windows setting found at System >Display > Scale & Layout > Scale

Examples

Basic Examples (1) 

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

In[1]:=
ResourceFunction[
 "Win32AlignWindow", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][StringStartsQ["Messages - "], Left]

Options (5) 

Screen (1) 

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

In[2]:=
ResourceFunction[
 "Win32AlignWindow", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][StringStartsQ["Messages - "], Right, "Screen" -> 2]

Proportion (2) 

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

In[3]:=
ResourceFunction[
 "Win32AlignWindow", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][StringStartsQ["Messages - "], Right, "Proportion" -> 1/3]

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

ResizeSecondaryDimension (1) 

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

WindowsUIScale (1) 

Align the message window to the bottom edge of the screen and compensate for the Windows setting found in System > Display > Scale & Layout > Scale being set to 200%:

Applications (1) 

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

In[4]:=
ResourceFunction["Win32WindowToFront"][StringStartsQ["Working.nb"]]
ResourceFunction[
 "Win32AlignWindow", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][StringStartsQ["Working.nb"], Left]
ResourceFunction["Win32WindowToFront"][StringEndsQ[" - Eclipse IDE"]]
ResourceFunction[
 "Win32AlignWindow", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][StringEndsQ[" - Eclipse IDE"], Right]

Possible Issues (1) 

Win32AlignWindow is only supported on Windows operating systems:

In[5]:=
ResourceFunction[
 "Win32AlignWindow", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][]
Out[5]=
In[6]:=
$OperatingSystem
Out[6]=

Windows may be sized incorrectly if WindowsUIScale is not set correctly.

Publisher

Daniel Bigham

Version History

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

Related Resources

License Information