Windows app control

Introduction

Controlling windows app can be useful for automation of processes or for testing. This article provides more insides on possible ways to control application in windows by build-in methods, that are:

  • SendKeys mechanism – that simulates sending keystrokes to the current application
  • Windows GUI
  • IE OLE

Send Key

This way allows to send keystrokes to virtually any active windows application.  The downside is, that the active application can change anytime, so the keystrokes will go to another application.

Windows GUI

It is specific to a given application. It requires knowledge of the application, the GUI components. The components can be addressed by:

  • Windows handler that is globally unique but is dynamically assigned by the operating system.
  • programs ID that is assigned at programing/compilation time and should be unique and remains constant for an application.

Addressing by program ID is more recommended.  Please use tools like Spy++ (or write your own one based on the example) in order to check application’s GUI components.

IE OLE

The method can be used to control HTML documents loaded by IE. It assumes knowledge of the GUI object  “Internet Explorer_Server” and OLE (see Object Linking and Embedding) object ID “626FC520-A41E-11CF-A731-00A0C9082637” that represents the internal HTML document.

Using OLE for controlling HTML pages is more complex due to the nature of HTML.

The example

It requires .Net and has been tested with Win 7 and 8.1

Included examples:

  1. RunKeys with notepad
  2. RunKeys with calculator
  3. GUI with calculator
  4. IE OLE (it assumes only one IE instance with one tab is opened)

The program waits after each example until the current windows will be closed.

Check this VB source code example: WinControlExample

Add mshtml to the project for compilation.

MS_mshtml

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: