Programming with Python / JavaScript / VBScript inline scripting in Automation Anywhere A 2019

Automation Anywhere A2019 allows you to call external scripts and programs. The scripting languages support Python / Javascript / VBScript, which can be prepared as separate files or embedded in the bot as an inline script and executed. If you want to keep it as a separate file, you will have to upload the locally created file to the Control Room in advance. In either case, the script will be executed in the environment of the local PC.

In-line scripting method

Python

  1. In the Bot Editor, find ** "Python script: Open" ** from the Actions palette and drag and drop it.
    Image.png
  2. Select the ** Python script: Open ** icon to open the action details. Then select "Manual input".
    Image.png
  3. Paste the following code into the "Enter script here" text box and save.

Inlinescript


from tkinter import messagebox
messagebox.showinfo('Python', 'Hello World')

image.png

  1. Finally, find ** "Python script: Execute script" ** and ** "Python script: Close" **, drag and drop at the end of the flow, and save.
    Image.png

Note: To execute Python code, you need to build a Python execution environment on your local PC. For more information, see @ zamaezaaa's article "Running Python code on A2019 Community Edition" (https://qiita.com/zamaezaaa/items/b956243ce80f9a652dfb). If you run the bot in an environment without a Python execution environment, the bot will not execute anything and will end normally, but the bot Agent may freeze and the next bot may not be able to run, requiring a reboot. ..

Execution result image.png

Reference information

Javascript

  1. In the Bot Editor, find ** "JavaScript: Open" ** from the Actions palette and drag and drop it.
    image.png
  2. Select the ** JavaScript: Open ** icon to open the action details. Then select "Manual input".
    Image.png
  3. Paste the following code into the "Enter script here" text box and save.

Inlinescript


function getRandom() {
    return Math.floor( Math.random()*10000 );
}

This is a function that returns a random number between 0 and 10,000. image.png

  1. Find ** "JavaScript: Run JavaScript" ** and drag and drop it at the end of the flow, and in the action details, getRandom for the function name to be executed and$ prompt-assignment $for the output storage location. Specify the variable.
    Image.png

  2. Finally, find ** "JavaScript: Close" **, drag and drop it at the end of the flow, insert a MessageBox action after it, and set it to display the $ prompt-assignment $ variable. Save it and you're done.
    Image.png

Execution result image.png

Note: For JavaScript, screen output implemented by browsers such as ʻalert, prompt, writeln, and WSH objects such as WScript.Echo, WScript.StdOut.WriteLine`. Since an error occurred when using, I executed only the value processing with JavaScript and displayed the result in the MessageBox of Automation Anywhere.

Reference information

VBScript

  1. In the Bot Editor, find ** "VBScript: Open" ** from the Actions palette and drag and drop it.
    Image.png
  2. Select the ** VBScript: Open ** icon to open the action details. Then select "Manual input".
    Image.png
  3. Paste the following code into the "Enter script here" text box and save.

Inlinescript


MsgBox "Hello World"

image.png

  1. Finally, find ** "VBScript: Run function" ** and ** "VBScript: Close" **, drag and drop at the end of the flow, and save.
    Image.png

Execution result image.png

Reference information

[^ 1]: The content of the product documentation is updated frequently, so it is recommended to refer to the English version of the documentation.

[^ 2]: Looking at the latest English documentation, in Python you can pass only one argument to the function (Boolean, dictionary, list, number, string), in JavaScript / VBScript you can pass a list type variable It says that you can pass multiple arguments (Boolean, Datetime, number, string etc.). However, in A2019.10 (build 2545), in VBScript, you can enter character strings and numbers in addition to list type variables in "Arguments to the function" in the action details.

Recommended Posts

Programming with Python / JavaScript / VBScript inline scripting in Automation Anywhere A 2019
Get in touch with functional programming in JavaScript or Python 3
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Scraping a website using JavaScript in Python
Launch a Flask app in Python Anywhere
[Automation] Read a Word document with Python
Try a functional programming pipe in Python
Learn dynamic programming in Python (A ~ E)
Programming in python
[Python] Get the files in a folder with Python
I made a competitive programming glossary with Python
To execute a Python enumerate function in JavaScript
[Automation] Extract the table in PDF with Python
Work in a virtual environment with Python virtualenv.
Create a new page in confluence with Python
How to convert / restore a string with [] in python
3. 3. AI programming with Python
UI Automation in Python
Make a simple Slackbot with interactive button in python
Try embedding Python in a C ++ program with pybind11
Python programming with Atom
I want to work with a robot in python.
Competitive programming with python
Python programming in Excel
Run a Python file with relative import in PyCharm
Create a fake Minecraft server in Python with Quarry
Programming with Python Flask
Programming with your smartphone anywhere! (Recommended for C / Python)
Try running python in a Django environment created with pipenv
A Python program in "A book that gently teaches difficult programming"
I made a simple typing game with tkinter in Python
Create a list in Python with all followers on twitter
Create a child account for connect with Stripe in Python
Let's create a script that registers with Ideone.com in Python.
How to import a file anywhere you like in Python
I made a puzzle game (like) with Tkinter in Python
Create a pixel art of Levi Captain with Python programming!
Programming with Python and Tkinter
Take a screenshot in Python
Scraping with selenium in Python
Create a function in Python
Create a dictionary in Python
Scraping with chromedriver in python
Try programming with a shell!
Debugging with pdb in Python
Working with sounds in Python
Scraping with Selenium in Python
[Gimp] Start scripting in Python
Scraping with Tor in Python
Tweet with image in Python
Make a bookmarklet in Python
Make a fortune with Python
UI Automation Part 2 in Python
Draw a heart in Python
Create a directory with python
[Python] Dynamic programming TDPC A
Network programming with Python Scapy
How to create a heatmap with an arbitrary domain in Python
Draw a watercolor illusion with edge detection in Python3 and openCV3
Read a file in Python with a relative path from the program
Solve the subset sum problem with a full search in Python