Windows and Controls


Manipulates windows and controls on the screen. This is the primary method for interacting with running programs.

*Tip:  To correctly access windows and controls, it is important to understand how vTask identifies windows. For more information concerning locating windows and controls, see Identifying Windows and Controls.


The available commands are:

  Use Window
  Get Text
  Set Text
  Get Window Info
  Move Window
  Resize
  Maximize
  Minimize
  Restore
  Close Window
  Set Window Style
  Child Control Action
  Minimize all Windows
  Close all Windows



  Use Window
 

This is a special command that indicates to vTask which window you want to work with. The "Use Window " command works with standard windows and controls. You need to have a Use Window command for many actions, such as showing a window, typing in it, and pressing child buttons.

There are many options available for identifying a window, or stated another way, there are many methods for locating and using a window. You can search for a window/control using options such as title text, class, id, data, coordinates, image, etc. Most frequently, you will probably use the options "Exact Title" (when you know the text will not change) or "Partial Title" (when part of the title is always the same). The trick to Use Window is to utilize a method that can uniquely identify the window. For example, there may be many "OK" buttons running at the same time. In these cases, "Class" is usually helpful. If you know the window's parent (usually the program itself), you can use the "Parent HWND" option. With a little practice, it should be easy to know what item uniquely identifies a window/control. As a backup plan, the "Image Match" option will always work - as long as the window is visible and not hidden behind other windows. Once you find a window, it can also switch to the window ("Bring to Front").

The Force Thread Activation option is an additional, low-level approach for activating a window's program (thread). This is similar to Windows' "Task Manager - Switch to Program" command. It is a brute-force method, and normally should not be used unless necessary, as certain programs may freeze when this method is used. All vTask versions prior to 6.2 employed this method by default.

If multiple matches are found, the Failure Mode is performed. However, if you have chosen "Use First if Multiple" or the "Ignore/Continue" failure mode, and multiple windows are found, then the first matching window is activated without generating an error. Use these settings when you are not concerned about conflicting windows.

The "Save Output" option is available for Use Window. The value that it saves is the window handle, which can be used in any other Window action. This is the same value as the system variable {hwnd}.

If provided, "Parent HWND" indicates that the window to locate is a child of another window (such as a dialog control). The search will be restricted to child objects owned by this window. This setting is optional, and should be omitted if you want to search all windows.

If the window is not located within the Max Wait timeout, the Failure Action is activated.

*Tip:  All Window commands must have at least one Use Window command before it, or alternatively you must have a previously saved window handle to use. A window handle can be retreived using "Use Window", {hwnd} or the Win32 API. Interaction with windows is based on the currently focused window/control, which can only be performed by Use Window.


Match MethodSample Data
Exact Title "Untitled - Notepad"
Partial Title "- Notepad"
Class
"Edit" (window type)


(Note: Class allows appended * wildcards, which enables matching dynamic .NET controls. For example, "WindowsForms10.STATIC.*" will match "WindowsForms10.STATIC.app.0.1b3cbea")
ID "1001" (identifier)
Userdata "8417839"
Title+Class+ID+Userdata,
Title+Class,
Class+ID, etc.

"Notepad|Edit|54212344|0"

(a combination of data,
separated by "|")
Handle (HWND) "4582743"
Window/Child Control At X,Y "30,40" (x,y)
Child at Parent-Relative X/Y "30,40" (x,y)

This X,Y coordinate is starting from parent window's upper left corner, therefore (10,10) is 10 pixels inside of the parent app. To use the correct parent window, either use "{hwnd}" in the Parent HWND field, or add a Use Window action to identify the parent window before identifing the child control.
Window/Child Control Below Mouse "30,40" (x,y)
Top Window (no parameters needed)
Window with Focus (no parameters needed)
Image (Graphic) "C:\MyImage.BMP" (graphic file)


For more information concerning locating windows and controls, see Identifying Windows and Controls, or Using Images if you are using image matching. Note that locating and activating child windows of the vTask program itself is prevented. The reasons for this is because vTask contains all of your script's actions, so will always match every window you could search for if the search parameters are specified to be open (definitely not what you intended). See the Vista Software online forum for special methods of accessing vTask window handles.


Identifying Windows without "Use Window"

For all other window actions besides "Use Window", there is an abbreviated list of methods for locating a window. The "Window Data" field indicates the handle or text to use for window identification.
"Most Recent Use Window" will use the last window that was found with the "Use Window" command (this is the default and best method).
"Window Handle" will use the HWND that you provide. This can be retrieved using "Use Window", {hwnd}, or the Win32 API.
"Top Window" will use the window that is currently in the foreground.
"Window Title" will locate a window based on the title text of the program/window.

If you need additional options for identifying windows, please employ the Use Window action, which provides all possible options and methods.



  Get Text
 

Retrieves the text (title) of a window or control. The location of the text depends on the type of window, for example, an application window will have its text in the main caption, but edit controls will show their text inside the white editable area.

