Activities

Cryptography

automagica.activities.generate_random_key()

Random key

Generate random Fernet key. Fernet guarantees that a message encrypted using it cannot be manipulated or read without the key. Fernet is an implementation of symmetric (also known as “secret key”) authenticated cryptography

Returns:Bytes-like object
Example:
>>> # Generate a random key
>>> generate_random_key()
b'AYv6ZPVgnrUtHDbGZqAopRyAo9r0_UKrA2Rm3K_NjIo='
Keywords
random, key, fernet, hash, security, cryptography, password, secure
Icon
las la-key
automagica.activities.encrypt_text_with_key(text, key)

Encrypt text

Encrypt text with (Fernet) key,

Parameters:
  • text – Text to be encrypted.
  • key – Path where key is stored.
Returns:

bytes-like object.

Example:

>>> # Generate a random key
>>> key = generate_random_key()
>>> # Encrypt text with this key
>>> encrypt_text_with_key('Sample text', key)
b'gAAAAABd8lpG8fNqcj5eXrPPHlx4KeCm-1TgX3jkyhStMfIlgGImIa-qaINZAj8XcxPcG8iu84iT56b_qAW9c5qpe7btUFhtxQ=='
Keywords
random, encryption, secure, security, hash, password, fernet, text
Icon
las la-lock
automagica.activities.decrypt_text_with_key(encrypted_text, key)

Decrypt text

Dexrypt bytes-like object to string with (Fernet) key

Returns:

String

Parameters:
  • encrypted_text – Text to be encrypted.
  • key

    Path where key is stored.

    Example:
>>> # Generate a random key
>>> key = generate_random_key()
>>> # Encrypt text with generated key
>>> encrypted_text = encrypt_text_with_key('Sample text', key)
>>> # Decrypt text with same key
>>> decrypt_text_with_key(encrypted_text, key)
'Sample text'
Keywords
decrypt, random, unlock, un-lock hash, security, cryptography, password, secure, hash, text
Icon
las la-lock-open
automagica.activities.encrypt_file_with_key(input_path, key, output_path=None)

Encrypt file

Encrypt file with (Fernet) key. Note that file will be unusable unless unlocked with the same key.

Parameters:
  • input_file – Full path to file to be encrypted.
  • key – Path where key is stored.
  • output_file – Output path. Default is the same directory with “_encrypted” added to the name
Returns:

Path to encrypted file

Example:

>>> # Generate a random key
>>> key = generate_random_key()
>>> # Create a textfile to illustrate file encryption
>>> textfile_path = make_textfile()
>>> # Encrypt the textfile
>>> encrypt_file_with_key(textfile_path, key=key)
'C:\Users\<username>\generated_textfile_encrypted.txt'
Keywords
encrypt, random, password, secure, secure file, lock
Icon
las la-lock
automagica.activities.decrypt_file_with_key(input_path, key, output_path=None)

Decrypt file

Decrypts file with (Fernet) key

Parameters:
  • input_file – Bytes-like file to be decrypted.
  • key – Path where key is stored.
  • output_file – Outputfile, make sure to give this the same extension as basefile before encryption. Default is the same directory with “_decrypted” added to the name
Returns:

Path to decrypted file

Example:

>>> # Generate a random key
>>> key = generate_random_key()
>>> # Create a textfile to encrypt file
>>> textfile_path = make_textfile()
>>> # Encrypt the textfile
>>> encrypted_textfile = encrypt_file_with_key(textfile_path, key=key)
>>> # Decrypt the newly encrypted file
>>> decrypt_file_with_key(encrypted_textfile, key=key)
'C:\Users\<username>\generated_textfile_encrypted_decrypted.txt'
Keywords
decrypt, random, password, secure, secure file, unlock
Icon
las la-lock-open
automagica.activities.generate_key_from_password(password, salt=None)

Key from password

Generate key based on password and salt. If both password and salt are known the key can be regenerated.

Parameters:
  • password – Passwords
  • salt – Salt to generate key in combination with password. Default value is the hostname. Take in to account that hostname is necessary to generate key, e.g. when files are encrypted with salt ‘A’ and password ‘B’, both elements are necessary to decrypt files.
Returns:

Bytes-like object

Example:

>>> # Generate a key from password
>>> key = generate_key_from_password(password='Sample password')
b'7jGGF5w_xyI0CIZGCmLlnNyUvFpNvIUY08JCHopgAmm8='
Keywords
random, key, fernet, hash, security, cryptography, password, secure, salt
Icon
las la-lock
automagica.activities.generate_hash_from_file(input_path, method='md5', buffer_size=65536)

Hash from file

Generate hash from file

Can be used to create unique identifier for file validation or comparison.

Parameters:
  • file – File to hash
  • method – Method for hashing, choose between ‘md5’, ‘sha256’ and ‘blake2b’. Note that different methods generate different hashes. Default method is ‘md5’.
  • buffer_size – Buffer size for reading file in chunks, default value is 64kb
Returns:

Bytes-like object

Example:

>>> # Generate a text file to illustrate hash
>>> textfile_path = make_textfile()
>>> # Get hash from textfile
>>> generate_hash_from_file(textfile_path)
'1ba249ca5931f3c85fe44d354c2f274d'
Keywords
hash, mdf5, sha256, blake2b, identifier, unique, hashing, fingerprint, comparison
Icon
las la-fingerprint
automagica.activities.generate_hash_from_text(text, method='md5')

Hash from text

Generate hash from text

Parameters:
  • file – Text to hash
  • method

    Method for hashing, choose between ‘md5’, ‘sha256’ and ‘blake2b’. Note that different methods generate different hashes. Default method is ‘md5’.

    Example:
>>> # Generate a hast from text
>>> generate_hash_from_text('Sample text')
'1ba249ca5931f3c85fe44d354c2f274d'
Keywords
Hash, mdf5, sha256, blake2b, identifier, unique, hashing, fingerprint, text, comparison
Icon
las la-fingerprint

Random

automagica.activities.generate_random_number(lower_limit=0, upper_limit=100, fractional=False)

Random number

Random numbers can be integers (not a fractional number) or a float (fractional number).

Parameters:
  • lower_limit – Lower limit for random number
  • upper_limit – Upper limit for random number
  • fractional – Setting this to True will generate fractional number. Default value is False and only generates whole numbers.
Returns:

Random integer or float

Example:

>>> # Generate a random number
>>> generate_random_number()
7
Keywords:
random number, random integer, dice, gamble, rng, random
Icon
las la-dice
automagica.activities.generate_random_boolean()

Random boolean

Generates a random boolean (True or False)

Returns:Boolean
Example:
>>> # Generate a random boolean
>>> generate_random_boolean()
True
Keywords:
random, dice, gamble, rng, coin, coinflip, heads, tails
Icon
las la-coins
automagica.activities.generate_random_name(locale=None)

Random name

Generates a random name. Adding a locale adds a more common name in the specified locale. Provides first name and last name.

Parameters:locale

Add a locale to generate popular name for selected locale.

  • ar_EG - Arabic (Egypt)
  • ar_PS - Arabic (Palestine)
  • ar_SA - Arabic (Saudi Arabia)
  • bg_BG - Bulgarian
  • bs_BA - Bosnian
  • cs_CZ - Czech
  • de_DE - German
  • dk_DK - Danish
  • el_GR - Greek
  • en_AU - English (Australia)
  • en_CA - English (Canada)
  • en_GB - English (Great Britain)
  • en_NZ - English (New Zealand)
  • en_US - English (United States)
  • es_ES - Spanish (Spain)
  • es_MX - Spanish (Mexico)
  • et_EE - Estonian
  • fa_IR - Persian (Iran)
  • fi_FI - Finnish
  • fr_FR - French
  • hi_IN - Hindi
  • hr_HR - Croatian
  • hu_HU - Hungarian
  • hy_AM - Armenian
  • it_IT - Italian
  • ja_JP - Japanese
  • ka_GE - Georgian (Georgia)
  • ko_KR - Korean
  • lt_LT - Lithuanian
  • lv_LV - Latvian
  • ne_NP - Nepali
  • nl_NL - Dutch (Netherlands)
  • no_NO - Norwegian
  • pl_PL - Polish
  • pt_BR - Portuguese (Brazil)
  • pt_PT - Portuguese (Portugal)
  • ro_RO - Romanian
  • ru_RU - Russian
  • sl_SI - Slovene
  • sv_SE - Swedish
  • tr_TR - Turkish
  • uk_UA - Ukrainian
  • zh_CN - Chinese (China)
  • zh_TW - Chinese (Taiwan)
Returns:Name as string
Example:
>>> # Generate a random name
>>> generate_random_name()
'Michelle Murphy'
Keywords
random, dummy name, name, name generater, fake person, fake, person, surname, lastname, fake name generator
Icon
las la-user-tag
automagica.activities.generate_random_sentence(locale=None)

Random sentence

Generates a random sentence. Specifying locale changes language and content based on locale.

Parameters:locale

Add a locale to generate popular name for selected locale.

  • ar_EG - Arabic (Egypt)
  • ar_PS - Arabic (Palestine)
  • ar_SA - Arabic (Saudi Arabia)
  • bg_BG - Bulgarian
  • bs_BA - Bosnian
  • cs_CZ - Czech
  • de_DE - German
  • dk_DK - Danish
  • el_GR - Greek
  • en_AU - English (Australia)
  • en_CA - English (Canada)
  • en_GB - English (Great Britain)
  • en_NZ - English (New Zealand)
  • en_US - English (United States)
  • es_ES - Spanish (Spain)
  • es_MX - Spanish (Mexico)
  • et_EE - Estonian
  • fa_IR - Persian (Iran)
  • fi_FI - Finnish
  • fr_FR - French
  • hi_IN - Hindi
  • hr_HR - Croatian
  • hu_HU - Hungarian
  • hy_AM - Armenian
  • it_IT - Italian
  • ja_JP - Japanese
  • ka_GE - Georgian (Georgia)
  • ko_KR - Korean
  • lt_LT - Lithuanian
  • lv_LV - Latvian
  • ne_NP - Nepali
  • nl_NL - Dutch (Netherlands)
  • no_NO - Norwegian
  • pl_PL - Polish
  • pt_BR - Portuguese (Brazil)
  • pt_PT - Portuguese (Portugal)
  • ro_RO - Romanian
  • ru_RU - Russian
  • sl_SI - Slovene
  • sv_SE - Swedish
  • tr_TR - Turkish
  • uk_UA - Ukrainian
  • zh_CN - Chinese (China)
  • zh_TW - Chinese (Taiwan)
Returns:Random sentence as string
Example:
>>> # Generate a random sentence
>>> generate_random_sentence()
'The age of automation is going to be the age of do-it-yourself'
Keywords
random, sentence, lorem ipsum, text generater, filler, place holder, noise, random text, random txt, text generation, nlp
Icon
las la-comment
automagica.activities.generate_random_address(locale=None)

Random address

Generates a random address. Specifying locale changes random locations and streetnames based on locale.

Parameters:locale

Add a locale to generate popular name for selected locale.

  • ar_EG - Arabic (Egypt)
  • ar_PS - Arabic (Palestine)
  • ar_SA - Arabic (Saudi Arabia)
  • bg_BG - Bulgarian
  • bs_BA - Bosnian
  • cs_CZ - Czech
  • de_DE - German
  • dk_DK - Danish
  • el_GR - Greek
  • en_AU - English (Australia)
  • en_CA - English (Canada)
  • en_GB - English (Great Britain)
  • en_NZ - English (New Zealand)
  • en_US - English (United States)
  • es_ES - Spanish (Spain)
  • es_MX - Spanish (Mexico)
  • et_EE - Estonian
  • fa_IR - Persian (Iran)
  • fi_FI - Finnish
  • fr_FR - French
  • hi_IN - Hindi
  • hr_HR - Croatian
  • hu_HU - Hungarian
  • hy_AM - Armenian
  • it_IT - Italian
  • ja_JP - Japanese
  • ka_GE - Georgian (Georgia)
  • ko_KR - Korean
  • lt_LT - Lithuanian
  • lv_LV - Latvian
  • ne_NP - Nepali
  • nl_NL - Dutch (Netherlands)
  • no_NO - Norwegian
  • pl_PL - Polish
  • pt_BR - Portuguese (Brazil)
  • pt_PT - Portuguese (Portugal)
  • ro_RO - Romanian
  • ru_RU - Russian
  • sl_SI - Slovene
  • sv_SE - Swedish
  • tr_TR - Turkish
  • uk_UA - Ukrainian
  • zh_CN - Chinese (China)
  • zh_TW - Chinese (Taiwan)
Returns:Random address as string
Example:
>>> # Generate a random address
>>> generate_random_address()
'5639 Cynthia Bridge Suite 610
'Port Nancy, GA 95894'
Keywords
random, address, random address, fake person , fake address, fake person generator
Icon
las la-map
automagica.activities.generate_random_beep(max_duration=2000, max_frequency=5000)

Random beep

Generates a random beep, only works on Windows

Parameters:
  • max_duration – Maximum random duration in miliseconds. Default value is 2 miliseconds
  • max_frequency – Maximum random frequency in Hz. Default value is 5000 Hz.
Returns:

Sound

Example:

>>> # Generate a random beep
>>> generate_random_beep()
Keywords
beep, sound, random, noise, alert, notification
Icon
las la-volume-up
automagica.activities.generate_random_date(formatting='%m/%d/%Y %I:%M', days_in_past=1000)

Random date

Generates a random date.

  • %a Abbreviated weekday name.
  • %A Full weekday name.
  • %b Abbreviated month name.
  • %B Full month name.
  • %c Predefined date and time representation.
  • %d Day of the month as a decimal number [01,31].
  • %H Hour (24-hour clock) as a decimal number [00,23].
  • %I Hour (12-hour clock) as a decimal number [01,12].
  • %j Day of the year as a decimal number [001,366].
  • %m Month as a decimal number [01,12].
  • %M Minute as a decimal number [00,59].
  • %p AM or PM.
  • %S Second as a decimal number [00,61].
  • %U Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.
  • %w Weekday as a decimal number [0(Sunday),6].
  • %W Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.
  • %x Predefined date representation.
  • %X Predefined time representation.
  • %y Year without century as a decimal number [00,99].
  • %Y Year with century as a decimal number.
  • %Z Time zone name (no characters if no time zone exists).
Parameters:
  • days_in_past – Days in the past for which oldest random date is generated, default is 1000 days
  • formatting – Formatting of the dates, replace with ‘None’ to get raw datetime format. e.g. format=’Current month is %B’ generates ‘Current month is Januari’ and format=’%m/%d/%Y %I:%M’ generates format 01/01/1900 00:00.
Returns:

Random date as string

Example:

>>> # Generate a random date
>>> generate_random_date()
01/01/2020 13:37'
Keywords
random, date, datetime, random date, fake date , calendar
Icon
las la-calendar
automagica.activities.generate_unique_identifier()

Generate unique identifier

Generates a random UUID4 (universally unique identifier). While the probability that a UUID will be duplicated is not zero, it is close enough to zero to be negligible.

Returns:Identifier as string
Example:
>>> # Generate unique identifier
>>> generate_unique_identifier()
'd72fd7ea-d682-4f78-8ca1-0ed34142a992'
Keywords
unique, identifier, primary key, random
Icon
las la-random

User Input

automagica.activities.ask_user_input(title='Title', label='Input', password=False)

Ask user for input

Prompt the user for an input with a pop-up window.

Parameters:
  • title – Title for the pop-up window
  • message – The message to be shown to the user
Returns:

Inputted text as string

Example:

>>> # Make a window pop-up ask for user input
>>> ask_user_input()
>>> # Type in text and press 'submit', e.g. 'Sample text'
'Sample text'
Keywords
user input, pop-up, interaction, popup, window, feedback, screen, ad-hoc, attended
Icon
las la-window-maximize
automagica.activities.ask_user_password(label='Password')

Ask user for password

Prompt the user for a password. The password will be masked on screen while entering.

Parameters:
  • title – Title for the pop-up window
  • message – The message to be shown to the user
Returns:

Inputted password as string

Example:

>>> # Make a window pop-up ask for user password
>>> ask_user_password()
>>> # Type in password and press 'submit', e.g. 'Sample password'
'Sample password'
Keywords
user input, pop-up, interaction, interactive, credential, popup, window, feedback, password, screen, login, attended
Icon
lar la-window-maximize
automagica.activities.ask_credentials(title='Credentials required', dialogue_text_username='Username:', dialogue_text_password='Password:')

Ask user for credentials

Prompt a popup which asks user for username and password and returns in plain text. Password will be masked.

Parameters:
  • title – Title for the popup
  • dialogue_text – Dialogue text for username
  • dialogue_text – Dialogue text for password
Returns:

Typle with nputted username and password as strings

Example:

>>> # Make a window pop-up ask user credentials
>>> ask_credentials()
>>> # Type in Username and Password 'submit', e.g. 'Sample username' and 'Sample password'
('Sample username', 'Sample password')
Keywords
user input, credentials, interactive, pop-up, interaction, popup, window, feedback, password, screen, login, attended
Icon
las la-window-maximize
automagica.activities.display_message_box(title='Title', message='Example message')

Shows message box

A pop-up message with title and message.

Parameters:
  • title – Title for the pop-up window
  • message – The message to be shown to the user
Returns:

True if user presses ‘OK’

Example:

>>> # Show pop-up with message
>>> display_message_box()
>>> # Wait till user presses 'OK'
True
Keywords
message box, warning, info, popup, window, feedback, screen, attended
Icon
las la-window-maximize
automagica.activities.display_osd_message(message='Example message', seconds=5)

Display overlay message

Display custom OSD (on-screen display) message. Can be used to display a message for a limited amount of time. Can be used for illustration, debugging or as OSD.

Parameters:message

Message to be displayed

Example:
>>> # Display overlay message
>>> display_osd_message()
Keywords
message box, osd, overlay, info warning, info, popup, window, feedback, screen, login, attended
Icon
las la-tv

Browser

class automagica.activities.Chrome(load_images=True, headless=False, incognito=False, disable_extension=False, maximize_window=True, focus_window=True)
by_class(element)

Find class in browser

Find element with specified class on a webpage in the the browser. Can also use native ‘find_element_by_class_name’

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find element by class
>>> elements = browser.by_class('search-input')
>>> # We can now use this element, for example to click on
>>> element.click()
Keywords
browser, class, classes, element, xml element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-times
by_class_and_by_text(element, text)

Find element in browser based on class and text

Find all elements with specified class and text on a webpage in the the browser.

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find elements by class and text
>>> element = browser.by_classes_and_by_text('search-input', 'Free dictionary)
>>> # We can now use this element, for example to click on
>>> element.click()
Keywords
browser, class, text, name classes, element, xml element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-times
by_classes(element)

Find class in browser

Find all elements with specified class on a webpage in the the browser. Can also use native ‘find_elements_by_class_name’ function

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find elements by class
>>> elements = browser.by_classes('search-input')
>>> # We can now use this element, for example to click on
>>> element.click()
Keywords
browser, class, classes, element, xml element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-times
by_id(element)

Find id in browser

Find element with specified id on a webpage in the the browser. Can also use native ‘find_element_by_id’ function

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find element by class
>>> elements = browser.by_cid('search-input')
>>> # We can now use this element, for example to click on
>>> element.click()
Keywords
browser, class, classes, element, xml element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-times
by_text(text)

Find element by text

Find one element by text. Text does not need to match exactly, part of text is enough.

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://nytimes.com')
>>> # Find elements by text
>>> browser.by_text('world')
webelement
Keywords
element, element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-align-center
by_xpath(element)

Find XPath in browser

Find all element with specified xpath on a webpage in the the browser. Can also use native ‘find_elements_by_xpath’

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find element by xpath
>>> elements = browser.by_xpath('//*[@id='js-link-box-en']')
>>> # We can now use this element, for example to click on
>>> element.click()
Keywords
random, xpath, element, xml element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-times
by_xpaths(element)

Find all XPaths

Find all elements with specified xpath on a webpage in the the browser. Can also use native ‘find_elements_by_xpath’

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find elements by xpaths
>>> browser.by_xpaths('//*[@id='js-link-box-en']')
[webelement1, webelement2 , .. ]
Keywords
random, element, xpath, xml, element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-times
exit()

Exit the browser

Quit the browser by exiting gracefully. One can also use the native ‘quit’ function

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://automagica.com')
>>> # Close browser
>>> browser.exit()
Keywords
quit, exit, close, element, element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-window-close

Find all links

Find all links on a webpage in the browser

Parameters:contains

Criteria of substring that url must contain to be included

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://nytimes.com')
>>> # Find elements by text
>>> browser.find_all_links()
[webelement1, webelement2 , .. ]
Keywords
random, element,link, links element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-window-restore
find_elements_by_text(text)

Find elements by text

Find all elements by their text. Text does not need to match exactly, part of text is enough.

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://nytimes.com')
>>> # Find elements by text
>>> browser.find_elements_by_text('world')
[webelement1, webelement2 , .. ]
Keywords
element, element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-align-center

Find first link on a webpage

Find first link on a webpage

Parameters:contains

Criteria of substring that url must contain to be included

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://nytimes.com')
>>> # Find elements by text
>>> browser.find_first_link()
Keywords
random, link, links, element, element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-window-restore
highlight(element)

Highlight element

Highlight elements in yellow in the browser

Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find all links
>>> links = browser.find_all_links()
>>> # Select first link to highlight for illustration
>>> first_link = links[0]
>>> # Highlight first link
>>> browser.highlight(first_link)
Keywords
element, element by text, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-highlighter
save_all_images(output_path=None)

Save all images

Save all images on current page in the Browser

Parameters:output_path – Path where images can be saved. Default value is home directory.
Returns:List with paths to images
Example:
>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://www.nytimes.com/')
>>> # Save all images
>>> browser.save_all_images()
>>> browser.quit()
['C:\Users\<username>\image1.png', 'C:\Users\<username>\image2.jpg', 'C:\Users\<username>\image4.gif']
Keywords
image scraping, chrome, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer
Icon
las la-images

Credential Management

automagica.activities.set_credential(username=None, password=None, system='Automagica')

Set credential

Add a credential which stores credentials locally and securely. All parameters should be Unicode text.

Parameters:
  • username – Username for which credential will be added.
  • password – Password to add
  • system – Name of the system for which credentials are stored. Extra safety measure and method for keeping passwords for similar usernames on different applications a part. Highly recommended to change default value.
Returns:

Stores credentials locally

Example:

>>> set_credential('SampleUsername', 'SamplePassword')
Keywords
credential, login, password, username, store, vault, secure, credentials, store, log in, encrypt
Icon
las la-key
automagica.activities.delete_credential(username=None, password=None, system='Automagica')

Delete credential

Delete a locally stored credential. All parameters should be Unicode text.

Parameters:
  • username – Username for which credential (username + password) will be deleted.
  • system

    Name of the system for which password will be deleted.

    Example:
>>> set_credential('SampleUsername', 'SamplePassword')
>>> delete_credential('SampleUsername', 'SamplePassword')
Keywords
credential, delete, login, password, username, store, vault, secure, credentials, store, log in, encrypt
Icon
las la-key
automagica.activities.get_credential(username=None, system='Automagica')

Get credential

Get a locally stored redential. All parameters should be Unicode text.

Parameters:
  • username – Username to get password for.
  • system – Name of the system for which credentials are retreived.
Returns:

Stored credential as string

Example:

>>> set_credential('SampleUsername', 'SamplePassword')
>>> get_credential('SampleUsername')
'SamplePassword'
Keywords
credential, get, delete, login, password, username, store, vault, secure, credentials, store, log in, encrypt
Icon
las la-key

FTP

class automagica.activities.FTP(server, username, password)
create_directory(directory_name, path='/')

Create FTP directory

Create a FTP directory. Note that sufficient permissions are present

Parameters:
  • directory_name – Name of the new directory, should be a string e.g. ‘my_directory’
  • path – Path to parent directory where to make new directory. Default is main directory
Returns:

Boolean if creation was succesful (True) or failed (False) :Example:

>>> # This example uses the Rebex FPT test server.
>>> # Trying to create a directory will most likely fail due to permission
>>> ftp = FTP('test.rebex.net', 'demo', 'password')
>>> # Create directory
>>> ftp.create_directory('brand_new_directory')      
False
Keywords
FTP, create, create folder, new, new folder, fptfile transfer protocol, filezilla, winscp, server, remote, folder, folders
Icon
las la-folder-plus
directory_exists(path='/')

Check FTP directory

Check if FTP directory exists

Parameters:path – Path to check on existence. Default is main directory
Returns:Boolean
Example:
>>> # This example uses the Rebex FPT test server.
>>> # Take caution uploading and downloading from this server as it is public
>>> ftp = FTP('test.rebex.net', 'demo', 'password')
>>> # Check if 'pub' folder exists in main directory
>>> ftp.directory_exists('\pub')
True
Keywords
FTP, list, upload, fptfile transfer protocol, filezilla, winscp, server, remote, folder, folders
Icon
las la-list-ol
download_file(input_path, output_path=None)

Download file

Downloads a file from FTP server. Connection needs to be established first.

Parameters:
  • input_path – Path to the file on the FPT server to download
  • output_path – Destination path for downloaded files. Default is the same directory with “_downloaded” added to the name
Returns:

Path to output file as string

Example:

>>> # This example uses the Rebex FPT test server.
>>> # Take caution uploading and downloading from this server as it is public
>>> ftp = FTP('test.rebex.net', 'demo', 'password')
>>> # Download Rebex public file 'readme.txt'
>>> ftp.download_file('readme.txt')
'C:\Users\<username>\readme_downloaded.txt'
Keywords
FTP, file transfer protocol, download, filezilla, winscp, server, remote, folder, folders
Icon
las la-download
enumerate_files(path='/')

List FTP files

Generate a list of all the files in the FTP directory

Parameters:path – Path to list files from. Default is the main directory
Returns:Prints list of all files and directories
Example:
>>> # This example uses the Rebex FPT test server.
>>> # Take caution uploading and downloading from this server as it is public
>>> ftp = FTP('test.rebex.net', 'demo', 'password')
>>> # Show all files in main directory
>>> ftp.enumerate_files()
10-27-15  03:46PM       <DIR>          pub
04-08-14  03:09PM                  403 readme.txt
'226 Transfer complete.'
Keywords
FTP, list, upload, fptfile transfer protocol, filezilla, winscp, server, remote, folder, folders
Icon
las la-list-ol
upload_file(input_path, output_path=None)

Upload file

Upload file to FTP server

Parameters:
  • from_path – Path file that will be uploaded
  • to_path – Destination path to upload.
Returns:

Patht to uploaded file as string

Example:

>>> # This example uses the Rebex FPT test server.
>>> # Take caution uploading and downloading from this server as it is public
>>> ftp = FTP('test.rebex.net', 'demo', 'password')
>>> # Create a .txt file for illustration
>>> textfile = make_textfile()
>>> # Upload file to FTP test server
>>> # Not that this might result in a persmission error for public FPT's
>>> ftp.upload_file(textfile)
Keywords
FTP, upload, fptfile transfer protocol, filezilla, winscp, server, remote, folder, folders
Icon
las la-upload

Keyboard

automagica.activities.press_key(key=None)

Press key

Press and release an entered key. Make sure your keyboard is on US layout (standard QWERTY). If you are using this on Mac Os you might need to grant acces to your terminal application. (Security Preferences > Security & Privacy > Privacy > Accessibility)

Supported keys:
‘ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(‘, ,’)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘<’,’=’, ‘>’, ‘?’, ‘@’, ‘[‘, ‘’, ‘]’, ‘^’, ‘_’, ‘`’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’,’f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘{‘, ‘|’, ‘}’, ‘~’, ‘alt’, ‘backspace’, ‘ctrl’, ‘delete’ ‘downarrow’, ‘rightarrow’, ‘leftarrow’, ‘uparrow’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘home’, ‘insert’, ‘pagedown’, ‘pageup’, ‘help’, ‘printscreen’, ‘space’, ‘scrollock’, ‘tab’, shift, ‘win’
Parameters:key – Key to press
Returns:Keypress
Example:
>>> # Open notepad to illustrate typing
>>> run('notepad.exe')
>>> # Press some keys
>>> press_key('a')
>>> press_key('enter')
>>> press_key('b')
>>> press_key('enter')
>>> press_key('c')
Keywords
keyboard, typing, type, key, keystroke, hotkey, press, press key
Icon
las la-keyboard
automagica.activities.press_key_combination(first_key, second_key, third_key=None, force_pyautogui=False)

Press key combination

Press a combination of two or three keys simultaneously. Make sure your keyboard is on US layout (standard QWERTY).

Supported keys:
‘ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(‘, ,’)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘<’,’=’, ‘>’, ‘?’, ‘@’, ‘[‘, ‘’, ‘]’, ‘^’, ‘_’, ‘`’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’,’f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘{‘, ‘|’, ‘}’, ‘~’, ‘alt’, ‘backspace’, ‘ctrl’, ‘delete’ ‘downarrow’, ‘rightarrow’, ‘leftarrow’, ‘uparrow’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘home’, ‘insert’, ‘pagedown’, ‘pageup’, ‘help’, ‘printscreen’, ‘space’, ‘scrollock’, ‘tab’, shift, ‘win’]
Parameters:
  • first_key – First key to press
  • second_key – Second key to press
  • third_key – Third key to press, this is optional.
  • force_pyautogui – Set parameter to true to force the use of pyautogui. This could help when certain keypresses do not work correctly.
Returns:

Key combination

Example:

>>> # Open notepad to illustrate typing
>>> run('notepad.exe')
>>> # Press 'ctrl + s' to prompt save window 
>>> press_key_combination('ctrl', 's')
Keywords
keyboard, key combination, shortcut, typing, type, key, keystroke, hotkey, press, press key
Icon
las la-keyboard

Mouse

automagica.activities.get_mouse_position(delay=None, to_clipboard=False)

Get mouse coordinates

Get the x and y pixel coordinates of current mouse position. These coordinates represent the absolute pixel position of the mouse on the computer screen. The x-coördinate starts on the left side and increases going right. The y-coördinate increases going down.

Parameters:
  • delay – Delay in seconds before capturing mouse position.
  • to_clipboard – Put the coordinates in the clipboard e.g. ‘x=1, y=1’
Returns:

Tuple with (x, y) coordinates

Example:

>>> get_mouse_position()
(314, 271)
Keywords
mouse, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-mouse
automagica.activities.display_mouse_position(duration=10)

Display mouse position

Displays mouse position in an overlay. Refreshes every two seconds. Can be used to find mouse position of element on the screen. These coordinates represent the absolute pixel position of the mouse on the computer screen. The x-coördinate starts on the left side and increases going right. The y-coördinate increases going down.

Parameters:duration – Duration to show overlay.
Returns:Overlay with (x, y) coordinates
Example:
>>> display_mouse_position()
Keywords
mouse, osd, overlay, show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
lars la-search-location
automagica.activities.click(element_id=None, x=None, y=None, delay=0.1)

Mouse click

Clicks on an element based on the element ID (vision) or pixel position determined by x and y coordinates.

Parameters:
  • element_id – ID of the element. To define an element and attach an ID one can use the Automagica recorder. The recorder uses vision to detect an element and can be invoked with the recorder() function.
  • x – X-coördinate
  • y – Y-coördinate
  • delay – Delay between clicks in seconds, standard value is 100 ms.
Returns:

Mouse click

Example:

>>> # Click on a vision element, use the recorder() function to define elements
>>> recorder()
>>> # Use the element ID found by the recorder, e.g.: click(element_id='ABCD')
>>> # Alternatively, click on coordinates
>>> click(x=100, y=100)
Keywords
mouse, vision, mouse, osd, overlay, show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-mouse-pointer
automagica.activities.double_click(element_id=None, x=None, y=None, delay=0.1)

Double mouse click

Double clicks on an element based on the element ID (vision) or pixel position determined by x and y coordinates.

Parameters:
  • id – ID of the element. To define an element and attach an ID one can use the Automagica recorder. The recorder uses vision to detect an element and can be invoked with the recorder() function.
  • x – X-coördinate
  • y – Y-coördinate
  • delay – Delay between double clicks in seconds, standard value is 100 ms.
Returns:

Double mouse click

Example:

>>> # Click on a vision element, use the recorder() function to define elements
>>> recorder()
>>> # Use the element ID found by the recorder, e.g.: double_click(element_id='ABCD')
>>> # Alternatively, click on coordinates
>>> double_click(x=100, y=100)
Keywords
mouse, osd, overlay, double, double click, doubleclick show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-mouse-pointer
automagica.activities.right_click(element_id=None, x=None, y=None, delay=0.1)

Right click

Right clicks on an element based on the element ID (vision) or pixel position determined by x and y coordinates.

Parameters:
  • id – ID of the element. To define an element and attach an ID one can use the Automagica recorder. The recorder uses vision to detect an element and can be invoked with the recorder() function.
  • x – X-coördinate
  • y – Y-coördinate
  • delay – Delay between right clicks in seconds, standard value is 100 ms.
Returns:

Right mouse click

Example:

>>> # Click on a vision element, use the recorder() function to define elements
>>> recorder()
>>> # Use the element ID found by the recorder, e.g.: right_click(element_id='ABCD')
>>> # Alternatively, right click on coordinates
>>> right_click(x=100, y=100)
Keywords
mouse, osd, right click, right, rightclick, overlay, show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-mouse-pointer
automagica.activities.move_mouse_to(x=None, y=None)

Move mouse

Moves te pointer to an element based on the element ID (vision) or pixel position determined by x and y coordinates x-y position.

Parameters:
  • id – ID of the element. To define an element and attach an ID one can use the Automagica recorder. The recorder uses vision to detect an element and can be invoked with the recorder() function.
  • x – X-coördinate
  • y – Y-coördinate
  • delay – Delay between movements in seconds, standard value is 100 ms.
Returns:

Move mouse to (x, y) coordinates

Example:

>>> move_mouse_to(x=100, y=100)
Keywords
mouse, osd, move mouse, right click, right, rightclick, overlay, show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-arrows-alt
automagica.activities.move_mouse_relative(x=None, y=None)

Move mouse relative

Moves the mouse an x- and y- distance relative to its current pixel position.

Parameters:
  • x – X-coördinate
  • y – Y-coördinate
Returns:

Move mouse (x, y) coordinates

Example:

>>> move_mouse_to(x=100, y=100)
>>> wait(1)
>>> move_mouse_relative(x=10, y=10)
Keywords
mouse, osd, move mouse, right click, right, rightclick, overlay, show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-arrows-alt
automagica.activities.drag_mouse_to(x=None, y=None, button='left')

Drag mouse

Drag the mouse from its current position to a entered x-y position, while holding a specified button.

Parameters:
  • x – X-coördinate
  • y – Y-coördinate
  • button – Button to hold while dragging. Options are ‘left’, ‘middle’ and ‘right’. Standard value is ‘left’.
Returns:

Drag mouse (x, y) coordinates

Example:

>>> move_mouse_to(x=100, y=100)
>>> drag_mouse_to(x=1, y=1)
Keywords
mouse, osd, move mouse, right click, right, rightclick, overlay, show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-arrows-alt

Image

automagica.activities.random_screen_snippet(size=100, path=None)

Random screen snippet

Take a random square snippet from the current screen. Mainly for testing and/or development purposes.

Parameters:
  • size – Size (width and height) in pixels for square snippet. Default value is 100 pixels
  • path – Path where snippet will be saved. Default value is home directory with name ‘random_screensnippet.jpg’
Returns:

Path to snippet

Example:

>>> random_screen_snippet()
'C:\Users\<username>\random_screensnippet.jpg'
Keywords
image, random, testing, screengrab, snippet
Icon
las la-crop-alt
automagica.activities.take_screenshot(path=None)

Screenshot

Take a screenshot of current screen.

Parameters:path – Path to save screenshot. Default value is home directory with name ‘screenshot.jpg’.
Returns:Path to screenshot
Example:
>>> take_screenshot
'C:\Users\<username>\screenshot.jpg'
Keywords
image, screenshot, printscreen,
Icon
las la-expand
automagica.activities.click_image(filename=None)

Click on image

This function searches the screen for a match with template image and clicks directly in the middle. Note that this only finds exact matches. For a more advanced and robust vision detection method see Automagica AI functionality.

Parameters:filename – Path to the template image.
Returns:True if image was found and clicked on. False if template image was not found.
Example:
>>> # Create a random snippet from current screen
>>> # This is for illustration and can be replaced by template
>>> snippet = random_screen_snippet(size=10)
>>> # Click on the snippet
>>> click_image(snippet)
Keywords
image matching, matching, vision, button, click, template, template matching.
Icon
las la-image
automagica.activities.double_click_image(filename=None)

Double click image

Double click on similar image on the screen. This function searches the screen for a match with template image and doubleclicks directly in the middle. Note that this only finds exact matches. For a more advanced and robust vision detection method see Automagica AI functionality.

Parameters:filename – Path to the template image.
Returns:True if image was found and double clicked on. False if template image was not found.
Example:
>>> # Create a random snippet from current screen
>>> # This is for illustration and can be replaced by template
>>> snippet = random_screen_snippet(size=10)
>>> # Click on the snippet
>>> double_click_image(snippet)
Keywords
image matching, matching, vision, button, double click, template, template matching,click
Icon
las la-image
automagica.activities.right_click_image(filename=None)

Right click image

Right click on similar image on the screen. This function searches the screen for a match with template image and right clicks directly in the middle. Note that this only finds exact matches. For a more advanced and robust vision detection method see Automagica AI functionality.

Returns:True if image was found and right clicked on. False if template image was not found.
Example:
>>> # Create a random snippet from current screen
>>> # This is for illustration and can be replaced by template
>>> snippet = random_screen_snippet(size=10)
>>> # Click on the snippet
>>> right_click_image(snippet)
Keywords
image matching, matching, vision, button, right click, template, template matching, click
Icon
las la-image
automagica.activities.locate_image_on_screen(filename=None)

Locate image on screen

Find exact image on the screen. This function searches the screen for a match with template image and clicks directly in the middle. Note that this only finds exact matches. For a more advanced and robust vision detection method see Automagica AI functionality.

Parameters:filename – Path to the template image.
Returns:Tuple with (x, y) coordinates if image is found. None if image was not found
Example:
>>> # Create a random snippet from current screen
>>> # This is for illustration and can be replaced by template
>>> snippet = random_screen_snippet(size=10)
>>> # Click on the snippet
>>> locate_image_on_screen(snippet)
Keywords
image matching, matching, vision, button, right click, template, template matching, click
Icon
las la-image

Folder Operations

automagica.activities.get_files_in_folder(path=None, extension=None, show_full_path=True, scan_subfolders=False)

List files in folder

List all files in a folder (and subfolders) Checks all folders and subfolders for files. This could take some time for large repositories.

Parameters:
  • path – Path of the folder to retreive files from. Default folder is the home directory.
  • extension – Optional filter on certain extensions, for example ‘pptx’, ‘exe,’ xlsx’, ‘txt’, .. Default value is no filter.
  • show_full_path – Set this to True to show full path, False will only show file or dirname. Default is True
Scan_subfolders:
 

Boolean to scan subfolders or not. Not that depending on the folder and hardware this activity could take some time if scan_subfolders is set to True

Returns:

List of files with their full path

Example:

>>> # List all files in the homedirectory
>>> get_files_in_folder()
['C:\Users\<username>\file1.jpg', 'C:\Users\<username>\file2.txt', ... ]
Keywords
folder, files, explorer, nautilus, folder, file, create folder, get files, list files, all files, overview, get files
Icon
las la-search
automagica.activities.create_folder(path=None)

Create folder

Creates new folder at the given path.

Parameters:path – Full path of folder that will be created. If no path is specified a folder called ‘new_folder’ will be made in home directory. If this folder already exists 8 random characters will be added to the name.
Returns:Path to new folder as string
Example:
>>> # Create folder in the home directory
>>> create_folder()
'C:\Users\<username>\new_folder'
Keywords
create folder, folder, folders, make folder, new folder, folder manipulation, explorer, nautilus
Icon
las la-folder-plus
automagica.activities.rename_folder(input_path, new_name=None)

Rename folder

Rename a folder

Parameters:
  • path – Full path of folder that will be renamed
  • new_name – New name of the folder e.g. ‘new_folder’. By default folder will be renamed to original folder name with ‘_renamed’ added to the folder name.
Returns:

Path to renamed folder as a string. None if folder could not be renamed.

Example:

>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Rename the folder
>>> rename_folder(testfolder, new_name='testfolder_brand_new_name')
'C:\Users\<username>\testfolder_brand_new_name'
Keywords
folder, rename, rename folder, organise folder, folders, folder manipulation, explorer, nautilus
Icon
las la-folder
automagica.activities.show_folder(path=None)

Open a folder

Open a folder with the default explorer.

Parameters:path – Full path of folder that will be opened. Default value is the home directory
Returns:Path to opend folder as a string
Example:
>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Open folder
>>> show_folder(testfolder)
'C:\Users\<username>\new_folder'
Keywords
folder, open, open folder, explorer, nautilus
Icon
las la-folder-open
automagica.activities.move_folder(from_path, to_path)

Move a folder

Moves a folder from one place to another. If the new location already contains a folder with the same name, a random 4 character uid is added to the name.

Parameters:
  • fom_path – Full path to the source location of the folder
  • new_path

    Full path to the destination location of the folder.

    return:Path to new location of folder as a string. None if folder could not be moved.
    Example:
>>> # Make new folder in home directory for illustration
>>> # If no new_folder exists in home dir this will be called new_folder
>>> testfolder = create_folder()
>>> # Make a second new folder
>>> # Since new_folder already exists this folder will get a random id added (in this case abc1)
>>> testfolder_2 = create_folder()
>>> # Move testfolder in testfolder_2
>>> move_folder(testfolder, testfolder_2)
'C:\Users\<username>\new_folder_abc1\new_folder'
Keywords
folder, move, move folder, explorer, nautilus, folder manipulation
Icon
las la-folder
automagica.activities.remove_folder(path, allow_root=False, delete_read_only=True)

Remove folder

Remove a folder including all subfolders and files. For the function to work optimal, all files and subfolders in the main targetfolder should be closed.

Parameters:
  • path – Full path to the folder that will be deleted
  • allow_root – Allow paths with an arbitrary length of 10 characters or shorter to be deleted. Default value is False.
Returns:

Path to deleted folder as a string

Example:

>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Check if folder exists
>>> print( folder_exists(testfolder) ) # Should print True
>>> # Remove folder
>>> remove_folder(testfolder)
>>> # Check again if folder exists
>>> folder_exists(testfolder)
False
Keywords
folder, delete folder, delete, nautilus, folder manipulation, explorer, delete folder, remove, remove folder
Icon
las la-folder-minus
automagica.activities.empty_folder(path, allow_root=False)

Empty folder

Remove all contents from a folder For the function to work optimal, all files and subfolders in the main targetfolder should be closed.

Parameters:
  • path – Full path to the folder that will be emptied
  • allow_root

    Allow paths with an arbitrary length of 10 characters or shorter to be emptied. Default value is False.

    Example:
>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Make new textfile in this folder
>>> import os
>>> textfile_location = os.path.join(testfolder, 'testfile.txt')
>>> make_textfile(output_path=textfile_location )
>>> # Print all files in the testfolder
>>> print( get_files_in_folder(testfolder) ) # Should show 
>>> # Empty the folder
>>> empty_folder(testfolder)
>>> # Check what is in the folder
>>> get_files_in_folder(testfolder)
[]
Keywords
folder, empty folder, delete, empty, clean, clean folder, nautilus, folder manipulation, explorer, delete folder, remove, remove folder
Icon
las la-folder-minus
automagica.activities.folder_exists(path)

Checks if folder exists

Check whether folder exists or not, regardless if folder is empty or not.

Parameters:path – Full path to folder
Returns:Boolean
Example:
>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Check if folder exists
>>> folder_exists(testfolder)
True
Keywords
folder, folder exists, nautilus, explorer, folder manipulation, files
Icon
las la-folder
automagica.activities.copy_folder(from_path, to_path=None)

Copy a folder

Copies a folder from one place to another. If the new location already contains a folder with the same name, a random 4 character id is added to the name.

Parameters:
  • old_path – Full path to the source location of the folder
  • new_path – Full path to the destination location of the folder. If no path is specified folder will get copied in the from_path directory
Returns:

Path to new folder as string

Example:

>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Copy this folder
>>> # Since new_folder already exists in home dir this folder will get a random id added (in this case abc1)
>>> copy_folder(testfolder)
Keywords
folder, move, move folder, explorer, nautilus, folder manipulation
Icon
lar la-folder
automagica.activities.zip_folder(path, new_path=None)

Zip

Zia folder and it’s contents. Creates a .zip file.
Parameters:
  • path – Full path to the source location of the folder that will be zipped
  • new_path – Full path to save the zipped folder. If no path is specified a folder with the original folder name plus 4 random characters
Returns:

Path to zipped folder

Example:

>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Zip this folder
>>> zip_folder(testfolder)
Keywords
zip, zipping, winrar, rar, 7zip, compress, unzip
Icon
las la-archive
automagica.activities.unzip(path, to_path=None)

Unzip

Unzips a file or folder from a .zip file.

Parameters:
  • path – Full path to the source location of the file or folder that will be unzipped
  • to_path – Full path to save unzipped contents. If no path is specified the unzipped contents will be stored in the same directory as the zipped file is located.
Returns:

Path to unzipped folder

Example:

>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Zip this folder
>>> zipped_folder = zip_folder(testfolder)
>>> # Unzip this folder
>>> unzip(zipped_folder)
Keywords
zip, zipping, winrar, rar, 7zip, compress, unzip
Icon
las la-archive
automagica.activities.most_recent_file(path=None)

Return most recent file in directory

Return most recent file in directory

Parameters:path – Path which will be scanned for most recent file
Returns:Path to most recent file
Example:
>>> # Find most recent file in homedir
>>> most_recent_file(path=homedir())
Keywords
find file, file, recent, newest, latest, recent
Icon
las la-clock

Delay

automagica.activities.wait(seconds=1)

Wait

Make the robot wait for a specified number of seconds. Note that this activity is blocking. This means that subsequent activities will not occur until the the specified waiting time has expired.

Parameters:seconds

Time in seconds to wait

Example:
>>> print('Start the wait')
>>> wait()
>>> print('The wait is over')
Keywords
wait, sleep, time, timeout, time-out, hold, pause
Icon
las la-hourglass
automagica.activities.wait_for_image(path=None, timeout=60)

Wait for image

Waits for an image to appear on the screen Note that this activity waits for an exact match of the template image to appear on the screen. Small variations, such as color or resolution could result in a mismatch.

Parameters:
  • path – Full or relative path to the template image.
  • timeout

    Maximum time in seconds to wait before continuing. Default value is 60 seconds.

    Example:
>>> # Create a random snippet from current screen
>>> # This is for illustration and can be replaced by template
>>> snippet = random_screen_snippet(size=10)
>>> # Wait for the snippet to be visible
>>> wait_for_image(snippet)
Keywords
image matching, wait, pause, vision, template, template matching
Icon
las la-hourglass
automagica.activities.wait_folder_exists(path, timeout=60)

Wait for folder

Waits until a folder exists. Not that this activity is blocking and will keep the system waiting.

Parameters:
  • path – Full path to folder.
  • timeout

    Maximum time in seconds to wait before continuing. Default value is 60 seconds.

    Example:
>>> # Create a random folder
>>> testfolder = create_folder()
>>> # Wait for the snippet to be visible
>>> wait_folder_exists(testfolder)
Keywords
image matching, wait, pause, vision, template, template matching
Icon
las la-hourglass

Word Application

class automagica.activities.Word(visible=True, file_path=None)
append_text(text)

Append text

Append text at end of Word document.

Parameters:text

Text to append to document

Example:
>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
Keywords
word, editor, text, text edit, office, document, microsoft word, doc, docx
Icon
lar la-file-word
export_to_html(path=None)

Export to HTML

Export to HTML

Parameters:path

Output path where HTML file will be exported to. Default path is home directory with filename ‘html_export.html’.

Example:
>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
>>> word.replace_text('sample', 'real')
>>> word.export_to_html('output.html')
Keywords
word, html, document, export, save as
Icon
las la-html5
export_to_pdf(path=None)

Export to PDF

Export the document to PDF

Parameters:path

Output path where PDF file will be exported to. Default path is home directory with filename ‘pdf_export.pdf’.

Example:
>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
>>> word.replace_text('sample', 'real')
>>> word.export_to_pdf('output.pdf')
Keywords
word, pdf, document, export, save as
Icon
lar la-file-pdf
quit()

Quit Word

This closes Word, make sure to use ‘save’ or ‘save_as’ if you would like to save before quitting.

Example:
>>> # Open Word  
>>> word = Word()
>>> # Quit Word
>>> word.quit()
Keywords
excel, exit, quit, close
Icon
la-file-word
read_all_text(return_as_list=False)

Read all text

Read all the text from a document

Parameters:return_as_list – Set this paramater to True to return text as a list of strings. Default value is False.
Returns:Text from the document
Example:
>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
>>> word.replace_text('sample', 'real')
>>> word.read_all_text()
'This is real text'
Keywords
word, extract, text, document
Icon
lar la-file-word
replace_text(placeholder_text, replacement_text)

Replace text

Can be used for example to replace arbitrary placeholder value. For example when using template document, using ‘XXXX’ as a placeholder. Take note that all strings are case sensitive.

Parameters:
  • placeholder_text – Placeholder text value (string) in the document, this will be replaced, e.g. ‘Company Name’
  • replacement_text

    Text (string) to replace the placeholder values with. It is recommended to make this unique to avoid wrongful replacement, e.g. ‘XXXX_placeholder_XXX’

    Example:
>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
>>> word.replace_text('sample', 'real')
Keywords
word, replace, text, template
Icon
lar la-file-word
set_footers(text)

Set footers

Set the footers of the document

Parameters:text

Text to put in the footer

Example:
>>> # Start Word
>>> word = Word()
>>> word.set_footers('This is a footer!')
Keywords
word, footer, footers
Icon
las la-heading
set_headers(text)

Set headers

Set the headers of the document

Parameters:text

Text to put in the header

Example:
>>> # Start Word
>>> word = Word()
>>> word.set_headers('This is a header!')
Keywords
word, header, headers
Icon
las la-subscript

Word File

class automagica.activities.WordFile(file_path=None)
append_text(text, auto_save=True)

Append text

Append text at the end of the document

Parameters:
  • text – Text to append
  • auto_save

    Save document after performing activity. Default value is True

    Example:
>>> wordfile = WordFile()
>>> wordfile.append_text('Some sample text')
Keywords
word, append text, add text
Icon
las la-file-word
read_all_text(return_as_list=False)

Read all text

Read all the text from the document

Parameters:return_as_list – Set this paramater to True to return text as a list of strings. Default value is False.
Returns:Text of the document
Example:
>>> wordfile = WordFile()
>>> wordfile.append_text('Some sample text')
>>> wordfile.read_all_text()
'Some sample text'
Keywords
word, read, text, file
Icon
las la-file-word
replace_text(placeholder_text, replacement_text, auto_save=True)

Replace all

Replaces all occurences of a placeholder text in the document with a replacement text.

Can be used for example to replace arbitrary placeholder value. For example when using template slidedeck, using ‘XXXX’ as a placeholder. Take note that all strings are case sensitive.

Parameters:
  • placeholder_text – Placeholder text value (string) in the document, this will be replaced, e.g. ‘Company Name’
  • replacement_text – Text (string) to replace the placeholder values with. It is recommended to make this unique to avoid wrongful replacement, e.g. ‘XXXX_placeholder_XXX’
  • auto_save

    Save document after performing activity. Default value is True

    Example:
>>> wordfile = WordFile()
>>> wordfile.append_text('Some sample text')
>>> wordfile.replace_text('sample', 'real')
Keywords
word, replace text, template
Icon
las la-file-word
save()

Save

Save document

Example:
>>> wordfile = WordFile()
>>> wordfile.append_text('Some sample text')
>>> wordfile.save()
Keywords
word, save, store
Icon
las la-file-word
save_as(path)

Save as

Save file on specified path

Parameters:path

Path to save Wordfile to

Example:
>>> wordfile = WordFile()
>>> wordfile.append_text('Some sample text')
>>> wordfile.save_as('document.docx')
Keywords
word, save as, store
Icon
las la-file-word
set_headers(text, auto_save=True)

Set headers

Set headers of Word document

Parameters:
  • text – Text to put in the header
  • auto_save

    Save document after performing activity. Default value is True

    Example:
>>> wordfile = WordFile()
>>> wordfile.append_text('Some sample text')
>>> wordfile.set_headers('This is a header')
Keywords
word, header text
Icon
las la-file-word

Outlook Application

class automagica.activities.Outlook(account_name=None)
add_contact(email, first_name='', last_name='')

Add a contact

Add a contact to Outlook contacts

Parameters:
  • email – The e-mail address for the contact
  • first_name – First name for the contact (optional)
  • last_name

    Last name for the contact (optional)

    Example:
>>> outlook = Outlook()
>>> outlook.add_contact('sales@automagica.com')
Keywords
outlook, create contact, add contact
Icon
las la-mail-bulk
delete_mails(folder_name='Inbox', limit=0, subject_contains='', body_contains='', sender_contains='')

Delete e-mails

Deletes e-mail messages in a certain folder. Can be specified by searching on subject, body or sender e-mail.

Parameters:
  • folder_name – Name of the Outlook folder, can be found using get_folders
  • limit – Maximum number of e-mails to delete in one go
  • subject_contains – Only delete e-mail if subject contains this
  • body_contains – Only delete e-mail if body contains this
  • sender_contains

    Only delete e-mail if sender contains this

    Example:
>>> outlook = Outlook()
>>> outlook.delete_mails(subject_contains='hello')
Keywords
outlook, remove e-mails, delete mail, remove mail
Icon
las la-mail-bulk
get_contacts(fields=None)

Retrieve contacts

Retrieve all contacts

Parameters:fields – Fields can be specified as a tuple with their exact names. Standard value is None returning “LastName”, “FirstName” and “Email1Address”.
Returns:List of dictionaries containing the contact details.
Example:
>>> outlook = Outlook()
>>> outlook.get_contacts()
[
    {
        'LastName': 'Doe',
        'FirstName' : 'John',
        'Email1Address': 'john@test.com'
    }
]
Keywords
outlook, get contacts, download contacts, rolodex
Icon
las la-mail-bulk
get_folders(limit=999)

Retrieve folders

Retrieve list of folders from Outlook

Parameters:limit

Maximum number of folders to retrieve

Example:
>>> outlook = Outlook()
>>> outlook.get_folders()
['Inbox', 'Sent', ...]
Keywords
outlook, get folders, list folders
Icon
las la-mail-bulk
get_mails(folder_name='Inbox', fields=None)

Retrieve e-mails

Retrieve list of messages from Outlook

Parameters:
  • folder_name – Name of the Outlook folder, can be found using get_folders.
  • limit – Number of messages to retrieve
  • fields – Fields (properties) of e-mail messages to give, requires tupl Stadard is ‘Subject’, ‘Body’, ‘SentOn’ and ‘SenderEmailAddress’.
Returns:

List of dictionaries containing the e-mail messages with from, to, subject, body and html.

Example:

>>> outlook = Outlook()
>>> outlook.get_mails()
[
    {
        'Subject': 'Hello World!',
        'Body' : 'This is an e-mail',
        'SenderEmailAddress': 'from@test.com'
    }
]
Keywords
outlook, retrieve e-mail, receive e-mails, process e-mails, get mails
Icon
las la-mail-bulk
move_mails(source_folder_name='Inbox', target_folder_name='Archive', limit=0, subject_contains='', body_contains='', sender_contains='')

Move e-mails

Move e-mail messages in a certain folder. Can be specified by searching on subject, body or sender e-mail.

Parameters:
  • source_folder_name – Name of the Outlook source folder from where e-mails will be moved, can be found using get_folders
  • target_folder_name – Name of the Outlook destination folder to where e-mails will be moved, can be found using get_folders
  • limit – Maximum number of e-mails to move in one go
  • subject_contains – Only move e-mail if subject contains this
  • body_contains – Only move e-mail if body contains this
  • sender_contains

    Only move e-mail if sender contains this

    Example:
>>> outlook = Outlook()
>>> outlook.move_mails(subject_contains='move me')
Keywords
outlook, move e-mail, move e-mail to folder
Icon
las la-mail-bulk
quit()

Quit

Close the Outlook application

Example:
>>> outlook = Outlook()
>>> outlook.quit()
Keywords
outlook, close, quit
Icon
las la-mail-bulk
save_attachments(folder_name='Inbox', target_folder_path=None)

Save attachments

Save all attachments from certain folder

Parameters:
  • folder_name – Name of the Outlook folder, can be found using get_folders.
  • target_folder_path – Path where attachments will be saved. Default is the home directory.
Returns:

List of paths to saved attachments.

Example:

>>> outlook = Outlook()
>>> outlook.save_attachments()
['Attachment.pdf', 'Signature_image.jpeg']
Keywords
outlook, save attachments, download attachments, extract attachments
Icon
las la-mail-bulk
send_mail(to_address, subject='', body='', html_body=None, attachment_paths=None)

Send e-mail

Send an e-mail using Outlook

Parameters:
  • to_address – The e-mail address the e-mail should be sent to
  • subject – The subject of the e-mail
  • body – The text body contents of the e-mail
  • html_body – The HTML body contents of the e-mail (optional)
  • attachment_paths

    List of file paths to attachments

    Example:
>>> outlook = Outlook()
>>> outlook.send_mail('test@test.com', subject='Hello world', body='Hi there')
Keywords
outlook, send e-mail, send mail
Icon
las la-mail-bulk

Excel Application

class automagica.activities.Excel(visible=True, file_path=None)
activate_first_empty_cell_down()

Activate first empty cell down

Activates the first empty cell going down

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Write some cells
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(1, 2, 'Filled')
>>> excel.write_cell(1, 3, 'Filled')
>>> # Activate the first empty cell going down, in this case cell A4 or (1,4)
>>> excel.activate_first_empty_cell_down()
Keywords
excel, first empty cell, down
Icon
las la-file-excel
activate_first_empty_cell_left()

Activate first empty cell left

Activates the first empty cell going left

Example:
>>> # Open Excel
>>> excel = Excel()
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(1, 2, 'Filled')
>>> excel.write_cell(1, 3, 'Filled')
>>> excel.activate_first_empty_cell_left()
Keywords
excel, first empty cell, left
Icon
las la-file-excel
activate_first_empty_cell_right()

Activate first empty cell right

Activates the first empty cell going right

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Write some cells
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(1, 2, 'Filled')
>>> excel.write_cell(1, 3, 'Filled')
>>> # Activate the first empty cell going right, in this case cell B1 or (2,1)
>>> excel.activate_first_empty_cell_right()
Keywords
excel, first empty cell, right
Icon
las la-file-excel
activate_first_empty_cell_up()

Activate first empty cell up

Activates the first empty cell going up

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Write some cells
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(1, 2, 'Filled')
>>> excel.write_cell(1, 3, 'Filled')
>>> # Activate first empty cell
>>> excel.activate_first_empty_cell_up()
Keywords
excel, first empty cell, up
Icon
las la-file-excel
activate_range(range_)

Activate range

Activate a particular range in the currently active workbook

Parameters:range

Range to activate, e.g. “A1:D10”

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Activate a cell range
>>> excel.activate_range('A1:D5')
Keywords
excel, activate range, make selection, select cells, select range
Icon
las la-file-excel
activate_worksheet(name)

Activate worksheet

Activate a worksheet in the current Excel document by name

Parameters:name

Name of the worksheet to activate

