Description
This property returns a combination of Win32 API constants (WS_CAPTION
, WS_BORDER
, etc.) that define the window style. These constants are specified in the dwStyles parameter of the CreateWindowEx
function (Windows API).
Using the WndStyles
property you can determine which styles a window has.
For a full list of Win32 API constants for window styles and their hexadecimal values, see the Window Styles article in MSDN.
Declaration
TestObj.WndStyles
Read-Only Property | Integer |
TestObj | A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section |
Applies To
The property is applied to the following objects:
View Mode
To view this property in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.
Property Value
An integer value that represents a combination of window styles.
Example
The following example shows how you can use the WndStyles
property to determine if a window is maximized or minimized.
JavaScript, JScript
function Test()
{
WshShell.Run("notepad");
var wndNotepad = Sys.Process("notepad").Window("Notepad");
wndNotepad.Maximize();
Log.Message("Notepad window is maximized: " + IsMaximized(wndNotepad));
Log.Message("Notepad window is minimized: " + IsMinimized(wndNotepad));
}
// Returns True if the specified Window is maximized; otherwise False.
function IsMaximized(Window)
{
var WS_MAXIMIZED = 0x01000000;
// Declaring the WinAPI hexadecimal value for the maximized window
return (Window.WndStyles & WS_MAXIMIZED) == WS_MAXIMIZED;
}
// Returns True if the specified Window is minimized; otherwise False.
function IsMinimized(Window)
{
var WS_MINIMIZED = 0x20000000;
// Declaring the WinAPI hexadecimal value for the minimized window
return (Window.WndStyles & WS_MINIMIZED) == WS_MINIMIZED;
}
Python
def Test():
WshShell.Run("notepad")
wndNotepad = Sys.Process("notepad").Window("Notepad")
wndNotepad.Maximize()
Log.Message("Notepad window is maximized: " + str(IsMaximized(wndNotepad)))
Log.Message("Notepad window is minimized: " + str(IsMinimized(wndNotepad)))
# Returns True if the specified Window is maximized; otherwise False.
def IsMaximized(Window):
WS_MAXIMIZED = 0x01000000
# Declaring the WinAPI hexadecimal value for the maximized window
return (Window.WndStyles & WS_MAXIMIZED) == WS_MAXIMIZED
# Returns True if the specified Window is minimized; otherwise False.
def IsMinimized(Window):
WS_MINIMIZED = 0x20000000
# Declaring the WinAPI hexadecimal value for the minimized window
return (Window.WndStyles & WS_MINIMIZED) == WS_MINIMIZED
VBScript
Sub Test
Call WshShell.Run("notepad")
Dim wndNotepad
Set wndNotepad = Sys.Process("notepad").Window("Notepad")
wndNotepad.Maximize
Call Log.Message("Notepad window is maximized: " & IsMaximized(wndNotepad))
Call Log.Message("Notepad window is minimized: " & IsMinimized(wndNotepad))
End Sub
' Returns True if the specified Window is maximized; otherwise False.
Function IsMaximized(Window)
Dim WS_MAXIMIZED
WS_MAXIMIZED = &H01000000
' Declaring the WinAPI hexadecimal value for the maximized window
IsMaximized = ((Window.WndStyles And WS_MAXIMIZED) = WS_MAXIMIZED)
End Function
' Returns True if the specified Window is minimized; otherwise False.
Function IsMinimized(Window)
Dim WS_MINIMIZED
WS_MINIMIZED = &H20000000
' Declaring the WinAPI hexadecimal value for the minimized window
IsMinimized = ((Window.WndStyles And WS_MINIMIZED) = WS_MINIMIZED)
End Function
DelphiScript
// Returns True if the specified Window is maximized; otherwise False.
function IsMaximized(Window);
var WS_MAXIMIZED;
begin
WS_MAXIMIZED := $01000000;
// Declaring the WinAPI hexadecimal value for the maximized window
Result := ((Window.WndStyles and WS_MAXIMIZED) = WS_MAXIMIZED);
end;
// Returns True if the specified Window is minimized; otherwise False.
function IsMinimized(Window);
var WS_MINIMIZED;
begin
WS_MINIMIZED := $20000000;
// Declaring the WinAPI hexadecimal value for the minimized window
Result := ((Window.WndStyles and WS_MINIMIZED) = WS_MINIMIZED);
end;
procedure Test;
var wndNotepad;
begin
WshShell.Run('notepad');
wndNotepad := Sys.Process('notepad').Window('Notepad');
wndNotepad.Maximize;
Log.Message('Notepad window is maximized: ' + VarToStr(IsMaximized(wndNotepad)));
Log.Message('Notepad window is minimized: ' + VarToStr(IsMinimized(wndNotepad)));
end;
C++Script, C#Script
function Test()
{
WshShell["Run"]("notepad");
var wndNotepad = Sys["Process"]("notepad")["Window"]("Notepad");
wndNotepad["Maximize"]();
Log["Message"]("Notepad window is maximized: " + IsMaximized(wndNotepad));
Log["Message"]("Notepad window is minimized: " + IsMinimized(wndNotepad));
}
// Returns True if the specified Window is maximized; otherwise False.
function IsMaximized(Window)
{
var WS_MAXIMIZED = 0x01000000;
// Declaring the WinAPI hexadecimal value for the maximized window
return (Window["WndStyles"] & WS_MAXIMIZED) == WS_MAXIMIZED;
}
// Returns True if the specified Window is minimized; otherwise False.
function IsMinimized(Window)
{
var WS_MINIMIZED = 0x20000000;
// Declaring the WinAPI hexadecimal value for the minimized window
return (Window["WndStyles"] & WS_MINIMIZED) == WS_MINIMIZED;
}