To use the "Selected Text" option, it is usually a requirement to match on the Class + ID with the Use Window command. This is because you will need to specifically find the edit window inside the main program, for example, in Microsoft Word this window class may be "_WwG", not "Document1 - Microsoft Word". The magnifying glass tool of vTask (in Properties) is able to identify these windows for you. The Selected Text option has been tested and works with Excel, Word, Notepad, and similar programs.

The contents of listboxes and combo boxes can also be retrieved. All options from the list are returned, with newlines separating each option.

The following Retrieval Methods are supported:

MethodDescription
(let vTask decide) vTask tries to determine the window type, and adapts the retrieval method to match. Typically, the WM_GETEXT method is used.
Control-Specific (all text) Sends a certain message to the control, depending on the type of control. For example, list boxes, combo boxes, and edit controls all use different messages to retrieve their data.
Control-Specific (selected text) Depending on the type of control, vTask will retrieve the text that is selected, also known as "highlighted." Please note that some custom or non-standard controls cannot be read.
GetWindowText Uses the internal system function to retrieve the text. Note: Microsoft Windows cannot retrieve the text of an edit control in another application using GetWindowText. This function is provided for completeness.
WM_GETTEXT This is the default method.
WM_GETTEXT (interactive) Interactively sends a request to the window. This is the safest and most reliable method, and is also the method used for the "Display all Windows & Controls" feature.



  Set Text
 

Places text inside of a window or control.
This action is also able to add new entries into listboxes and combo boxes. Each item is separated by semicolons ";", such as "One;Two;Three".

This action performs the same as the Direct Window Entry action.


  Get Window Info
 

Retrieves data about a window or control.

The following data items are available:

Window InformationDescription
Text the title or data of the window
Width the horizontal size of the window, in pixels
Height the vertical size of the window, in pixels
Left Coordinate the left pixel location of the window (0,0 is upper left of screen)
Right Coordinate the right pixel location of the window
Top Coordinate the top pixel location of the window
Bottom Coordinatethe bottom pixel location of the window
Is Visible 1 if window visible, 0 if not visible
Is Minimized 1 if window is minimized to tray, else 0 if normal
Is Maximized 1 if window is full screen, else 0 if normal
Is Checked 1 if checked, 0 if not checked (for checkboxes and radio buttons)
Is Enabled 1 if enabled, 0 if not enabled (grayed)
Window Class the Class Name, such as "Button" or "tooltips_class32"
Control Type text description of the control, such as "Button" or "Edit"
Control ID the numeric identifier of the control, such as "1000"
Style Value Numeric value of the window's style (WS_VISIBLE = 0x10000000, etc)
This is a technical reference, and only used by programmers who need to check for a certain style bit
Process EXE The source filename of the EXE program that is running the window, for example, "C:\Windows\Notepad.exe"
Process EXE Path The source path of the EXE program that is running the window, for example, "C:\Windows\"
Process EXE Base The base name of the EXE program that is running the window, for example, "Notepad.exe"

NOTE: vTask can only retrieve the EXE filenames of programs that are 32-bit.



  Move Window
 

Changes the window position on the screen. The coordinates start at 0, 0 which would be the upper left corner of the screen. Coordinate (1,1) would be 1 pixel away from the upper left corner. The window size is not changed.


  Resize
 

Changes the window size. The height and width are based on screen pixels. The window position is not changed.

If either the height or width value is less than 1 (or omitted), it will not be changed. This allows you to change only one part of the width and height if you want.


  Maximize
 

Changes the window size and position to occupy the entire screen.


  Minimize
 

Changes the window position so that it only appears in the task bar as an icon. This has no effect on windows that are already minimized.

*Tip:  Please note that some windows hide themselves or go to the system tray when minimized (such as printer configuration apps and MS Messenger). This non-standard behavior will not allow vTask to restore as it would a normal program. In these circumstances, you need to determine what the program needs in able to restore its main window (usually a mouse command or menu selection).



  Restore
 

Restores a minimized icon to its normal position and size. This has no effect on windows that are already normal sized, however the window is re-activated and brought in front of other windows.


  Close Window
 

Exits a running program window. The program will have a chance to close itself and show any user prompts (such as save data). This can also be used to close dialog boxes and popup windows.


  Set Window Style
 

Changes a window's appearance and internal configurations. Many alterations are possible, including:

Visible
Hidden
Enabled
Disabled
Not Always on Top
Always on Top
Caption
Not Resizable
Resizable
Maximize Button
Without Maximize Button
Without Minimize Button
Minimize Button


  Child Control Action
 

Performs an action on a control, such as a button or checkbox.

For more information concerning locating windows and controls, see Identifying Windows and Controls.


  Minimize all Windows
 

Performs the same action as Minimize Window, but on all windows. The windows will be available as icons in the Taskbar.


  Close all Windows
 

Performs the same action as Close Window, but on all windows. Use this command with caution, since no data will be saved in any program!