Home > Enhancing Scripts > Naming Objects, Spy Tool

Naming Objects, Spy Tool

The Spy tool included in WinTask allows you to find the name of a window and the parameters for the UseWindow function. It is used too for generating the HTML descriptor of HTML elements displayed on a Web page. Spy tool can find window names for 32 bits applications under a x64 Windows but cannot find a pure x64 window (the 64 bit automation product is needed for pure x64 windows).  


Video: How to use Spy on a Windows application
Video: How to use Spy on a web page

To launch Spy tool, click  icon in WinTask Editor toolbar or select Start/Spy menu. Spy main window is displayed:

Click Spy button. Move the mouse on the desktop, when a window is found, the mouse cursor changes to a cross-hair pointer. Click once to populate Spy window fields for this specific window. The window name is shown in the "Window name" field. Other window identifiers are listed below:
Field name   Content
 UseWindow  Argument for UseWindow function
 Appl          Application name
 Module  Executable module name
 Class      Window class
 Title  Window title
 Index  Index of the control (when the same control
 is used several times inside the window)
 Instance      Instance number (if several instances of the same window are loaded)
 Handle  Window handle in hexa - Note that GetTopWindowHandleGetFocusWindowHandle and GetWindowHandle function return the
handle as an integer 

For example, Spy on an emtpy notepad window displays:

 

It is possible to truncate this window name in the Window name field ; delete rightmost characters if you want to use a truncated window name in a UseWindow function. Click Validate button to check that the window name is still correct. If window name changes from one replay to another, truncate the window name to keep only the beginning of the window name which does not change.

Click Paste button to paste the window name found by the SPY tool into the script. The paste is done where the cursor is in the Editor window, so before pasting, place the cursor in a new line. This pasted window name can then be used as argument for the UseWindow function.

Spy tool on a Web page

If Spy tool is used on a Web page, the Web Information part of Spy window is filled too. For example, if you load www.wintask.com/demos and if you use Spy to find the HTML descriptor of the Form link, the Spy window is filled like that after having moved the mouse on Form text and clicked once:



HTML tag field returns the tag name for the HTML element where the mouse is. 

The Cursor position fields give the mouse coordinates in pixels relative to the top left corner of the browser client window and relative to the top left corner of the screen. They can be used for generating easily the ClickMouse function.

The HTML attributes box gives the different attributes which can be used for generating the HTML descriptor. Select the one that you want to use.

Descriptor INDEX returns the INDEX number which will be used in the HTML descriptor (when two HTML elements have the same descriptor, an INDEX is added for identifying each element uniquely - see HML descriptor topic).

If the HTML element is an element containing text which can be captured by WinTask (Table, Paragraph, ...), Change CONTENT button can be used to change the CONTENT keyword.

The Descriptor field contains the HTML descriptor as you have generated it using the fields above. Click Paste button to paste it into the script.