Introduction To Surface Automation 5.0.1
Introduction To Surface Automation 5.0.1
Introduction To Surface Automation 5.0.1
Automation
TRAINING GUIDE
Version: 5.0.001
The training materials and other documentation (“Training Materials”) provided by Blue Prism as part of the training course are Blue
Prism’s Intellectual Property and Confidential Information. They are to be used only in conjunction with the Blue Prism Software which
is licensed to your company, and the Training Materials are subject to the terms of that license. In addition, Blue Prism hereby grants to
you a personal, revocable, non-transferable and non-exclusive license to use the Training Materials in a non-production and non-
commercial capacity solely for the purpose of training. You can modify or adapt the Training Materials for your internal use to the
extent required to comply with your operational methods, provided that you shall (a) ensure that each copy shall include all copyright
and proprietary notices included in the Training Materials; (b) keep a written record of the location and use of each such copy; and (c)
provide a copy of such record to Blue Prism on request and allow Blue Prism to verify the same from time to time on request.
For the avoidance of doubt, except as permitted by the license or these terms, you cannot (a) copy, translate, reverse engineer, reverse
assemble, modify, adapt, create derivative works of, decompile, merge, separate, disassemble, determine the source code of or
otherwise reduce to binary code or any other human-perceivable form, the whole or any part of the Training Materials; (b) sublease,
lease, assign, sell, sub-license, rent, export, re-export, encumber, permit concurrent use of or otherwise transfer or grant other rights in
the whole or any part of the Training Materials; or (c) provide or otherwise make available the Training Materials in whole or in part in
any form to any person, without prior written consent from Blue Prism.
All trademarks are hereby acknowledged and are used to the benefit of their respective owners.
Blue Prism is not responsible for the content of external websites referenced by this document.
Blue Prism Limited, Centrix House, Crow Lane East, Newton-le-Willows, WA12 9UY, United Kingdom
Registered in England: Reg. No. 4260035. Tel: +44 870 879 3000. Web: www.blueprism.com
The term thin client is used to describe an application that does not run on the local machine and uses a
client/server architecture. A thick client application is one that is installed directly on the local machine, like Blue
Prism itself. Although some consider web applications as thin client, here we are looking at applications that
operate on a remote machine and are presented to the user via virtualization software like Citrix.
With thin client, Blue Prism cannot use its normal integration techniques because the target application is virtual
and there is very little that spy-modes like Win32 and AA are able to detect. An analogy could be to think of the
surface of a thick client application as having a “landscape” made of buttons, fields, and checkboxes, etc., whereas
the surface of a thin client application is smooth and featureless.
In order to integrate with a thin client application we must redefine the application surface as a series of rectangles
or regions.
To learn the basics, we will first create an interface to the MS Windows Calculator application. We will create a
simple action that will perform a basic calculation and interpret the result.
• Move the mouse over the application to see that it highlights elements much in the same way as Win32.
• Although we can spy Calculator as normal, for this exercise we are going to pretend that we can’t and treat it
as a thin client application
.
• Using the identification tool select the entire Calculator application (as above) and CTRL+left-click to open
the Region Editor.
2.2. Region Editor
The Region Editor displays a screenshot of the element that was spied using the region spy mode. Its purpose is to
provide us with a “drawing area” on which we can create and edit regions.
The region Editor let you create two types of region: the default is a basic rectangle and the other is a more
complex “list” of rectangles which we will look at later.
Key Point
• Region elements are captured as children of the application element initially selected to open the Region
Editor.
.
Exercise 2.2.2 Highlighting a Region
Once captured, a region can be highlighted, much like any other element of the Application Model.
• Launch the application from Application Modeler if you haven’t already done so.
• Select the Key 7 element and press the “Highlight Element” button.
• See that the element is highlighted on the Calculator application.
You can select a region using either the Select tool or by selecting the region name from the
drop-down list in the top-right corner.
• Continue working on your page so that it is able to perform the calculation 789 * 789.
Remember to include the Equals button at the end.
• Launch Calculator using the Launch button if you haven’t already done so.
• Press the Run button (or press F5) to run your page.
• See that the mouse clicks the buttons to perform the calculation.
Key Point
• To reiterate the point, we can spy Calculator as normal but for this exercise, we are going to pretend that we
can’t and treat it as a thin client application.
.
Exercise 3.1.1 Calculator Result Region
We want to use Character Matching to interpret the result of our expression, and to do so we need a screenshot of
the Calculator display area.
• Create a new region for the Calculator display area and rename it Result. Your Region Editor should look
something like this:
In this exercise, we will create a font definition from the list of system fonts.
• With the Results region selected, find the Font property on the right-hand properties list.
• Select New > Identify System Font, as shown below.
Font Smoothing
Font Smoothing is a Windows setting designed to make fonts easier to read by blurring (anti-aliasing) the edges of
text characters. This setting disrupts Character Matching and we need it to be switched off on all Blue Prism PCs.
• In the Text field, type in the same characters shown in the region, i.e., 1234567890. This tells Blue Prism
what characters we are looking to match.
• Click the Search button.
• As it searches, Blue Prism uses each font to create a bitmap image of “1234567890” as it would appear
using that font.
• It then compares that image with the region to see if it could be a match.
• Potential fonts are added to the “Fonts” list and once the search is complete, selecting an item in the Fonts
list will show how “1234567890” looks in that font.
Key Point
• Automatic search requires a degree of experimentation; it may not yield any results or might produce only
partial matches.
.
Exercise 3.2.2 Identifying a System Font (Part 2)
In the previous exercise, the default search settings produce no successful matches; the search was too “narrow”
so we will try adjusting the parameters to include larger fonts.
• Click the blue link next to the Search label to bring up the Search Parameters screen.
• Increase the scope of the search by selecting the font sizes 18 and 20 (you can speed up the search by
deselecting the previously searched sizes).
• Click “OK” to confirm and then search again.
• The “Consolas” font should be identified as a match, as shown below.
• Blue Prism will then generate a font definition and store it in the Blue Prism database. This will make the
font definition available to other Blue Prism machines connected to the database.
• Run the page and you’ll notice that the result is not populated. Blue Prism has failed to recognize the text
and has not provided any error message. Why is this?
• The reason the text can’t be recognized that Blue Prism doesn’t know what color the text is and what color
the background is. We need to tell it what to look for.
• To help Blue Prism identify the text, we must provide the font color or the background color as an input to
the Read stage. In Windows 7, the Calculator background color is a gray gradient so we will identify the
font color instead.
• To determine the font color, take a screenshot of Calculator using the PrntScrn key and paste the
screenshot into Microsoft Paint.
• Zoom in and use the Color Picker tool click on one of the result numbers.
• Then open the Edit Colors window by pressing the toolbar button.
• Confirm that the color in the Color|Solid box is the color of the text and not the surrounding area and
record the Red, Green and Blue (RGB) number, in this case 51, 51, and 51.
• We know need to convert the number to hexadecimal. This can be done in MS Excel using the following
formula =DEC2HEX(number). If your version of Excel doesn’t support this function add the Analysis ToolPak
add-in or use the Windows Calculator and set to Scientific in Windows XP or Programmer in Windows 7.
• Each RGB reference needs to be calculated individually. For example, for RGB code 63, 129, 179
DEC2HEX(63) is 3F
DEC2HEX(129) is 81
DEC2HEX(179) is B3
• The hex code you would provide to Blue Prism would be #3F81B3 (note the use of the prefix hash symbol
#).
The Font input parameter can be left blank because we have already associated the Results
region with the Consolas font in the Region Editor.
The Background input parameter can also be left blank because we only need to provide
one color for the Read stage to work out the difference between foreground and
background colors.
• Before running your page, make sure Object Studio is not maximized and that Calculator is visible and not
obscured by any other window.
• Run the page and see that the Read stage extracts a text value into your Data Item.
3.4. Recognize Text Input Parameters
As we have seen, the Recognize Text method requires input parameters for Font, Color, and Background Color
values. Their usage is described as follows:
Font
• This is the name of the font definition the Read stage should use.
• It can be left blank if the region has a font assigned to it in the Region Editor.
• If the region has no font assigned, the Read stage will use the “system” font of the PC.
Color
• This is the hex code of the foreground color the Read stage should use.
• It must be left blank if a background color has been specified.
• If left blank and no background color is specified, the Read stage will assume the foreground color to be
black.
Background Color
• This is the hex code of the background color the Read stage should use.
• It must be left blank if a foreground color has been specified.
• It can also be set to “auto” to indicate that the least prevalent color in the region is the foreground color.
This is useful if the color of the text in the region is inconsistent.
Normally in Blue Prism you would use the Write stage to send data to an application. This is not possible with a thin
client application though, (remember it is a virtual application that does not really exist on the local machine) so we
must send keystrokes to the application. To do this we use the Global SendKeys method.
In the previous exercises, using Calculator, we executed our calculation by clicking buttons with the mouse but, just
like a human user, we could achieve the same effect by using the keyboard. For us to do this though, we must
ensure that the Calculator is in focus and not hidden by any other windows, including Blue Prism itself.
• Return to your Calculator Business Object and add a new Navigate stage at the start of your page.
• Open the properties form and drag in the Calculator Screen element.
• Select the Activate Application action from the drop-down list and press “OK”.
• Before closing the properties form, enter the Text input parameter to indicate to the Action stage which
keystrokes to send. In this case the expression will be “7”
• Continue to add more Navigate stages so that the page sends the keystrokes for 789 * 789 = .You can do
this a series of single keystroke actions (i.e., 7 then 8 then 9, etc.) or by sending all the keystrokes from one
Navigate stage.
• Run the process. You should see it perform the calculation much like the other page, except that because
we are not using the mouse we do not see the mouse pointer move.
In order to interface with the application safely, we need to not only be able to read the text on the screen but also
be able to interpret images.
• Select the Equals region from the drop-down menu and change the Retain Image property to “True”.
Now we have made the snapshot part of the region, we can use Wait stage to effectively say, “Wait until this region
of the application exists and looks exactly like this.”
• Click the Highlight Element button again and notice that the region is no longer over the Equals button.
Unlike thick client elements, the region element is essentially a rectangular area, relative to the top-left corner of
its parent. To interface with thin client applications, Blue Prism Best Practice recommends qualifying the position of
all elements prior to interaction, and we can do this by reading images.
• Launch the Calculator and step through the action to populate the Data Item.
Exercise 5.1.5 Image Data Item Current Value
We now have an image of the Equals region.
• Reset the Calculator to Standard mode and capture the Equals region again (i.e., step through the page
again).
• Open the Data Item properties and view the image to confirm it is correct.
• Amend the page from the previous exercise so it only contains the Equals Button Data Item.
• We want to capture a screenshot of the application during run time. As we won’t know how big the
application will be (standard mode v scientific mode), we will get these details from the application before
capturing a screenshot.
• First open Application Modeler and then Region Editor.
• Create a new region anywhere on the screen and call it Dynamic Region.
Tip: It doesn’t matter where you put the region because we will move it around the screen
during runtime.
• Close Region Editor and select the element in Application Modeler. Change the Start X, Start Y, End X, and
End Y attributes to dynamic as shown below.
Tip: You can sort the matched attributes by selecting the match column.
• Test your page and inspect the results in the Collection - the Collection captures the position and size of
the Calculator Screen element.
Now we want to take a snapshot image of the screen using the newly acquired bounds.
• Add a Read stage to your page to capture the image using the dynamic attributes of the Dynamic Region.
• Call the Read stage Get Calculator Screen and the Data Item Calculator Screen
• Step though the process and inspect the properties of the Calculator Screen image Data Item. It should
have captured the image of the Calculator screen.
• Set the Calculator to Scientific and step though the action again.
We now have a Data Item containing the Equals button reference image and a Data Item containing an image of
the whole Calculator screen. This means we are able to search for Equals button image and find its position within
the Calculator screen image.
Once we have those coordinates, we can use them as attributes of the Dynamic Region element, thus enabling us
to send a mouse click to the correct position.
• If you haven’t already done so, import the object from the file C:\Program Files\Blue Prism Limited\Blue
Prism Automate\VBO\ BPA Object - Utility - Image Manipulation.xml
Recall from the X and Y values returned when you set the Calculator to normal and scientific mode that the Y value
doesn’t change. This is because the Equals button only moves horizontally within the container element. Hence we
only need to make the Start X and End X coordinates dynamic.
Remember why we need the coordinates of the Equals button. We want to be able to perform the calculation we
created in 1.2 even if the Calculator button moved around the screen.