Example:
>>> # Open Excel   
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Add another worksheet
>>> excel.add_worksheet('Another Worksheet')
>>> # Activate the first worksheet
>>> excel.activate_worksheet('My Example Worksheet)
Keywords
excel, activate worksheet, set worksheet, select worksheet, select tab, activate tab
Icon
las la-file-excel
add_worksheet(name=None)

Add worksheet

Adds a worksheet to the current workbook

Parameters:

workbook – Workbook object which is retrieved with either new_workbook or open_workbook

Parmeter name:

Give the sheet a name (optional)

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Add a worksheet
>>> excel.add_worksheet('My Example Worksheet')
Keywords
excel, add worksheet, add tab, insert worksheet, new worksheet
Icon
las la-file-excel
delete_column(range_)

Delete column

Delet a column from the currently active worksheet. Existing columns will shift to the left.

Parameters:column

Column letter (string) where to delete column e.g. ‘A’

Example:
>>> # Open Excel              
>>> excel = Excel()
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(2, 2, 'Filled')
>>> excel.write_cell(3, 3, 'Filled')
>>> excel.delete_column(2)
Keywords
excel, delete column, remove column
Icon
las la-file-excel
delete_row(row)

Delete row in Excel

Deletes a row from the currently active worksheet. Existing data will shift up.

Parameters:row

Row number (integer) where to delete row e.g 1

Example:
>>> # Open Excel              
>>> excel = Excel()
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(2, 2, 'Filled')
>>> excel.write_cell(3, 3, 'Filled')
>>> excel.delete_row(2)
Keywords
excel, delete row, remove row
Icon
las la-file-excel
export_to_pdf(path=None)

Export to PDF

Export to PDF

Parameters:path

Output path where PDF file will be exported to. Default path is home directory with filename ‘pdf_export.pdf’.

Example:
>>> # Open Excel              
>>> excel = Excel()
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(2, 2, 'Filled')
>>> excel.write_cell(3, 3, 'Filled')
>>> excel.export_to_pdf('output.pdf')
Keywords
excel, save as pdf, export to pdf, export as pdf
Icon
las la-file-excel
get_table(name)

Get table

Get table data from the currently active worksheet by name of the table

Parameters:name

List of table names

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Create a table (Table1)
>>> data = [
    {
        'Column A': 'Data Row 1 for A',
        'Column B': 'Data Row 1 for B',
        'Column C': 'Data Row 1 for C',
    },
    {
        'Column A': 'Data Row 2 for A',
        'Column B': 'Data Row 2 for B',
        'Column C': 'Data Row 2 for C',
    }]
>>> excel.insert_data_as_table(data)
>>> # Get the table
>>> excel.get_table('Table1')
[['Column A', 'Column B', 'Column C'], ['Row 1 A Data', 'Row 1 B Data', 'Row 1 C Data'], ...]
Keywords
excel, worksheet names, tab names
Icon
las la-file-excel
get_worksheet_names()

Get worksheet names

Get names of all the worksheets in the currently active workbook

Returns:List is worksheet names
Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Add a worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Get all worksheet names
>>> excel.get_worksheet_names()
['Sheet1', 'My Example Worksheet']
Keywords
excel, worksheet names, tab names
Icon
las la-file-excel
insert_data_as_table(data, range_='A1', table_style='TableStyleMedium2')

Insert data as table

Insert list of dictionaries as a table in Excel

Parameters:
  • data – List of dictionaries to write as table
  • range

    Range or startingpoint for table e.g. ‘A1’

    Example:
>>> excel = Excel()
>>> data = [
    {
        'Column A': 'Data Row 1 for A',
        'Column B': 'Data Row 1 for B',
        'Column C': 'Data Row 1 for C',
    },
    {
        'Column A': 'Data Row 2 for A',
        'Column B': 'Data Row 2 for B',
        'Column C': 'Data Row 2 for C',
    }
>>> excel.insert_data_as_table(data)
Keywords
excel, insert data, insert table, create table
Icon
las la-file-excel
insert_empty_column(column)

Insert empty column

Inserts an empty column in the currently active worksheet. Existing columns will shift to the right.

Parameters:column

Column letter (string) where to insert empty column e.g. ‘A’

Example:
>>> # Open Excel
>>> excel = Excel()
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(2, 2, 'Filled')
>>> excel.write_cell(3, 3, 'Filled')
>>> excel.insert_empty_column(2)
Keywords
excel, insert column, add column
Icon
las la-file-excel
insert_empty_row(row)

Insert empty row

Inserts an empty row to the currently active worksheet

Parameters:row

Row number (integer) where to insert empty row e.g 1

Example:
>>> # Open Excel              
>>> excel = Excel()
>>> excel.write_cell(1, 1, 'Filled')
>>> excel.write_cell(1, 2, 'Filled')
>>> excel.write_cell(1, 3, 'Filled')
>>> excel.insert_empty_row(2)
Keywords
excel, insert row, add row, empty row
Icon
las la-file-excel
quit()

Quit Excel

This closes Excel, make sure to use ‘save’ or ‘save_as’ if you would like to save before quitting.

Example:
>>> # Open Excel  
>>> excel = Excel()
>>> # Quit Excel
>>> excel.quit()
Keywords
excel, exit, quit, close
Icon
las la-file-excel
read_cell(column, row)

Read cell

Read a cell from the currently active workbook and active worksheet

Parameters:
  • column – Column number (integer) to read
  • row – Row number (integer) to read
Returns:

Cell value

Example:

>>> # Open Excel
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Insert a text into the first cell
>>> excel.write_cell(1,1, 'Hello World!')
>>> excel.read_cell(1,1)
'Hello World!'
Keywords
excel, cell, read cell, read data
Icon
las la-file-excel
read_cell_formula(column, row, formula)

Read cell formula

Read the formula from a particular cell

Parameters:
  • column – Column number (integer) to read formula
  • row – Row number (integer) to read formula
Returns:

Cell value

Example:

>>> # Open Excel
>>> excel = Excel()
>>> # Write a formula to the first cell
>>> excel.write_cell_formula(1, 1, '=1+1)
>>> # Read the cell
>>> excel.read_cell_formula(1, 1)
'=1+1'
Keywords
excel, read formula, read calculation
Icon
las la-file-excel
read_range(range_)

Read range

Read a range of cells from the currently active worksheet in the active workbook

Parameters:

range – Range to read from, e.g. “A1:D10”

Return value:

Values in param range

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Insert a text in every cell in this range
>>> excel.write_range('A1:D5', 'Hello World!')
>>> # Read the same range
>>> excel.read_range('A1:D5')
[['Hello World', 'Hello World', 'Hello World', 'Hello World'], ...]
Keywords
excel, cell, read range, read data
Icon
las la-file-excel
read_worksheet(name=None, headers=False)

Read worksheet

Read data from a worksheet as a list of lists

Parameters:
  • name – Optional name of worksheet to read. If no name is specified will take active sheet
  • headers – Boolean to treat first row as headers. Default value is False
Returns:

List of dictionaries with sheet data

Example:

>>> # Open excel    
>>> excel = Excel()
>>> Write some cells
>>> excel.write_cell(1, 1, 'A')
>>> excel.write_cell(1, 2, 'B')
>>> excel.write_cell(1, 3, 'C')
>>> excel.read_worksheet()
[['A'],['B'],['C']]
Keywords
excel, read worksheet, export data, read data
Icon
las la-file-excel
run_macro(name)

Run macro

Run a macro by name from the currently active workbook

Parameters:name

Name of the macro to run.

Example:
>>> excel = Excel('excel_with_macro.xlsx')
>>> # Run the macro
>>> excel.run_macro('Macro1')
Keywords
excel, run macro, run vba
Icon
las la-file-excel
save()

Save

Save the current workbook

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Save the workbook to My Documents
>>> excel.save()
Keywords
excel, save, store
Icon
las la-file-excel
save_as(path)

Save as

Save the current workbook to a specific path

Parameters:path

Path where workbook will be saved. Default is home directory and filename ‘workbook.xlsx’

Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Save the workbook to the current working directory
>>> excel.save_as('output.xlsx')
Keywords
excel, save as, export
Icon
las la-file-excel
write_cell(column, row, value)

Write cell

Write to a specific cell in the currently active workbook and active worksheet

Parameters:
  • column – Column number (integer) to write
  • row – Row number (integer) to write
  • value

    Value to write to specific cell

    Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Insert a text into the first cell
>>> excel.write_cell(1,1, 'Hello World!')
Keywords
excel, cell, insert cell, insert data
Icon
las la-file-excel
write_cell_formula(column, row, formula)

Write cell formula

Write a formula to a particular cell

Parameters:
  • column – Column number (integer) to write formula
  • row – Row number (integer) to write formula
  • value

    Formula to write to specific cell e.g. “=10*RAND()”

    Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Write a formula to the first cell
>>> excel.write_cell_formula(1, 1, '=1+1)
Keywords
excel, insert formula, insert calculation, insert calculated cell
Icon
las la-file-excel
write_range(range_, value)

Write range

Write to a specific range in the currently active worksheet in the active workbook

Parameters:
  • range – Range to write to, e.g. “A1:D10”
  • value

    Value to write to range

    Example:
>>> # Open Excel
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Insert a text in every cell in this range
>>> excel.write_range('A1:D5', 'Hello World!')
Keywords
excel, cell, write range, read data
Icon
las la-file-excel

Excel File

class automagica.activities.ExcelFile(file_path=None)
activate_worksheet(name)

Activate worksheet

Activate a worksheet. By default the first worksheet is activated.

Parameters:name

Name of the worksheet to activate.

Example:
>>> # Open a new Excel file
>>> excel_file = ExcelFile()
>>> # Add some worksheets
>>> excel_file.add_worksheet('My Example Worksheet')
>>> excel_file.add_worksheet('Another Worksheet')
>>> # Activate a worksheet
>>> excel_file.active_worksheet('My Example Worksheet')
Keywords
excel, activate tab, activate worksheet
Icon
las la-file-excel
add_worksheet(name, auto_save=True)

Add worksheet

Add a worksheet

Parameters:
  • name – Name of the worksheet to add
  • auto_save

    Save document after performing activity. Default value is True

    Example:
>>> # Open a new Excel file
>>> excel_file = ExcelFile()
>>> # Add a worksheet
>>> excel_file.add_worksheet('My Example Worksheet')
>>> # List all the worksheets
>>> excel.get_worksheet_names()
Keywords
excel, add worksheet, worksheet
Icon
las la-file-excel
get_worksheet_names()

Get worksheet names

Get worksheet names

Returns:List of worksheet names
Example:
>>> # Open a new Excel file
>>> excel_file = ExcelFile()
>>> # Add some worksheets
>>> excel_file.add_worksheet('My Example Worksheet')
>>> excel_file.add_worksheet('Another Worksheet')
>>> # Get the worksheet names
>>> excel_file.get_worksheet_names()
['My Example Worksheet', 'Another Worksheet']
Keywords
excel, worksheet names, worksheet,
Icon
las la-file-excel
read_cell(column, row)

Read cell

Read a cell based on column and row

Parameters:
  • column – Column number (integer) to read
  • row – Row number (integer) to read
Returns:

Cell value

Example:

>>> # Open a new Excel file
>>> excel_file = ExcelFile()
>>> # Add a worksheet
>>> excel_file.add_worksheet('My Example Worksheet')
>>> # Write the first cell
>>> excel_file.write_cell(1, 1, 'Filled!')
>>> # Read the first cell
>>> excel_file.read_cell(1, 1)
'Filled!'
Keywords
excel, read cell, read
Icon
las la-file-excel
save_as(path)

Save as

Save file as

Parameters:path

Path where workbook will be saved

Example:
>>> # Open a new Excel file
>>> excel_file = ExcelFile()
>>> # Ad a worksheet
>>> excel_file.add_worksheet('My Example Worksheet')
>>> # Save the Excel file
>>> excel_file.save_as('output.xlsx')
>>> # We can also save it in the home directory by using
>>> excel_file.save_as( home_path('output.xlsx') )
Keywords
excel, save as, export, save
Icon
las la-file-excel
to_dataframe()

Export file to dataframe

Export to pandas dataframe

Parameters:file_path

Enter a path to open Excel with an existing Excel file. If no path is specified a ‘workbook.xlsx’ will be initialized in the home directory, this is the default value. If a workbook with the same name already exists the file will be overwritten.

Example:
>>> # Open a new Excel file
>>> excel_file = ExcelFile()
>>> # Convert to Dataframe
>>> df = excel_file.to_dataframe()
Keywords
excel, open, start, xlsx, dataframe,
Icon
las la-file-excel
write_cell(column, row, value, auto_save=True)

Write cell

Write a cell based on column and row

Parameters:
  • column – Column number (integer) to write
  • row – Row number (integer) to write
  • value – Value to write to specific cell
  • auto_save

    Save document after performing activity. Default value is True

    Example:
>>> # Open a new Excel file
>>> excel_file = ExcelFile()
>>> # Add a worksheet
>>> excel_file.add_worksheet('My Example Worksheet')
>>> excel_file.write_cell(1, 1, 'Filled!')
Keywords
excel, write cell, insert data
Icon
las la-file-excel

PowerPoint Application

class automagica.activities.PowerPoint(visible=True, path=None, add_slide=True)
add_slide(index=None, type='blank')

Add PowerPoint Slides

Adds slides to a presentation

Parameters:

index – Index where the slide should be inserted. Default value is as final slide.

Parmeter type:

Type of the slide to be added. Supports following types: blank, chart, text, title and picture.

Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add a first slide
>>> powerpoint.add_slide()
Keywords
powerpoint, ppt, add, add slide powerpoint, slides
Icon
las la-file-powerpoint
add_text(text, index=None, font_size=48, font_name=None, bold=False, margin_bottom=100, margin_left=100, margin_right=100, margin_top=100)

Text to slide

Add text to a slide

Parameters:
  • index – Slide index to add text. If none is specified, a new slide will be added as final slide
  • font_size – Fontsize, default value is 48
  • font_name – Fontname, if not specified will take default PowerPoint font
  • bold – Toggle bold with True or False, default value is False
  • margin_bottom – Margin from the bottom in pixels, default value is 100 pixels
  • margin_left – Margin from the left in pixels, default value is 100 pixels
  • margin_right – Margin from the right in pixels, default value is 100 pixels
  • margin_top

    Margin from the top in pixels, default value is 100 pixels

    Example:
Parmeter text:

Text to be added

>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add slide with text
>>> powerpoint.add_text(text='Sample Text')
Keywords
powerpoint, ppt, text, add text, slides
Icon
las la-file-powerpoint
delete_slide(index=None)

Delete slide

Delete a slide

Parameters:index

Slide index to be deleted. If none is specified, last slide will be deleted

Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add some slides
>>> powerpoint.add_slide()
>>> powerpoint.add_slide()
>>> # Delete last slide
>>> powerpoint.delete_slide()
Keywords
powerpoint, ppt, delete, delete slide
Icon
las la-file-powerpoint
export_slides_to_images(path=None, type='png')

Slides to images

Export PowerPoint slides to seperate image files

Parameters:
  • path – Output path where image files will be exported to. Default path is home directory.
  • type

    Output type of the images, supports ‘png’ and ‘jpg’ with ‘png’ as default value

    Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add some slides with text
>>> powerpoint.add_text(text='Robots are cool')
>>> powerpoint.add_text(text='Humans are cooler')
>>> # Export slides to images
>>> powerpoint.export_slides_to_images()
Keywords
powerpoint, ppt, export, png, image, slides to image
Icon
las la-file-powerpoint
export_to_pdf(path=None)

PowerPoint to PDF

Export PowerPoint presentation to PDF file

Parameters:path

Output path where PDF file will be exported to. Default path is home directory with filename ‘pdf_export.pdf’.

Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add some slides with text
>>> powerpoint.add_text(text='Robots are cool')
>>> # Export to pdf
>>> powerpoint.export_to_pdf()
Keywords
powerpoint, ppt, export, pdf
Icon
las la-file-powerpoint
number_of_slides()

Slide count

Returns the number of slides

Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add some slides
>>> powerpoint.add_slide()
>>> powerpoint.add_slide()
>>> # Show number of slides
>>> powerpoint.number_of_slides()
Keywords
powerpoint, ppt, slide count, number of slides
Icon
las la-file-powerpoint
quit()

Close PowerPoint Application

Close PowerPoint

Parameters:

index – Index where the slide should be inserted. Default value is as final slide.

Parmeter type:

Type of the slide to be added. Supports following types: blank, chart, text, title and picture.

Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Close PowerPoint
>>> powerpoint.quit()
Keywords
powerpoint, ppt, quit, exit
Icon
las la-file-powerpoint
replace_text(placeholder_text, replacement_text)

Replace all occurences of text in PowerPoint slides

Can be used for example to replace arbitrary placeholder value in a PowerPoint. For example when using a template slidedeck, using ‘XXXX’ as a placeholder. Take note that all strings are case sensitive.

Parameters:
  • placeholder_text – Placeholder value (string) in the PowerPoint, this will be replaced, e.g. ‘Company Name’
  • replacement_text

    Text (string) to replace the placeholder values with. It is recommended to make this unique in your PowerPoint to avoid wrongful replacement, e.g. ‘XXXX_placeholder_XXX’

    Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add some slides with text
>>> powerpoint.add_text(text='Hello, my name is placeholder')
>>> # Change 'placeholder' to the word 'robot
>>> powerpoint.replace_text(placeholder_text = 'placeholder', replacement_text ='robot')
Keywords
powerpoint, ppt, replace, placeholder
Icon
las la-file-powerpoint
save_as(path=None)

Save PowerPoint

Save PowerPoint Slidedeck

Parameters:path

Save the PowerPoint presentation. Default value is the home directory and filename ‘presentation.pptx’

Example:
>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add a first slide
>>> powerpoint.add_slide()
>>> # Save the PowerPoint presentation
>>> powerpoint.save()
Keywords
powerpoint, ppt, save, save as, save powerpoint
Icon
las la-file-powerpoint

Office 365

automagica.activities.send_email_with_outlook365(client_id, client_secret, to_email, subject='', body='')

Send email Office Outlook 365

Send email Office Outlook 365

Parameters:
  • client_id – Client id for office 365 account
  • client_secret – Client secret for office 365 account
  • to_email – E-mail to send to
  • subject – Optional subject
  • body

    Optional body of the email

    Example:
>>> # Send email to 'robot@automagica.com'
>>> send_email_with_outlook365('SampleClientID', 'SampleClientSecret', 'robot@automagica.com')
Keywords
mail, office 365, outlook, email, e-mail
Icon
las la-envelope

Salesforce

automagica.activities.salesforce_api_call(action, key, parameters={}, method='get', data={})

Salesforce API

Activity to make calls to Salesforce REST API.

Parameters:
  • action – Action (the URL)
  • key – Authorisation key
  • parameters – URL params
  • method – Method (get, post or patch)
  • data – Data for POST/PATCH.
Returns:

API data

Example:

>>> spf_api_call('action', 'key', 'parameters')
Response
Keywords
salesforce
Icon
lab la-salesforce

E-mail (SMTP)

automagica.activities.send_mail_smtp(smtp_host, smtp_user, smtp_password, to_address, subject='', message='', port=587)

Mail with SMTP

This function lets you send emails with an e-mail address.

Parameters:
  • smpt_host – The host of your e-mail account.
  • smpt_user – The password of your e-mail account
  • smpt_password – The password of your e-mail account
  • to_address – The destination is the receiving mail address.
  • subject – The subject
  • message – The body of the mail
  • port

    The port variable is standard 587. In most cases this argument can be ignored, but in some cases it needs to be changed to 465.

    Example:
>>> send_mail_smpt('robot@automagica.com', 'SampleUser', 'SamplePassword', 'robotfriend@automagica.com')
Keywords
mail, e-mail, email smpt
Icon
las la-mail-bulk

Windows OS

automagica.activities.find_window_title(searchterm, partial=True)

Find window with specific title

Find a specific window based on the name, either a perfect match or a partial match.

Parameters:
  • searchterm – Ttile to look for, e.g. ‘Calculator’ when looking for the Windows calculator
  • partial

    Option to look for titles partially, e.g. ‘Edge’ will result in finding ‘Microsoft Edge’ when partial is set to True. Default value is True

    Example:
>>> # Make textfile
>>> testfile = make_textfile()
>>> # Open the file
>>> open_file(testfile)
>>> #Find 'Notepad' in window titles
>>> find_window_title('Notepad')
'generated_textfile.txt - Notepad'
Keywords
windows, user, password, remote desktop, remote, citrix, vnc, remotedesktop
Icon
lab la-readme
automagica.activities.start_remote_desktop(ip, username, password=None, desktop_width=1920, desktop_height=1080)

Login to Windows Remote Desktop

Create a RDP and login to Windows Remote Desktop

Parameters:
  • ip – IP address of remote desktop
  • username – Username
  • password – Password
  • desktop_width – Resolution (width) of desktop, standard value is 1920 (full HD)
  • desktop_height

    Resolution (height) of desktop, standard value is 1080 (full HD)

    Example:
>>> start_remote_desktop('123.456.789.10','Administrator', 'SamplePassword')
Keywords
windows, user, password, remote desktop, remote, citrix, vnc, remotedesktop
Icon
las la-passport
automagica.activities.close_remote_desktop()

Stop Windows Remote Desktop

Stop Windows Remote Desktop

Example:
>>> close_remote_desktop()
Keywords
windows, user, password, remote desktop, remote, citrix, vnc, remotedesktop, stop
Icon
las la-passport
automagica.activities.set_user_password(username, password)

Set Windows password

Sets the password for a Windows user.

Parameters:
  • username – Username
  • password

    New password

    Example:
>>> set_user_password('SampleUsername', 'SamplePassword')
Keywords
windows, user, password, account
Icon
las la-passport
automagica.activities.validate_user_password(username, password)

Check Windows password

Validates a Windows user password if it is correct

Parameters:
  • username – Username
  • password – New password
Returns:

True if the password is correct

Example:

>>> validate_user_password('SampleUsername', 'SamplePassword')
False
Keywords
windows, user, password, account
Icon
las la-passport
automagica.activities.lock_windows()

Lock Windows

Locks Windows requiring login to continue.

Example:
>>> lock_windows()
Keywords
windows, user, password, account, lock, freeze, hibernate, sleep, lockescreen
Icon
las la-user-lock
automagica.activities.is_logged_in()

Check if Windows logged in

Checks if the current user is logged in and not on the lockscreen. Most automations do not work properly when the desktop is locked.

Returns:True if the user is logged in, False if not
Example:
>>> is_logged_in()
True
Keywords
windows, login, logged in, lockscreen, user, password, account, lock, freeze, hibernate, sleep
Icon
lar la-user
automagica.activities.is_desktop_locked()

Check if Windows is locked

Checks if the current user is locked out and on the lockscreen. Most automations do not work properly when the desktop is locked.

Returns:True when the lockscreen is active, False if not.
Example:
>>> desktop_locked()
True
Keywords
windows, login, logged in, lockscreen, user, password, account, lock, locked, freeze, hibernate, sleep
Icon
las la-user
automagica.activities.get_username()

Get Windows username

Get current logged in user’s username

Example:
>>> get_username()
'Automagica'
Keywords
windows, login, logged in, lockscreen, user, password, account, lock, locked, freeze, hibernate, sleep
Icon
las la-user
automagica.activities.set_to_clipboard(text)

Set clipboard

Set any text to the Windows clipboard.

Parameters:text

Text to put in the clipboard

Example:
>>> # Create some sample text
>>> sample_text = 'A robots favourite food must be computer chips'
>>> # Set to clipboard
>>> set_to_clipboard(sample_text)
>>> # Print the clipboard to verify
>>> print( get_from_clipboard() )
Keywords
copy, clipboard, clip board, ctrl c, ctrl v, paste
Icon
las la-clipboard-check
automagica.activities.get_from_clipboard()

Get clipboard

Get the text currently in the Windows clipboard

Returns:Text currently in the clipboard
Example:
>>> # Create some sample text
>>> sample_text = 'A robots favourite food must be computer chips'
>>> # Set to clipboard
>>> set_to_clipboard(sample_text)
>>> # Get the clipboard to verify
>>> get_from_clipboard()
'A robots favourite food must be computer chips'
Keywords
copy, clipboard, clip board, ctrl c, ctrl v, paste
Icon
las la-clipboard-list
automagica.activities.clear_clipboard()

Empty clipboard

Empty text from clipboard. Getting clipboard data after this should return in None

Example:
>>> # Create some sample text
>>> sample_text = 'A robots favourite food must be computer chips'
>>> # Set to clipboard
>>> set_to_clipboard(sample_text)
>>> # Clear the clipboard
>>> clear_clipboard()
>>> # Get clipboard contents to verify
>>> print( get_clipboard() )
None
Keywords
copy, clipboard, clip board, ctrl c, ctrl v, paste
Icon
las la-clipboard
automagica.activities.run_vbs_script(script_path, parameters=[])

Run VBSscript

Run a VBScript file

Parameters:
  • script_path – Path to the .vbs-file
  • parameters

    Additional arguments to pass to the VBScript

    Example:
>>> # Run a VBS script
>>> run_vbs_script('Samplescript.vbs')
Keywords
vbs, VBScript
Icon
las la-cogs
automagica.activities.beep(frequency=1000, duration=500)

Beep

Make a beeping sound. Make sure your volume is up and you have hardware connected.

Parameters:
  • frequency – Integer to specify frequency (Hz), default value is 1000 Hz
  • duration – Integer to specify duration of beep in miliseconds (ms), default value is 500 ms.
Returns:

Sound

Example:

>>> beep()
Keywords
beep, sound, noise, speaker, alert
Icon
las la-volume-up
automagica.activities.get_all_network_interface_names()

Get all network interface names

Returns a list of all network interfaces of the current machine

Example:
>>> get_all_network_interface_names()
['Microsoft Kernel Debug Network Adapter', 'Realtek Gaming GbE Family Controller', 'WAN Miniport (SSTP)']
Keywords
networking, connection, list
Icon
las la-ethernet
automagica.activities.enable_network_interface(name)

Enable network interface

Enables a network interface by its name.

Parameters:name

Name of the network

Example:
>>> enable_network_interface('Realtek Gaming GbE Family Controller')
Keywords
networking, connection, enable
Icon
las la-ethernet
automagica.activities.disable_network_interface(name)

Disable network interface

Disables a network interface by its name.

Parameters:name

Name of the network interface

Example:
>>> disable_network_interface('Realtek Gaming GbE Family Controller')
Keywords
networking, connection, disable
Icon
las la-ethernet
automagica.activities.get_default_printer_name()

Get default printer

Returns the name of the printer selected as default

Example:
>>> get_default_printer_name()
'Epson MF742C/744C'
Keywords
printing, get default printer name, default printer
Icon
las la-print
automagica.activities.set_default_printer(name)

Set default printer

Set the default printer.

Parameters:name

Printer name

Example:
>>> set_default_printer('Epson MF742C/744C')
Keywords
printing, set default printer name, default printer
Icon
las la-print
automagica.activities.remove_printer(name)

Remove printer

Removes a printer by its name

Parameters:name

Printer name to remove

Example:
>>> remove_printer('Epson MF742C/744C')
Keywords
printing, remove printer, printer
Icon
las la-print
automagica.activities.get_service_status(name)

Get service status

Returns the status of a service on the machine

Parameters:name

Name of service

Example:
>>> get_service_status('Windows Backup')
'stopped'
Keywords
services, get service status, status
Icon
las la-cog
automagica.activities.start_service(name)

Start a service

Starts a Windows service

Parameters:name

Name of service

Example:
>>> start_service('Windows Backup')
Keywords
services, start a service, start
Icon
las la-cog
automagica.activities.stop_service(name)

Stop a service

Stops a Windows service

Parameters:name

Name of service

Example:
>>> stop_service('Windows Backup')
Keywords
services, stop a service, stop
Icon
las la-cog
automagica.activities.set_window_to_foreground(title)

Set window to foreground

Sets a window to foreground by its title.

Parameters:name

Name of service

Example:
>>> set_window_to_foreground('Notepad - Untitled')
Keywords
window, foreground
Icon
las la-window-restore
automagica.activities.get_foreground_window_title()

Get foreground window title

Retrieve the title of the current foreground window

Example:
>>> get_foreground_window_title()
'IPython'
Keywords
window, foreground, title
Icon
las la-window-restore
automagica.activities.close_window(title)

Close window

Closes a window by its title

Parameters:title

Title of window

Example:
>>> close_window('Untitled - Notepad')
Keywords
window, close, title
Icon
las la-window-restore
automagica.activities.maximize_window(title)

Maximize window

Maximizes a window by its title

Parameters:title

Title of window

Example:
>>> maximize_window('Untitled - Notepad')
Keywords
window, maximize, title
Icon
las la-window-restore
automagica.activities.restore_window(title)

Restore window

Restore a window by its title

Parameters:title

Title of window

Example:
>>> restore_window('Untitled - Notepad')
Keywords
window, restore, title
Icon
las la-window-restore
automagica.activities.minimize_window(title)

Minimize window

Minimizes a window by its title

Parameters:title

Title of window

Example:
>>> minimize_window(title)
Keywords
window, minimize, title
Icon
las la-window-restore
automagica.activities.resize_window(title, x, y, width, height)

Resize window

Resize a window by its title

Parameters:title

Title of window

Example:
>>> resize_window('Untitled - Notepad', 100, 200, 300, 400)
Keywords
window, resize, title
Icon
las la-window-restore
automagica.activities.hide_window(title)

Hide window

Hides a window from the user desktop by using it’s title

Parameters:title

Title of window

Example:
>>> hide_window('Untitled - Notepad')
Keywords
window, hide, title
Icon
las la-window-restore

Terminal

automagica.activities.run_ssh_command(user, host, command)

Run SSH command

Runs a command over SSH (Secure Shell)

Parameters:
  • user – User
  • host – Host
  • command

    Command

    Example:
>>> run_ssh_command('root', 'machine', 'ls -a')
'. .. .bashrc'
Keywords
ssh, command
Icon
las la-terminal

SNMP

automagica.activities.snmp_get(target, oids, credentials, port=161, engine=None, context=None)

SNMP Get

Retrieves data from an SNMP agent using SNMP (Simple Network Management Protocol)

Parameters:
  • target – Target
  • oids – oids
  • credentials – credentials
  • port – Port (default 161)
  • engine – Engine (default none)
  • context

    Contect (default none)

    Example:
>>> snmp_get()
Keywords
snmp, simple network management protocol, protocols, get
Icon
las la-ethernet

Active Directory

class automagica.activities.ActiveDirectory(ldap_server=None, username=None, password=None)
get_object_by_distinguished_name(distinguished_name)

Get AD object by name

Interface to Windows Active Directory through ADSI

Activity to connect the ADSI interface to Microsoft Active Directory. Connects to the AD domain to which the machine is joined by default.

Example:
>>> ad = ActiveDirectory()
>>> ad.get_object_by_distinguished_name('SampleDN')
Keywords
AD, active directory, activedirectory
Icon
las la-audio-description

Utilities

automagica.activities.home_path(subdir=None)

Get user home path

Returns the current user’s home path

Parameters:filename – Optional filename to add to the path. Can also be a subdirectory
Returns:Path to the current user’s home folder
Example:
>>> # Home_path without arguments will return the home path
>>> print( home_path() )
>>> # When looking for a file in the home path, we can specify it
>>> # First make a sample textfile
>>> make_textfile()
>>> # Refer to it
>>> home_path('generated_textfile.txt')
'C:\Users\<username>\generated_textfile.txt'
Keywords
home, home path, homepath, home directory, homedir
Icon
las la-home
automagica.activities.desktop_path(subdir=None)

Get desktop path

Returns the current user’s desktop path

Parameters:filename – Optional filename to add to the path. Can also be a subdirectory
Returns:Path to the current user’s desktop folder
Example:
>>> # Desktop_path without arguments will return the home path
>>> print( desktop_path() )
>>> # When looking for a file on the desktop, we can specify it
>>> # First make a sample textfile
>>> make_textfile()
>>> # Refer to it
>>> desktop_path('generated_textfile.txt')
'C:\Users\<username>\Desktop\generated_textfile.txt'
Keywords
desktop, desktop path, desktoppath, desktop directory, desktopdir
Icon
lar la-desktop
automagica.activities.downloads_path()

Get downloads path

Returns the current user’s default download path

Returns:Path to the current user’s downloads folder
Example:
>>> # Find downloads path
>>> print( downloads_path() )
Keywords
download, download path, downloadpath, download directory, download dir, downloaddir
Icon
lar la-download
automagica.activities.open_file(path)

Open file

Opens file with default programs

Parameters:path – Path to file.
Returns:Path to file
Example:
>>> # Make textfile
>>> testfile = make_textfile()
>>> # Open the file
>>> open_file(testfile)
Keywords
file, open, open file, show, reveal, explorer, run, start
Icon
lar la-file
automagica.activities.set_wallpaper(image_path)

Set wallpaper

Set Windows desktop wallpaper with the the specified image

Parameters:image_path

Path to the image. This image will be set as desktop wallpaper

Example:
>>> # Caution: this example will change your wallpaper
>>> # Take a screenshot of current screen
>>> screenshot = take_screenshot()
>>> # Flip it hozirontally for fun
>>> mirror_image_horizontally(screenshot)
>>> # Set flipped image as wallpaper
>>> set_wallpaper(screenshot)
Keywords
desktop, desktop path, desktoppath, desktop directory, desktopdir, wallpaper, wall paper, wall
Icon
las la-desktop
automagica.activities.download_file_from_url(url, filename=None, path=None)

Download file from a URL

Download file from a URL

Parameters:
  • url – Source URL to download file from
  • path – Target path. If no path is given will download to the home directory
Returns:

Target path as string

Example:

>>> # Download robot picture from the wikipedia robot page
>>> picture_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Atlas_from_boston_dynamics.jpg/220px-Atlas_from_boston_dynamics.jpg'
>>> download_file_from_url(url = picture_url, path='robot.jpg')
'C:\Users\<username>\robot.jpg'
Keywords
download, download url, save, request
Icon
las la-cloud-download-alt

Trello

automagica.activities.add_trello_card(title='My card', description='My description', board_name='My board', list_name='My list', api_key='', api_secret='', token='', token_secret='any')

Add Trello Card

Add a card to the Trello board. For this you need a Trello API key, secret and token.

Parameters:
  • title – Title of Trello card
  • description – Description of Trello card
  • board_name – Name of the Trello board
  • api_key – Trello API key
  • api_secret – Trello API secret
  • token – Trello token
  • token_secret

    Token secret can be any string, but should be altered for security purposes.

    Example:
>>> add_trello_card(title='ExampleTitle', description='ExampleDescription', api_key='SampleKey', api_secret='ApiSecret', token='SampleToken')
Keywords
trello
Icon
lab la-trello

System

automagica.activities.rename_file(input_path, new_name=None)

Rename a file

This activity will rename a file. If the the desired name already exists in the folder file will not be renamed.

Parameters:
  • path – Full path to file that will be renamed
  • new_name – New name of the file e.g. ‘newfile.txt’. By default file will be renamed to original folder name with ‘_renamed’ added to the folder name.
Returns:

Path to renamed file as a string. None if folder could not be renamed.

Example:

>>> # Make new textfile in home directory
>>> textfile = make_textfile()
>>> # Rename the file
>>> rename_file(textfile)
C:\Users\<username>\generated_textfile_renamed.txt'
Keywords
file, rename, rename file, organise file, files, file manipulation, explorer, nautilus
Icon
las la-file-contract
automagica.activities.move_file(from_path, to_path)

Move a file

If the new location already contains a file with the same name, a random 4 character uid will be added in front of the name before the file is moved.

Parameters:
  • old_path – Full path to the file that will be moved
  • new_location – Path to the folder where file will be moved to
Returns:

Path to renamed file as a string. None if folder could not be moved.

Example:

>>> # Make new textfile in home directory
>>> textfile = make_textfile()
>>> # Make a folder to move the file to
>>> new_folder = create_folder()
>>> # Move textfile to the folder
>>> move_file(textfile, new_folder)
Keywords
file, move, move file, organise file, files, file manipulation, explorer, nautilus
Icon
las la-file-export
automagica.activities.remove_file(path)

Remove a file

Remove a file

Parameters:path – Full path to the file that will be deleted.
Returns:Path to removed file as a string.
Example:
>>> # Make new textfile in home directory
>>> textfile = make_textfile()
>>> # Remove the file
>>> remove_file(textfile)
Keywords
file, delete, erase, delete file, organise file, files, file manipulation, explorer, nautilus
Icon
las la-trash
automagica.activities.file_exists(path)

Check if file exists

This function checks whether the file with the given path exists.

Parameters:path – Full path to the file to check.

return: True or False (boolean)

Example:
>>> # Make new textfile in home directory
>>> textfile = make_textfile()
>>> # Check if file exists
>>> file_exists(textfile)
True
Keywords
file, exists, files, file manipulation, explorer, nautilus
Icon
las la-tasks
automagica.activities.wait_file_exists(path, timeout=60)

Wait until a file exists.

Not that this activity is blocking and will keep the system waiting.

Parameters:
  • path – Full path to file.
  • timeout

    Maximum time in seconds to wait before continuing. Default value is 60 seconds.

    Example:
>>> # Make new textfile in home directory
>>> textfile = make_textfile()
>>> # Wait untile file exists # Should pass immediatly
>>> wait_file_exists(textfile)
Keywords
file, wait, wait till exists, files, file manipulation, explorer, nautilus
Icon
las la-list-alt
automagica.activities.write_list_to_file(list_to_write, file_path)

List to .txt

Writes a list to a text (.txt) file. Every element of the entered list is written on a new line of the text file.

Parameters:
  • list_to_write – List to write to .txt file
  • path

    Path to the text-file.

    Example:
>>> # Make a list to write
>>> robot_names = ['WALL-E', 'Terminator', 'R2D2']
>>> # Create a new text file
>>> textfile = make_textfile()
>>> write_list_to_file(robot_names, textfile)
>>> # Open the file for illustration
>>> open_file(textfile)
Keywords
list, text, txt, list to file, write list, write
Icon
las la-list
automagica.activities.read_list_from_txt(file_path)

Read .txt file

This activity writes the content of a .txt file to a list and returns that list. Every new line from the .txt file becomes a new element of the list. The activity will not work if the entered path is not attached to a .txt file.

Parameters:path – Path to the .txt file
Returns:List with contents of specified .txt file
Example:
>>> # Make a list to write
>>> robot_names = ['WALL-E', 'Terminator', 'R2D2']
>>> # Create a new text file
>>> textfile = make_textfile()
>>> write_list_to_file(robot_names, textfile)
>>> # Read list from file
>>> read_list_from_txt(textfile)
['WALL-E', 'Terminator', 'R2D2']
Keywords
list, text, txt, list to file, write list, read, read txt, read text
Icon
las la-th-list
automagica.activities.append_line(text, file_path)

Append to .txt

Append a text line to a file and creates the file if it does not exist yet.

Parameters:
  • text – The text line to write to the end of the file
  • file_path

    Path to the file to write to

    Example:
>>> # Create a new text file
>>> textfile = make_textfile()
>>> # Append a few lines to the file
>>> append_line('Line 1', textfile)
>>> append_line('Line 2', textfile)
>>> append_line('Line 3', textfile)
>>> # Open the file for illustration
>>> open_file(textfile)
Keywords
list, text, txt, list to file, write list, read, write txt, append text, append line, append, add to file, add
Icon
las la-tasks
automagica.activities.make_textfile(text='Sample text', output_path=None)

Make text file

Initialize text file

Parameters:
  • text – The text line to write to the end of the file. Default text is ‘Sample text’
  • output_path – Ouput path. Will write to home directory
Returns:

Path as string

Example:

>>> # Create a new text file
>>> textfile = make_textfile()
C:\Users\<username>\generated_textfile.txt'
Keywords
make textfile, textfile, testfile, exampel file, make file, make, new file, new textfile, txt, new txt
Icon
las la-file-alt
automagica.activities.copy_file(old_path, new_path=None)

Copy a file

Copies a file from one place to another. If the new location already contains a file with the same name, a random 4 character uid is added to the name.

Parameters:
  • old_path – Full path to the source location of the folder
  • new_path – Optional full path to the destination location of the folder. If not specified file will be copied to the same location with a random 8 character uid is added to the name.
Returns:

New path as string

Example:

>>> # Create a new text file
>>> textfile = make_textfile()
>>> # Copy the textfile
>>> copy_file(textfile)
C:\Users\<username>\generated_textfile.txt'
Keywords
make textfile, textfile, testfile, exampel file, make file, make, new file, new textfile, txt, new txt
Icon
las la-copy
automagica.activities.get_file_extension(path)

Get file extension

Get extension of a file

Parameters:path – Path to file to get extension from
Returns:String with extension, e.g. ‘.txt’
Example:
>>> # Create a new text file
>>> textfile = make_textfile()
>>> # Get file extension of this textfile
>>> get_file_extension(textfile)
'.txt'
Keywords
file, extension, file extension, details
Icon
las la-info
automagica.activities.send_to_printer(file)

Print

Send file to default printer to priner. This activity sends a file to the printer. Make sure to have a default printer set up.

Parameters:file

Path to the file to print, should be a printable file

Example:
>>> # Caution as this example could result in a print from default printer
>>> # Create a new text file
>>> textfile = make_textfile(text = 'What does a robot do at lunch? Take a megabyte!')
>>> # Print the textfile
>>> send_to_printer(textfile)
Keywords
print, printer, printing, ink, export
Icon
las la-print

PDF

automagica.activities.read_text_from_pdf(file_path)

Text from PDF

Extracts the text from a PDF. This activity reads text from a pdf file. Can only read PDF files that contain a text layer.

Parameters:file_path – Path to the PDF (either relative or absolute)
Returns:The text from the PDF
Example:
>>> # Caution, for this example to work a .pdf example file will be downloaded from automagica.com FTP
>>> example_pdf = download_file_from_url('http://automagica.com/examples/example_document.pdf')
>>> # Open example pdf for illustration
>>> open_file(example_pdf)
>>> # Read the text
>>> read_text_from_pdf(example_pdf)
Keywords
PDF, read, text, extract text, PDF file
Icon
las la-glasses
automagica.activities.join_pdf_files(file_paths, output_path=None)

Merge PDF

Merges multiple PDFs into a single file

Parameters:
  • file_paths – List of paths to PDF files
  • output_path – Full path where joined pdf files can be written. If no path is given will write to home dir as ‘merged_pdf.pdf’
Returns:

Output path as string

Example:

>>> # Caution, for this example to work a .pdf example file will be downloaded from automagica.com FTP
>>> example_pdf = download_file_from_url('http://automagica.com/examples/example_document.pdf')
>>> # Join the PDF file three times with itself for illustration, could also be different files
>>> merged_pdf = join_pdf_files([example_pdf, example_pdf, example_pdf])
>>> # Open resulting PDF file for illustration
>>> open_file(merged_pdf)
Keywords
PDF, read, text, extract text, PDF file, join PDF, join, merge, merge PDF
Icon
las la-object-ungroup
automagica.activities.extract_page_range_from_pdf(file_path, start_page, end_page, output_path=None)

Extract page from PDF

Extracts a particular range of a PDF to a separate file.

Parameters:
  • file_path – Path to the PDF (either relative or absolute)
  • start_page – Page number to start from, with 0 being the first page
  • end_page – Page number to end with, with 0 being the first page
  • output_path

    Output path, if no path is provided same path as input will be used with ‘extracted’ added to the name

    Example:
>>> # Caution, for this example to work a .pdf example file will be downloaded from automagica.com FTP
>>> example_pdf = download_file_from_url('http://automagica.com/examples/example_document.pdf')
>>> # Join the PDF file three times to create multi page
>>> multi_page_pdf_example = join_pdf_files([example_pdf, example_pdf, example_pdf])
>>> # Extract some pages from it
>>> new_file = extract_page_range_from_pdf(multi_page_pdf_example, 1, 2 )
>>> # Open resulting PDF file for illustration
>>> open_file(new_file)
Keywords
PDF, read, extract text, PDF file, extract PDF, join, cut, cut PDF, extract pages, extract from pdf, select page, page
Icon
las la-cut
automagica.activities.extract_images_from_pdf(file_path)

Extract images from PDF

Save a specific page from a PDF as an image

Parameters:file_path

Full path to store extracted images

Example:
>>> # Caution, for this example to work a .pdf example file will be downloaded from automagica.com FTP
>>> example_pdf = download_file_from_url('http://automagica.com/examples/example_document.pdf')
>>> # Extract the images
>>> extract_images_from_pdf(example_pdf)
Keywords
PDF, extract images, images, extract text, PDF file, image
Icon
las la-icons
automagica.activities.apply_watermark_to_pdf(file_path, watermark_path, output_path='')

Watermark a PDF

Watermark a PDF

Parameters:
  • file_path – Filepath to the document that will be watermarked. Should be pdf file.
  • watermark_path – Filepath to the watermark. Should be pdf file.
  • output_path – Path to save watermarked PDF. If no path is provided same path as input will be used with ‘watermarked’ added to the name
Returns:

Output path as a string :Example:

>>> # Caution, for this example to work a .pdf example file will be downloaded from automagica.com FTP
>>> example_pdf = download_file_from_url('http://automagica.com/examples/example_document.pdf')
>>> # Download the watermark
>>> example_watermark = download_file_from_url('http://automagica.com/examples/approved_stamp.pdf')
>>> # Apply the watermark
>>> watermarked_file = apply_watermark_to_pdf(example_pdf, example_watermark)
>>> # Open the file for illustration
>>> open_file(watermarked_file)
Keywords
PDF, extract images, images, extract text, PDF file, image
Icon
las la-stamp

System Monitoring

automagica.activities.get_cpu_load(measure_time=1)

CPU load

Get average CPU load for all cores.

Parameters:measure_time – Time (seconds) to measure load. Standard measure_time is 1 second.
Returns:Displayed load is an average over measured_time.
Example:
>>> get_cpu_load()
10.1
Keywords
cpu, load, cpuload
Icon
las la-microchip
automagica.activities.get_number_of_cpu(logical=True)

Count CPU

Get the number of CPU’s in the current system.

Parameters:logical – Determines if only logical units are added to the count, default value is True.
Returns:Number of CPU Integer
Example:
>>> get_number_of_cpu()
2
Keywords
cpu, count, number of cpu
Icon
las la-calculator
automagica.activities.get_cpu_frequency()

CPU frequency

Get frequency at which CPU currently operates.

Returns:minimum and maximum frequency
Example:
>>> get_cpu_frequency()
scpufreq(current=3600.0, min=0.0, max=3600.0)
Keywords
cpu, load, cpu frequency
Icon
las la-wave-square
automagica.activities.get_cpu_stats()

CPU Stats

Get CPU statistics

Returns:Number of CTX switches, intterupts, soft-interrupts and systemcalls.
Example:
>>> get_cpu_stats()
scpustats(ctx_switches=735743826, interrupts=1540483897, soft_interrupts=0, syscalls=2060595131)
Keywords
cpu, load, cpu frequency, stats, cpu statistics
Icon
las la-server
automagica.activities.get_memory_stats(mem_type='swap')

Memory statistics

Get memory statistics

Parameters:mem_type – Choose mem_type = ‘virtual’ for virtual memory, and mem_type = ‘swap’ for swap memory (standard).
Returns:Total, used, free and percentage in use.
Example:
>>> get_memory_stats()
sswap(total=24640016384, used=18120818688, free=6519197696, percent=73.5, sin=0, sout=0)
Keywords
memory, statistics, usage, ram
Icon
las la-memory
automagica.activities.get_disk_stats()

Disk stats

Get disk statistics of main disk

Returns:Total, used, free and percentage in use.
Example:
>>> get_disk_stats()
sdiskusage(total=999559262208, used=748696350720, free=250862911488, percent=74.9)
Keywords
disk usage, disk stats, disk, harddisk, space
Icon
las la-save
automagica.activities.get_disk_partitions()

Partition info

Get disk partition info

Returns:tuple with info for every partition.
Example:
>>> get_disk_paritions()
[sdiskpart(device='C:\', mountpoint='C:\', fstype='NTFS', opts='rw,fixed')]
Keywords
disk usage, disk stats, disk, harddisk, space
Icon
las la-save
automagica.activities.get_boot_time()

Boot time

Get most recent boot time

Returns:time PC was booted in seconds after the epoch.
Example:
>>> get_boot_time()
123456789.0
Keywords
boot, boot time, boottime, startup, timer
Icon
lar la-clock
automagica.activities.get_time_since_last_boot()

Uptime

Get uptime since last boot

Returns:time since last boot in seconds.
Example:
>>> get_time_since_last_boot()
1337.0
Keywords
boot, boot time, boottime, startup, timer
Icon
lar la-clock

Image Processing

automagica.activities.show_image(path)

Show image

Displays an image specified by the path variable on the default imaging program.

Parameters:path

Full path to image

Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # Show the image
>>> show_image(testimage)
Keywords
image, show image, reveal, open image, open
Icon
las la-images
automagica.activities.rotate_image(path, angle=90)

Rotate image

Rotate an image

Parameters:angle

Degrees to rotate image. Note that angles other than 90, 180, 270, 360 can resize the picture.

Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # Rotate the image
>>> rotate_image(testimage)
>>> # Show the image
>>> show_image(testimage)
Keywords
image, rotate image, 90 degrees, image manipulation, photoshop, paint
Icon
las la-undo
automagica.activities.resize_image(path, size)

Resize image

Resizes the image specified by the path variable.

Parameters:
  • path – Path to the image
  • size

    Tuple with the width and height in pixels. E.g. (300, 400) gives the image a width of 300 pixels and a height of 400 pixels.

    Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # Resize the image
>>> resize_image(testimage, size=(100,100))
>>> # Show the image
>>> show_image(testimage)
Keywords
image, resize image, resize, size, image manipulation, photoshop, paint
Icon
las la-expand-arrows-alt
automagica.activities.get_image_width(path)

Get image width

Get with of image

Parameters:path

Path to image

Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # get image height
>>> get_image_width(testimage)
1000
Keywords
image, height, width, image height, image width
Icon
las la-expand-arrows-alt
automagica.activities.get_image_height(path)

Get image height

Get height of image

Parameters:path – Path to image
Returns:Height of image
Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # get image height
>>> get_image_height(testimage)
1000
Keywords
image, height, width, image height, image width
Icon
las la-arrows-alt-v
automagica.activities.crop_image(path, box=None)

Crop image

Crops the image specified by path to a region determined by the box variable.
Parameters:
  • path – Path to image
  • box

    A tuple that defines the left, upper, right and lower pixel coördinate e.g.: (left, upper, right, lower)

    Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # Crop the image
>>> crop_image(testimage, box = (10,10,100,100))
>>> # Show the image
>>> show_image(testimage)
Keywords
image, crop, crop image
Icon
las la-crop
automagica.activities.mirror_image_horizontally(path)

Mirror image horizontally

Mirrors an image with a given path horizontally from left to right.

Parameters:path

Path to image

Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # Mirror image horizontally
>>> mirror_image_horizontally(testimage)
>>> # Show the image
>>> show_image(testimage)
Keywords
image, flip, flip image, mirror, mirror image, horizon, horizontally
Icon
las la-caret-up
automagica.activities.mirror_image_vertically(path)

Mirror image vertically

Mirrors an image with a given path vertically from top to bottom.

Parameters:path

Path to image

Example:
>>> # Take screenshot of current screen to use as test image
>>> testimage = take_screenshot()
>>> # Mirror image vertically
>>> mirror_image_vertically(testimage)
>>> # Show the image
>>> show_image(testimage)
Keywords
image, flip, flip image, mirror, mirror image, vertical, vertically
Icon
las la-caret-right

Process

automagica.activities.run_manual(task)

Windows run

Use Windows Run to boot a process Note this uses keyboard inputs which means this process can be disrupted by interfering inputs

Parameters:task

Name of the task to run e.g. ‘mspaint.exe’

Example:
>>> # Open paint with Windows run
>>> run_manual('mspaint.exe')
>>> # Open home directory with Windows run
>>> run_manual(home_path())
Keywords
run, open, task, win r, windows run, shell, cmd
Icon
las la-cog
automagica.activities.run(process)

Run process

Use subprocess to open a windows process

Parameters:process

Process to open e.g: ‘calc.exe’, ‘notepad.exe’, ‘control.exe’, ‘mspaint.exe’.

Example:
>>> # Open paint with Windows run
>>> run('mspaint.exe')
Keywords
run, open, task, win r, windows run, shell, cmd
Icon
las la-play
automagica.activities.is_process_running(name)

Check if process is running

Check if process is running. Validates if given process name (name) is currently running on the system.

Parameters:name – Name of process
Returns:Boolean
Example:
>>> # Open paint with Windows run
>>> run('mspaint.exe')
>>> # Check if paint is running
>>> is_process_running('mspaint.exe')
True
Keywords
run, open, task, win r, windows run, shell, cmd
Icon
las la-cogs
automagica.activities.get_running_processes()

Get running processes

Get names of unique processes currently running on the system.

Returns:List of unique running processes
Example:
>>> # Show all running processes
>>> get_running_processes()
['cmd.exe', 'chrome.exe', ... ]
Keywords
process, processes, list processes, running, running processes
Icon
las la-list
automagica.activities.kill_process(name=None)

Kill process

Kills a process forcefully

Parameters:name

Name of the process

Example:
>>> # Open paint with Windows run
>>> run('mspaint.exe')
>>> # Force paint to close
>>> kill_process('mspaint.exe')
Keywords
run, open, task, win r, windows run, shell, cmd, kill, stop, kill process, stop process, quit, exit
Icon
las la-window-close

Optical Character Recognition (OCR)

automagica.activities.extract_text_ocr(path=None)

Get text with OCR

This activity extracts all text from the current screen or an image if a path is specified.

Parameters:path – Path to image from where text will be extracted. If no path is specified a screenshot of current screen will be used.
Returns:String with all text from current screen
Example:
>>> # Make a textfile with some text to recognize
>>> testfile = make_textfile(text='OCR Example')
>>> # Open the textfile
>>> open_file(testfile)
>>> # Find the text with OCR
>>> extracted_text = find_text_on_screen_ocr(text='OCR Example')
>>> # Check if the extracted_text contains the original word
>>> 'OCR Example' in extracted_text
True
Keywords
OCR, vision, AI, screen, citrix, read, optical character recognition
Icon
lab la-readme
automagica.activities.find_text_on_screen_ocr(text, criteria=None)

Find text on screen with OCR

This activity finds position (coordinates) of specified text on the current screen using OCR.

Parameters:
  • text – Text to find. Only exact matches are returned.
  • criteria – Criteria to select on if multiple matches are found. If no criteria is specified all matches will be returned. Options are ‘first’, which returns the first match closest to the upper left corner, ‘last’ returns the last match closest to the lower right corner, random selects a random match.
Returns:

Dictionary or list of dictionaries with matches with following elements: ‘h’ height in pixels, ‘text’ the matched text,’w’ the width in pixels, ‘x’ absolute x-coördinate , ‘y’ absolute y-coördinate. Returns nothing if no matches are found

Example:

>>> # Make a textfile with some text to recognize
>>> testfile = make_textfile(text='OCR Example')
>>> # Open the textfile
>>> open_file(testfile)
>>> # Find the text with OCR
>>> find_text_on_screen_ocr(text='OCR Example')
Keywords
OCR, vision, AI, screen, citrix, read, optical character recognition
Icon
las la-glasses
automagica.activities.click_on_text_ocr(text)

Click on text with OCR

This activity clicks on position (coordinates) of specified text on the current screen using OCR.

Parameters:text

Text to find. Only exact matches are returned.

Example:
>>> # Make a textfile with some text to recognize
>>> testfile = make_textfile(text='OCR Example')
>>> # Open the textfile
>>> open_file(testfile)
>>> # Find the text with OCR and click on it
>>> click_on_text_ocr(text='OCR Example')
Keywords
OCR, vision, AI, screen, citrix, read, optical character recognition, click
Icon
las la-mouse-pointer
automagica.activities.double_click_on_text_ocr(text)

Double click on text with OCR

This activity double clicks on position (coordinates) of specified text on the current screen using OCR.

Parameters:text

Text to find. Only exact matches are returned.

Example:
>>> # Make a textfile with some text to recognize
>>> testfile = make_textfile(text='OCR Example')
>>> # Open the textfile
>>> open_file(testfile)
>>> # Find the text with OCR and double click on it
>>> double_click_on_text_ocr(text='OCR Example')
Keywords
OCR, vision, AI, screen, citrix, read, optical character recognition, click, double click
Icon
las la-mouse-pointer
automagica.activities.right_click_on_text_ocr(text)

Right click on text with OCR

This activity Right clicks on position (coordinates) of specified text on the current screen using OCR.

Parameters:text

Text to find. Only exact matches are returned.

Example:
>>> # Make a textfile with some text to recognize
>>> testfile = make_textfile(text='OCR Example')
>>> # Open the textfile
>>> open_file(testfile)
>>> # Find the text with OCR and right click on it
>>> right_click_on_text_ocr(text='OCR Example')
Keywords
OCR, vision, AI, screen, citrix, read, optical character recognition, click, right click
Icon
las la-mouse-pointer

UiPath

automagica.activities.execute_uipath_process(project_file_path, arguments=None, uirobot_exe_path=None)

Execute a UiPath process

This activity allows you to execute a process designed with the UiPath Studio. All console output from the Write Line activity (https://docs.uipath.com/activities/docs/write-line) will be printed as output.

Parameters:
  • project_file_path – path to the project file (as created within the UiPath Studio)
  • arguments – dictionary with input arguments/parameters for the process to use in UiPath (optional)
  • uirobot_exe_path

    path to UiPath’s UiRobot.exe (optional)

    Example:
>>> # Run a UiPath process
>>> arguments = {'firstname': 'John', 'lastname': 'Doe'}
>>> execute_uipath_process(r"C:\Processes UiPath\my_process.xaml", arguments=arguments)
Completed UiPath process "C:\Processes UiPath\my_process.xaml"
Keywords
RPA, UiPath, Studio, robot, orchestrator, xaml, ui path
Icon
las la-robot

AutoIt

automagica.activities.run_autoit_script(script_path, arguments=None, autoit_exe_path=None)

Execute a AutoIt script

This activity allows you to run an AutoIt script. If you use the ConsoleWrite function (https://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm), the output will be presented to you.

Parameters:
  • script_path – path to the ‘.au3’ script file
  • arguments – string with input arguments/parameters for the script (optional)
  • autoit_exe_path

    path to AutoIt.exe (optional)

    Example:
>>> # Run an AutoIt script
>>> arguments = 'John'
>>> run_autoit_script(r"C:\AutoIt\Scripts\MyScript.au3", arguments=arguments) # Point this to your AutoIt Script
Completed AutoIt script "C:\AutoIt\Scripts\MyScript.au3"
Keywords
RPA, AutoIt, au3, au
Icon
las la-robot

Robot Framework

automagica.activities.execute_robotframework_test(test_case_path, variables=None)

Execute a Robot Framework test case

This activity allows you to run a Robot Framework test case. Console output of the test case will be printed.

Parameters:
  • test_case_path – path to the ‘.robot’ test case file
  • variables

    dictionary with variable declarations

    Example:
>>> # Run an Robot Framework test case
>>> variables = {'FIRSTNAME': 'John', 'LASTNAME': 'Doe'}
>>> execute_robotframework_test(r"C:\Test Cases\my_test_case.robot", variables=variables) # Point this to your Robot Framework test case
Completed Robot Framework test case "C:\Test Cases\my_test_case.robot"
Keywords
RPA, robot framework, robotframework, robot
Icon
las la-robot

Blue Prism

automagica.activities.run_blueprism_process(process_name, username='', password='', sso=False, inputs=None, automatec_exe_path=None)

Run a Blue Prism process

This activity allows you to run a Blue Prism process.

Parameters:
  • process_name – name of the process in Blue Prism
  • username – Blue Prism username
  • password – Blue Prism password
  • sso – Run as single-sign on user with Blue Prism
  • inputs – dictionary with inputs declarations (optional)
  • automatec_exe_path

    path to Blue Prism’s AutomateC.exe (optional)

    Example:
>>> # Run a Blue Prism process
>>> inputs = {'firstname': 'John', 'lastname': 'Doe'}
>>> run_blueprism_process("My Example Process", username="user", password="password", inputs=inputs)
Completed Blue Prism process "My Example Process"
Keywords
RPA, blueprism, blue prism, robot
Icon
las la-robot

Automation Anywhere

automagica.activities.run_automationanywhere_task(task_file_path, aaplayer_exe_path=None)

Run an Automation Anywhere task

This activity allows you to run an Automation Anywhere task.

Parameters:
  • task_file_path – path to the task file of Automation Anywhere
  • aaplayer_exe_path

    path to the AAPlayer.exe (optional)

    Example:
>>> # Run an Automation Anywhere task
>>> run_automationanywhere_task(r"C:\AutomationAnywhereTasks\MyTask.atmx")
Completed Automation Anywhere task "C:\AutomationAnywhereTasks\MyTask.atmx"
Keywords
RPA, automation anywhere, aa, robot
Icon
las la-robot

SAP GUI

automagica.activities.click(element_id=None, x=None, y=None, delay=0.1)

Mouse click

Clicks on an element based on the element ID (vision) or pixel position determined by x and y coordinates.

Parameters:
  • element_id – ID of the element. To define an element and attach an ID one can use the Automagica recorder. The recorder uses vision to detect an element and can be invoked with the recorder() function.
  • x – X-coördinate
  • y – Y-coördinate
  • delay – Delay between clicks in seconds, standard value is 100 ms.
Returns:

Mouse click

Example:

>>> # Click on a vision element, use the recorder() function to define elements
>>> recorder()
>>> # Use the element ID found by the recorder, e.g.: click(element_id='ABCD')
>>> # Alternatively, click on coordinates
>>> click(x=100, y=100)
Keywords
mouse, vision, mouse, osd, overlay, show, display, mouse automation, click, right click, mouse button, move mouse, position, pixel
Icon
las la-mouse-pointer

Portal

automagica.activities.create_new_job(script_name, script_version_id=None, priority=0, parameters=None)

Create a new job in the Automagica Portal

This activity creates a new job in the Automagica Portal for a given script. The bot performing this activity will need to be assigned to the script it creates a job for.

Parameters:
  • script_name – name of the script
  • script_version_id – id of a specific version of the script, if not provided it will use the latest version (optional)
  • priority – priority level of the script. higher priority levels are performed first. (optional)
  • parameters

    parameters for the script (optional)

    Example:
>>> # Create a job in the Automagica Portal
>>> create_new_job('My script')
Job 1234567890 created
Keywords
queueing, script, job, create job, new job
Icon
las la-robot

Vision