NEW: AppRobot is now available with Selenium WebDriver, allowing for not only the precise Windows automation you're used to with AppRobot, but Firefox, Internet Explorer, and Chrome browsers as well! Flip back and forth between Windows application automation, web app automation, and keyboard/mouse macros, all in the same script, with extreme ease.
If you’re new to AppRobot then you’re in the right place! Here you will be introduced to the key basics of AppRobot, helping you get started with all the fundamentals that you need to begin automating Windows applications, including web browsers. This tutorial is intended primarily for beginners that have a basic understanding of VBScript.
1) Create a simple Hello AppRobot automation script - Jump to Tutorial
2) Automate the Calculator to perform addition and read the result back to the user (Video Below!) - Jump to Tutorial
3) Automate Firefox, Internet Explorer, or Chrome to visit Google, search for a term, submit, and click a button on the results page - Jump to Tutorial
To begin, open AppRobot Designer after downloading and installing from our homepage.
A bit of a background:
And if you'd really like, go ahead and use only Notepad!
On the flip-side, AppRobot Designer allows you to create powerful and reliable automation quickly and easily by simply browsing and clicking to add the commands you want.
Leveraging the latest in automation technology including Microsoft UI Automation, AppRobot allows you to "attach" to specific user interface items ("UI Items") to perform "actions" on them.
For example, you can attach to a specific button on the screen and click it, rather than having to send unreliable X,Y mouse coordinates when using other tools such as macro recorders (although, a macro recorder is also included with AppRobot, allowing you to record and then run macros in-line within a larger script using the “Recorded Macros -> Play Macro” command, mixing and matching as you please). You can attach to a specific text box and either read text from it, or type text into it. This allows for very precise automation, even if the location of UI Items such as applications, buttons, text boxes, etc. has changed between automation runs (i.e. screen was resized or the application was moved elsewhere on the screen).
The result is a simple, reliable automation script. Let's dive into an example.
Tutorial 1: Hello AppRobot!
In AppRobot Designer, click "FILE -> New" on the menu bar to open a new editor page. Paste in the following code:
Set AppRobot = CreateObject("AppRobot.API") : AppRobot.Print("Hello AppRobot!") :
Now, click "SCRIPT -> Run" on the menu bar (or Ctrl+R on your keyboard). You will be prompted to save the new script, pick an easy-to-find location such as the Desktop and Save. The above code will now run.
That's all there is to the basics!
The Print command allows you to "Print" any text to the AppRobot Printer. Click on "TOOLS -> Open Printer" on the menu bar to view everything you've "printed". This is useful when you don't want to use many MsgBox (MessageBox) VBScript commands in your automation scripts, which interrupt execution each time with a pop-up. Printing to the Printer is silent, so you can view everything you printed at the end.
The above is similar to:
Set AppRobot = CreateObject("AppRobot.API") : MsgBox("Hello AppRobot!") :
OK, we executed a basic Hello AppRobot automation script. From this point, you can continue browsing and adding commands from the left side of the Designer.
~ Select the command you'd like to add to your script by clicking on it
~ Click one of the two green arrow buttons between the commands column and the script editor. The top arrow button adds the command to the line where the cursor is currently located. The bottom arrow button adds the command to the end of the script.
~ A command dialog box may appear asking you which UI Item the command should take action on. You usually specify the UI Item's Name or ID property, or a variable. The Calculator example on this page demonstrates how to find and use the Name or ID property of a UI Item using the AppRobot UI Item Explorer tool.
Let's create another simple script that's a bit more useful.
Tutorial 2: Calculator
We're going to:
~ Launch the Calculator program
~ "Get/Attach" to the Calculator application so commands on UI Items that follow will be performed within it
~ Add 5 + 1
~ Read the addition result into a variable
~ Print result to the AppRobot Printer as well as display it in a Message Box
~ Close the Calculator application once the user clicks OK on the Message Box
The final code will look like this:
Set AppRobot = CreateObject("AppRobot.API") : AppRobot.RunApplication("C:\Windows\System32\calc.exe") : AppRobot.Wait(3000) : Call AppRobot.GetApplication("Name", "Calculator") : Call AppRobot.ButtonClick("Name", "5") : Call AppRobot.ButtonClick("Name", "Add") : Call AppRobot.ButtonClick("Name", "1") : Call AppRobot.ButtonClick("Name", "Equals") : Dim resultText : resultText = AppRobot.TextBoxGetText("ID", "150") : AppRobot.Print("The Result is: " & resultText) : MsgBox("The Result is: " & resultText) : AppRobot.CloseCurrentApplication() :
Follow along with the step-by-step video performing the written instructions listed below:
Here are the detailed steps that will produce the complete code in this example:
1) In AppRobot Designer, click "FILE -> New" on the menu bar to open a blank editor page. At this point, it will be pre-filled with:
Set AppRobot = CreateObject("AppRobot.API") :
2) On the left-hand side, expand the "Application" command option, and click on "Run Application" to select it.
3) Click on the top green Arrow button located in-between the commands and the script editor.
4) A "Run Application" dialog appears, enter the full path to the application you're opening (in our case C:\Windows\System32\calc.exe), click Insert. The command gets inserted into the line where your cursor is currently located:
5) Next, expand the "Timing" command option on the left-hand side, and click on "Wait". Click the bottom green Arrow button in the middle.
6) Enter '3000' milliseconds without quotes (for 3 seconds), and click Insert. This command pauses the script execution, here we'll wait 3 seconds in case the Calculator is slow to load.
Now that the Calculator is open, we are at the interesting part that allows us to take "action" on specific "UI Items", which separates AppRobot from simple macro recorders/players.
7) First, let's "Get", or "Attach", to our Application so future commands that we write will "act" on this application. This saves a lot of time because our code only has to find the application we're automating in the Windows object hierarchy once, rather than each time we perform an action. To attach to our app, expand "Application", and select the "Attach to Application" command. Click the bottom green arrow button. A dialog box appears asking you for the Name or ID property value.
To find either the Name or ID, we will use the AppRobot UI Item Explorer. To open it, click "TOOLS -> Open UI Item Explorer" on the menu bar. To find the "Automation ID" or "Name" of an Application, simply click the "Start Item Explorer" button on the left-hand side, hover over the Application (usually the top part so you select the main window), and press "Ctrl" on your keyboard. The property values will populate on the right-hand side of Item Explorer. When you do this with the calculator, the Name property value of "Calculator" appears, while the AutomationId property is blank. Returning to the Attach to Application dialog box, select "Name" from the drop-down, enter "Calculator" without quotes into the bottom text field, and click the Insert button.
Call AppRobot.GetApplication("Name", "Calculator") :
8) Expand "Common Actions", and select the "Button Click" command.
9) When you look up the property values for button "5" on the calculator using Item Explorer, the property values of "135" for the AutomationId, and "5" for the Name appear. You can use either value in the Designer. Repeat these steps for the "+", "1", "=" buttons, and the TextBox/Label where the Results are displayed. Check to make sure your property values match ours:
~ Button 5: ID: 135 Name: 5
~ Button 1: ID: 131 Name: 1
~ Button +: ID: 93 Name: Add
~ Button =: ID: 121 Name: Equals
~ Label for "Results": ID: 150 Name: Result
10) Click "Stop Item Explorer" and close the UI Item Explorer application.
11) Returning to the Click Button dialog, select "Name" from the drop-down, and enter "5" without quotes into the bottom text field (Note: You could also select "ID" from the drop-down and enter "135" here instead, you should experiment which results in the UI Item being found faster during script runs). When you click Insert, you'll see:
Call AppRobot.ButtonClick("Name", "5") :
12) Repeat Step 11 for buttons "1", "+", and "=", resulting in:
Call AppRobot.ButtonClick("Name", "Add") : Call AppRobot.ButtonClick("Name", "1") : Call AppRobot.ButtonClick("Name", "Equals") :
13) Now, we'll read the result. Under "Common Actions", select "TextBox Get Text", and click a green arrow button.
14) In the drop-down on the Get TextBox Text dialog box select "ID", and without the quotes type "150", and something to name the variable where you'd like to store the result value (we chose "resultText").
Dim resultText : resultText = AppRobot.TextBoxGetText("ID", "150") :
15) Next, we'll output the Result value to a MessageBox and also print it to the AppRobot Printer (to view output, go to Tools -> Open Printer). The MessageBox is the VBScript MsgBox command, so we can type it in directly:
MsgBox("The result is: " & resultText) :
As you can see, you can switch between VBScript and AppRobot code wherever you see fit if you'd like to take advantage of the various COM objects and administration scripts already available to VBScript. Now, we'll switch back to AppRobot:
AppRobot.Print("The result is: " & resultText) :
To insert the above command, expand "Debug" on the left-hand side, select "Print to AppRobot Printer", click a green arrow button. When the Printer dialog box appears, notice you only have the option to enter specific text. What you enter will be sent to the Printer, so once the command is inserted, just delete the string you typed that appears in quotes, and replace it with the variable name you're using to store the value of the addition result (resultText). As you can see, you can pass in variables instead of hard-coded values into the commands you're using. The command dialog boxes allow for a more visual approach to reduce time having to looking up syntax.
16) Once the user running the automation script dismisses/clicks OK on the MessageBox that appears during the script run, we'll close the Calculator. On the left-hand side, expand "Application" and select "Close Current Application". We're using the "Current" command, rather than the "Close Application" command because we already Attached to it earlier in our script. We could, of course, use the other command as well to either close the Calculator or any other running app by locating it using its Name or ID property. Click Insert, and the final command is inserted into your script:
17) Click the Run button, or select "SCRIPT -> Run" on the menu bar to save and run the script. Everything should run automatically, you'll only have to click OK on the MessageBox.
Tutorial 3: Web Browser
To automate the browser, we have several options:
~ Record/replay keystrokes + mouse movements with the AppRobot Macro Recorder tool, independently or as part of a larger AppRobot script
~ Automate Internet Explorer, utilizing the IE COM object, independently or as part of a larger AppRobot script
~ Automate Firefox, Internet Explorer, and Chrome by leveraging the integrated Selenium commands in AppRobot
~ Combination of all of the above
Below, we have a simple example of how to leverage AppRobot + IE's COM object to tap into its functionality directly.
1) Open Google's homepage
2) Find the search box ID using the AppRobot UI Explorer tool ("lst-ib")
3) Set the text and submit the search form using IE's core methods
4) Wait for pages to load using AppRobot's Wait functionality
5) Find the Settings button ID using the AppRobot UI Explorer tool ("abar_button_opt")
6) Click the button
Set AppRobot = CreateObject("AppRobot.API") : Set IE = CreateObject("InternetExplorer.Application") : IE.Visible = 1 : IE.Navigate "https://www.google.com" : Do While (IE.Busy) : AppRobot.Wait(10) : Loop : Set SearchBox = IE.document.getElementByID("lst-ib") : SearchBox.Value = "Hello World!" : Set SearchBox = IE.document.Forms(0) : SearchBox.Submit : Do While (IE.Busy) : AppRobot.Wait(10) : Loop : IE.document.getElementById("abar_button_opt").Click :
AppRobot also comes with tight Selenium WebDriver integration (commands appear on the left-hand side under the Selenium Browser Automation category), making it easy to automate Firefox, IE, and Chrome with a single block of code.
We can achieve the same result as above by using AppRobot commands as follows, simply replace "Firefox" with "IE" or "Chrome" to specify the browser you'd like to automate without having to update any other code below:
AppRobot.RunBrowser("Firefox") : AppRobot.NavigateTo("https://www.google.com") : Call AppRobot.GetElement("ID", "lst-ib") : AppRobot.TypeIntoElement("Hello World!") : AppRobot.SubmitForm() : AppRobot.Wait(3000) : Dim browserTitle : browserTitle = AppRobot.GetWebpageTitle() : AppRobot.Print(browserTitle) : MsgBox(browserTitle) : AppRobot.CloseBrowser() :
Overall, automating with AppRobot breaks down to these general steps:
1) Open Windows Application or Website you'd like to automate
2) Look up a UI Item's (button, text box) Name or ID property using the AppRobot UI Item Explorer tool
3) Look up the UI Item's ControlType (to make sure you're not trying to use a Click action on a Label type thinking it's a Button, for example)
4) Perform an Action on the UI Item (click, select, set text, get text, type, etc...)
5) Repeat steps 2-4 for every UI Item on which you need to perform an Action
6) Optional. Output results to Excel, SQL/MySQL DB, online/network storage, or simply Print to AppRobot Printer for immediate review
7) Optional. Loop through steps 1-6 when performing same steps on multiple records in an input file (Excel or SQL database, for example)
In addition to the examples above, feel free to take a look at and run the included Getting Started script by clicking "HELP -> Getting Started Sample" on the Designer menu bar.
Enjoy and happy automating!