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

Random key

Return type

bytes

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 (string) – Text to be encrypted

  • key (bytes) – Fernet Encryption key

Returns

Encrypted text

Return type

bytes

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

Parameters
  • encrypted_text – Text to be encrypted.

  • key (bytes) – Fernet Encryption key

Returns

Decrypted text

Return type

string

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_path (input_file) – Path to file to be encrypted

  • key (bytes) – Fernet Encryption key

  • output_path (output_file, optional) – Output path, defaults to the same directory with “_encrypted” added to the name

Returns

Path to encrypted file

Return type

path

Example

>>> # Generate a random key
>>> key = generate_random_key()
>>> # Create a text file to illustrate file encryption
>>> text_file_path = make_text_file()
>>> # Encrypt the text file
>>> encrypt_file_with_key(text_file_path, key=key)
'C:\Users\<username>\generated_text_file_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_path (input_file) – Bytes-like file to be decrypted.

  • key (bytes) – Path where key is stored.

  • output_path (output_file, optional) – 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 text file to encrypt file
>>> text_file_path = make_text_file()
>>> # Encrypt the text file
>>> encrypted_text_file = encrypt_file_with_key(text_file_path, key=key)
>>> # Decrypt the newly encrypted file
>>> decrypt_file_with_key(encrypted_text_file, key=key)
'C:\Users\<username>\generated_text_file_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 (string) – Passwords

  • salt (string, optional) – 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. Please note that MD5 and SHA1 are not cryptographically secure.

Parameters
  • input_path (input_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 (int, optional) – Buffer size for reading file in chunks, default value is 64kb

Options method

[‘md5’, ‘sha256’, ‘blake2b’]

Returns

Bytes-like object

Example

>>> # Generate a text file to illustrate hash
>>> text_file_path = make_text_file()
>>> # Get hash from text file
>>> generate_hash_from_file(text_file_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. Keep in mind that MD5 is not cryptographically secure.

Parameters
  • text (string) – Text to hash

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

Options method

[‘md5’, ‘sha256’, ‘blake2b’]

Returns

Bytes-like object

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 (int, optional) – Lower limit for random number

  • upper_limit (int, optional) – Upper limit for random number

  • fractional (bool, optional) – 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_data(locale=None, attribute=None)

Random data

Generates all kinds of random data. Specifying locale changes format for some options

Parameters
  • locale – Add a locale to generates typical data for selected locale.

  • attribute – Choose a specific characteristic or attribute from fake person

Options locale

[‘cs’, ‘da’, ‘de’, ‘de-at’, ‘de-ch’, ‘el’, ‘en’, ‘en-au’, ‘en-ca’, ‘en-gb’, ‘es’, ‘es-mx’, ‘et’, ‘fa’, ‘fi’, ‘fr’, ‘hu’, ‘is’, ‘it’, ‘ja’, ‘kk’, ‘ko’, ‘nl’, ‘nl-be’, ‘no’, ‘pl’, ‘pt’, ‘pt-br’, ‘ru’, ‘sk’, ‘sv’, ‘tr’, ‘uk’, ‘zh’]

Options attribute

[‘email’, ‘food dish’, ‘food drink’, ‘fruit’, ‘vegetable’, ‘company type’, ‘ean code’, ‘imei code’, ‘isbn code’, ‘issn code’, ‘ip v4’, ‘ip v6’, ‘mac address’, ‘filename’, ‘filename extension’, ‘chemical element’, ‘academic degree’, ‘occupation’, ‘word’, ‘phone number’ , ‘political view’, ‘university’]

  • cs - Czech

  • da - Danish

  • de - German

  • de-at - Austrian german

  • de-ch - Swiss german

  • el - Greek

  • en - English

  • en-au - Australian English

  • en-ca - Canadian English

  • en-gb - British English

  • es - Spanish

  • es-mx - Mexican Spanish

  • et - Estonian

  • fa - Farsi

  • fi - Finnish

  • fr - French

  • hu - Hungarian

  • is - Icelandic

  • it - Italian

  • ja - Japanese

  • kk - Kazakh

  • ko - Korean

  • nl - Dutch

  • nl-be - Belgium Dutch

  • no - Norwegian

  • pl - Polish

  • pt - Portuguese

  • pt-br - Brazilian Portuguese

  • ru - Russian

  • sk - Slovak

  • sv - Swedish

  • tr - Turkish

  • uk - Ukrainian

  • zh - Chinese

Returns

Random data as string

Example

>>> # Generate random data
>>> generate_random_data()
'Banana'
Keywords

random, lorem ipsum, gsm, cell, cellphone, telephone, mobile, number, smartphone, text generater, filler, place holder, noise, random text, random txt, text generation, fake, code, email, generate, generator, generic

Icon

las la-digital-tachograph

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, name=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.

  • name – Choose to generate first, last or full name.

Options name

[‘full’, ‘first’, ‘last’]

Options locale

[‘cs’, ‘da’, ‘de’, ‘de-at’, ‘de-ch’, ‘el’, ‘en’, ‘en-au’, ‘en-ca’, ‘en-gb’, ‘es’, ‘es-mx’, ‘et’, ‘fa’, ‘fi’, ‘fr’, ‘hu’, ‘is’, ‘it’, ‘ja’, ‘kk’, ‘ko’, ‘nl’, ‘nl-be’, ‘no’, ‘pl’, ‘pt’, ‘pt-br’, ‘ru’, ‘sk’, ‘sv’, ‘tr’, ‘uk’, ‘zh’]

  • cs - Czech

  • da - Danish

  • de - German

  • de-at - Austrian german

  • de-ch - Swiss german

  • el - Greek

  • en - English

  • en-au - Australian English

  • en-ca - Canadian English

  • en-gb - British English

  • es - Spanish

  • es-mx - Mexican Spanish

  • et - Estonian

  • fa - Farsi

  • fi - Finnish

  • fr - French

  • hu - Hungarian

  • is - Icelandic

  • it - Italian

  • ja - Japanese

  • kk - Kazakh

  • ko - Korean

  • nl - Dutch

  • nl-be - Belgium Dutch

  • no - Norwegian

  • pl - Polish

  • pt - Portuguese

  • pt-br - Brazilian Portuguese

  • ru - Russian

  • sk - Slovak

  • sv - Swedish

  • tr - Turkish

  • uk - Ukrainian

  • zh - Chinese

Returns

Random 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_words(locale=None, type=None)

Random words

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

Parameters
  • type – Specify type of words to generate

  • locale – Add a locale to generate text for selected locale.

Options type

[‘sentence’, ‘quote’, ‘answer’, ‘single word’, ‘color’, ‘swear word’]

Options locale

[‘cs’, ‘da’, ‘de’, ‘de-at’, ‘de-ch’, ‘el’, ‘en’, ‘en-au’, ‘en-ca’, ‘en-gb’, ‘es’, ‘es-mx’, ‘et’, ‘fa’, ‘fi’, ‘fr’, ‘hu’, ‘is’, ‘it’, ‘ja’, ‘kk’, ‘ko’, ‘nl’, ‘nl-be’, ‘no’, ‘pl’, ‘pt’, ‘pt-br’, ‘ru’, ‘sk’, ‘sv’, ‘tr’, ‘uk’, ‘zh’]

  • cs - Czech

  • da - Danish

  • de - German

  • de-at - Austrian german

  • de-ch - Swiss german

  • el - Greek

  • en - English

  • en-au - Australian English

  • en-ca - Canadian English

  • en-gb - British English

  • es - Spanish

  • es-mx - Mexican Spanish

  • et - Estonian

  • fa - Farsi

  • fi - Finnish

  • fr - French

  • hu - Hungarian

  • is - Icelandic

  • it - Italian

  • ja - Japanese

  • kk - Kazakh

  • ko - Korean

  • nl - Dutch

  • nl-be - Belgium Dutch

  • no - Norwegian

  • pl - Polish

  • pt - Portuguese

  • pt-br - Brazilian Portuguese

  • ru - Russian

  • sk - Slovak

  • sv - Swedish

  • tr - Turkish

  • uk - Ukrainian

  • zh - Chinese

Returns

Random words as string

Example

>>> # Generate a random sentence
>>> generate_random_words()
'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, format=None)

Random address

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

Parameters
  • format – Choose a specific part or format for the address

  • locale – Add a locale to generate typical address for selected locale.

Options format

[‘address’, ‘street’, ‘street number’, ‘city’, ‘continent’, ‘country’, ‘country code’, ‘postal code’]

Options locale

[‘cs’, ‘da’, ‘de’, ‘de-at’, ‘de-ch’, ‘el’, ‘en’, ‘en-au’, ‘en-ca’, ‘en-gb’, ‘es’, ‘es-mx’, ‘et’, ‘fa’, ‘fi’, ‘fr’, ‘hu’, ‘is’, ‘it’, ‘ja’, ‘kk’, ‘ko’, ‘nl’, ‘nl-be’, ‘no’, ‘pl’, ‘pt’, ‘pt-br’, ‘ru’, ‘sk’, ‘sv’, ‘tr’, ‘uk’, ‘zh’]

  • cs - Czech

  • da - Danish

  • de - German

  • de-at - Austrian german

  • de-ch - Swiss german

  • el - Greek

  • en - English

  • en-au - Australian English

  • en-ca - Canadian English

  • en-gb - British English

  • es - Spanish

  • es-mx - Mexican Spanish

  • et - Estonian

  • fa - Farsi

  • fi - Finnish

  • fr - French

  • hu - Hungarian

  • is - Icelandic

  • it - Italian

  • ja - Japanese

  • kk - Kazakh

  • ko - Korean

  • nl - Dutch

  • nl-be - Belgium Dutch

  • no - Norwegian

  • pl - Polish

  • pt - Portuguese

  • pt-br - Brazilian Portuguese

  • ru - Russian

  • sk - Slovak

  • sv - Swedish

  • tr - Turkish

  • uk - Ukrainian

  • zh - Chinese

Returns

Name as string

Example

>>> # Generate a random address
>>> generate_random_address()
'123 Robot Avenue'
Keywords

random, address, data, street, city, postal, dummy name, name, name generater, fake person, fake, person, surname, lastname, fake name generator

Icon

las la-map-marker

automagica.activities.generate_random_beep(max_duration=2000, max_frequency=5000)

Random beep

Generates a random beep, only works on Windows

Parameters
  • max_duration (int, optional) – Maximum random duration in miliseconds. Default value is 2 miliseconds

  • max_frequency (int, optional) – 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 (int, optional) – Days in the past for which oldest random date is generated, default is 1000 days

  • formatting (string, optional) – 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_date_today(formatting='%m/%d/%Y')

Today’s date

Generates today’s 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

formatting (string, optional) – 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_date_today()
'01/01/2022'
Keywords

random, date, today, now, today date, time, 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

Output

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 (string, optional) – Message to be displayed

  • seconds – Duration in seconds for message to be displayed

>>> # Display overlay message
>>> display_osd_message()
Keywords

message box, osd, overlay, info warning, info, popup, window, feedback, screen, login, attended

Icon

las la-tv

automagica.activities.print_console(data='Example print')

Print message in console

Print message in console. Can be used to display data in the Automagica Flow console

Parameters

data – Data to be printed

>>> # Print in console
>>> print_console()
Keywords

print, box, osd, data, debugging info, popup, window, feedback, screen, login, attended

Icon

las la-tv

Browser

class automagica.activities.Chrome(**kwargs)
browse_to(url)

Browse to URL

Browse to URL.

Parameters

url (string) – Url to browser to

Returns

Webpage

Example

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.browse_to('https://nytimes.com')
Keywords

chrome, element, browse to, browse, surf, surf to, go to, get, internet, browsing, browser, surfing, web, webscraping, www, selenium, crawling, webtesting, mozilla, firefox, internet explorer

Icon

lab la-chrome

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’

Parameters

element (string, optional) – Class of element

Returns

Element by class

Example

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find element by class
>>> element = 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.

Parameters
  • element (string) – Class of element

  • text (string) – Text inside the element

Returns

Element by class and text

Example

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find elements by class and text
>>> element = browser.by_class_and_by_text('search-input', 'Search Wikipedia')
>>> # 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

Parameters

element (string, optional) – Class of element

Returns

Element by classes

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')
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

Parameters

element (string, optional) – Id of element

Returns

Element by id

Example

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find element by class
>>> elements = browser.by_id('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_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’

Parameters

element (string, optional) – Xpath of element

Returns

Element by xpath

Example

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find element by xpath
>>> element = 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’

Parameters

element (string, optional) – Xpath of element

Returns

Element by xpaths

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

download_latest_driver(chromedriver_path)

Downloads latest Chrome driver on Windows

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 (string, optional) – Criteria of substring that url must contain to be included

Returns

Links

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.

Parameters

text (string) – Text to find elements by

Returns

Elements that matched with text

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 (string, optional) – Criteria of substring that url must contain to be included

Returns

First link

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

get_text_on_webpage()

Get all text on webpage

Get all the raw body text from current webpage

Returns

Text

Example

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://nytimes.com')
>>> # Get text from page
>>> browser.get_text_on_webpage()
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

Parameters

element – Element to highlight

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://wikipedia.org')
>>> # Find first link on page
>>> first_link = browser.find_elements_by_xpath("//a[@href]")[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 (output_dir, optional) – 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

switch_to_iframe(name='iframe')

Switch to iframe in browser

Switch to an iframe in the browser

Parameters

name – Name of the Iframe

>>> # Open the browser
>>> browser = Chrome()
>>> # Go to a website
>>> browser.get('https://www.w3schools.com/html/html_iframe.asp')
>>> # Switch to iframe
>>> browser.switch_to_iframe()
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

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 (string, optional) – Username for which credential will be added.

  • password (string, optional) – Password to add

  • system (string) – 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 (string) – Username for which credential (username + password) will be deleted.

  • password (string, optional) – Password to delete

  • 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 (string) – Username to get password for.

  • system (string, optional) – 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(**kwargs)
create_directory(directory_name, path='/')

Create FTP directory

Create a FTP directory. Note that sufficient permissions are present

Parameters
  • directory_name (string) – Name of the new directory, should be a string e.g. ‘my_directory’

  • path (output_dir, optional) – 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 (input_dir, optional) – 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 (input_file) – Path to the file on the FPT server to download

  • output_path (output_dir, optional) – 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 (input_dir, optional) – 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
  • input_path (input_file) – Path file that will be uploaded

  • output_path (output_dir, optional) – Destination path to upload.

Returns

Path 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
>>> text_file = make_text_file()
>>> # Upload file to FTP test server
>>> # Note that this might result in a persmission error for public FPT's
>>> ftp.upload_file(input_path = text_file)
Keywords

FTP, upload, fptfile transfer protocol, filezilla, winscp, server, remote, folder, folders

Icon

las la-upload

Keyboard

automagica.activities.press_key(key=None, delay=1, perform_n_times=1, delay_between=0.5)

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 access to your terminal application. (Security Preferences > Security & Privacy > Privacy > Accessibility)

Parameters
  • key – Key to press. This can also be a scan code (e.g: 33 for ‘!’)

  • delay (int, optional) – Delay before key is pressed in seconds, default is 1 second

  • perform_n_times (int, optional) – How many times to perform the key press

  • delay_between (float, optional) – Delay between key presses

Options key

[‘ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘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’, ‘end’, ‘ctrl’, ‘del’, ‘downarrow’, ‘right’, ‘left’, ‘up’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, ‘f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘home’, ‘insert’, ‘pagedown’, ‘pageup’, ‘help’, ‘space’, ‘tab’, ‘shift’, ‘win’]

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, compatibility=False, delay=1)

Press key combination

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

Parameters
  • first_key – First key to press

  • second_key – Second key to press

  • third_key – Third key to press, this is optional.

  • compatibility – Set parameter to true to not use win32com. This could help with compatibility on certain systems or when certain keypresses do not work correctly.

  • delay (int, optional) – Delay before keys are pressed in seconds, default is 1 second

Options first_key

[‘ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘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’, ‘end’, ‘ctrl’, ‘del’, ‘downarrow’, ‘right’, ‘left’, ‘up’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, ‘f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘home’, ‘insert’, ‘pagedown’, ‘pageup’, ‘help’, ‘space’, ‘tab’, ‘shift’, ‘win’]

Options second_key

[‘ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘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’, ‘end’, ‘ctrl’, ‘del’, ‘downarrow’, ‘right’, ‘left’, ‘up’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, ‘f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘home’, ‘insert’, ‘pagedown’, ‘pageup’, ‘help’, ‘space’, ‘tab’, ‘shift’, ‘win’]

Options third_key

[‘ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-‘, ‘.’, ‘/’, ‘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’, ‘end’, ‘ctrl’, ‘del’, ‘downarrow’, ‘right’, ‘left’, ‘up’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, ‘f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘home’, ‘insert’, ‘pagedown’, ‘pageup’, ‘help’, ‘space’, ‘tab’, ‘shift’, ‘win’]

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

automagica.activities.typing(text, automagica_id=None, clear=False, interval_seconds=0.01, delay=1)

Type text

Simulate keystrokes. If an element ID is specified, text will be typed in a specific field or element based on the element ID (vision) by the recorder.

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’

parameter text

Text in string format to type. Note that you can only press single character keys. Special keys can not be part of the text argument.

type text

string

parameter automagica_id

ID of the element. To define an element and attach an ID one can use the Automagica Wand. The recorder uses vision to detect an element and can be invoked with the recorder() function.

type automagica_id

automagica_id, optional

parameter clear

Attempts to clear the element before typing using hotkeys. Be cautious when using this method as a vision mismatch could result in deleting unwanted data. Default value is False

type clear

bool, optional

parameter interval_seconds

Time in seconds between two keystrokes. Defautl value is 0.01 seconds.

type interval_seconds

int, optional

parameter delay

Delay before beginning to type, default is 1 second

type delay

int, optional

return

Keystrokes

Example

>>> # Open notepad to illustrate typing
>>> run('notepad.exe')
>>> # Type a story
>>> typing('Why was the robot mad? 

They kept pushing his buttons!’)

Keywords

keyboard, keystrokes, key combination, shortcut, typing, type, key, keystroke, hotkey, press, press key, send keys, keystrokes

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 (int, optional) – Delay in seconds before capturing mouse position.

  • to_clipboard (bool, optional) – 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 (int, optional) – 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(automagica_id, delay=1)

Mouse click

Clicks on an element based on the element ID (vision)

Parameters
  • automagica_id (automagica_id) – ID of the element. To define an element and attach an ID one can use the Automagica Wand. The recorder uses vision to detect an element and can be invoked with the recorder() function.

  • delay – Delay before clicking in seconds.

>>> # Click on a vision element, use the recorder() function to define elements
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> click('qf41')
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.click_coordinates(x=None, y=None, delay=1)

Mouse click coordinates

Clicks on an element based on pixel position determined by x and y coordinates. To find coordinates one could use display_mouse_position().

Parameters
  • x (int) – X-coordinate

  • y (int) – Y-coordinate

  • delay – Delay before clicking in seconds.

>>> # Click on pixel position
>>> click_coordinates(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_coordinates(x=None, y=None, delay=1)

Double mouse click coordinates

Double clicks on a pixel position determined by x and y coordinates.

Parameters
  • x (int) – X-coordinate

  • y (int) – Y-coordinate

  • delay – Delay before cliking in seconds.

>>> # Click on coordinates
>>> double_click_coordinates(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.double_click(automagica_id=None, delay=1)

Double mouse click

Double clicks on an element based on the element ID (vision)

Parameters
  • automagica_id (automagica_id) – ID of the element. To define an element and attach an ID one can use the Automagica Wand. The recorder uses vision to detect an element and can be invoked with the recorder() function.

  • delay – Delay before clicking in seconds.

>>> # Click on a vision element, use the recorder() function to define elements
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> double_click('qf41')
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(automagica_id=None, delay=1)

Right click

Right clicks on an element based on the element ID (vision)

Parameters
  • automagica_id (automagica_id) – ID of the element. To define an element and attach an ID one can use the Automagica Wand. The recorder uses vision to detect an element and can be invoked with the recorder() function.

  • delay – Delay before cliking in seconds.

>>> # Click on a vision element, use the recorder() function to define elements
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> right_click('qf41')
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.right_click_coordinates(x=None, y=None, delay=1)

Right click coordinates

Right clicks on an element based pixel position determined by x and y coordinates.

Parameters
  • x (int) – X-coördinate

  • y (int) – Y-coördinate

  • delay – Delay before clicking in seconds

>>> # Right click on coordinates
>>> right_click_coordinates(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(automagica_id=None, delay=1)

Move mouse

Moves te pointer to an element based on the element ID (vision)

Parameters
  • automagica_id (automagica_id, optional) – ID of the element. To define an element and attach an ID one can use the Automagica Wand. The recorder uses vision to detect an element and can be invoked with the recorder() function.

  • delay (int, optional) – Delay before movement in seconds

Returns

Move mouse to (x, y) coordinates

Example

>>> # Use recorder to find an element ID
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> move_mouse_to('qf41')
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_to_coordinates(x=None, y=None, delay=1)

Move mouse coordinates

Moves te pointer to an element based on the pixel position determined by x and y coordinates

Parameters
  • x (int) – X-coördinate

  • y (int) – Y-coördinate

  • delay (int, optional) – Delay between movements in seconds, standard value is 1s.

Returns

Move mouse to (x, y) coordinates

Example

>>> # Move mouse to coordinates
>>> move_mouse_to_coordinates(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 (int) – X-coördinate

  • y (int) – Y-coördinate

Returns

Move mouse (x, y) coordinates

Example

>>> move_mouse_to_coordinates(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_coordinates(x=None, y=None, end_x=0, end_y=0, delay=1)

Drag mouse relatively

Drags mouse to an element based on pixel position determined by x and y coordinates

Parameters
  • x (int) – X-coordinate

  • y (int) – Y-coordinate

  • x – X-coordinate to stop dragging

  • y – Y-coordinate to stop dragging

  • delay – Delay between movements in seconds, standard value is 1s.

>>> # Use coordinates to move and drag mouse
>>> move_mouse_to_coordinates(x=100, y=100)
>>> drag_mouse_to_coordinates(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

automagica.activities.drag_mouse_to(automagica_id=None, end_x=0, end_y=0, delay=1)

Drag mouse

Drags mouse to an element based on the element ID (vision)

Parameters
  • automagica_id (automagica_id) – ID of the element. To define an element and attach an ID one can use the Automagica Wand. The recorder uses vision to detect an element and can be invoked with the recorder() function.

  • end_x (int, optional) – Drag to x

  • end_y (int, optional) – Drag to y

  • delay (int, optional) – Delay before movement in seconds.

Returns

Drag mouse

Example

>>> # Use recorder to find an element ID
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> drag_mouse_to('qf41')
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, output_path=None)

Random screen snippet

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

Parameters
  • size (int, optional) – Size (width and height) in pixels for square snippet. Default value is 100 pixels

  • output_path (output_file) – Path where snippet will be saved. Default value is home directory with name ‘random_screensnippet.jpg’

Extension output_path

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(output_path=None)

Screenshot

Take a screenshot of current screen.

Parameters

output_path (output_path) – Path to save screenshot. Default value is home directory with name ‘screenshot.jpg’.

Extesion output_path

jpg

Returns

Path to save screenshot

Example

>>> new_screenshot = take_screenshot()
>>> open_file(new_screenshot)
'C:\Users\<username>\screenshot.jpg'
Keywords

image, screenshot, printscreen,

Icon

las la-expand

Folder Operations

automagica.activities.get_files_in_folder(input_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
  • input_path (input_dir) – Path of the folder to retreive files from. Default folder is the home directory.

  • extension (string, optional) – Optional filter on certain extensions, for example ‘pptx’, ‘exe,’ xlsx’, ‘txt’, .. Default value is no filter.

  • show_full_path (bool, optional) – Set this to True to show full path, False will only show file or dirname. Default is True

  • scan_subfolders (bool, optional) – Boolean to scan subfolders or not. Note 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 (input_dir, optional) – 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, new folder, folders, make folder, new folder, folder manipulation, explorer, nautilus

Icon

las la-folder-plus

automagica.activities.rename_folder(input_path, output_name=None)

Rename folder

Rename a folder

Parameters
  • input_path (input_dir, optional) – Full path of folder that will be renamed

  • output_name (string, optional) – New name. 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.

Example

>>> # Make new folder in home directory for illustration
>>> testfolder = create_folder()
>>> # Rename the folder
>>> rename_folder(testfolder, output_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(input_path=None)

Open a folder

Open a folder with the default explorer.

Parameters

input_path (input_dir, optional) – Full path of folder that will be opened. Default value is the home directory

Returns

Path to open 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(input_path, output_path=None)

Move a folder

Moves a folder from one place to another.

Parameters
  • input_path (input_dir) – Full path to the source location of the folder

  • output_path – Full path to the destination location of the folder, defaults to input_path with ‘_moved’ added

>>> # 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(input_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
  • input_path (input_dir) – Full path to the folder that will be deleted

  • allow_root (bool, optional) – Allow paths with an arbitrary length of 10 characters or shorter to be deleted. Default value is False.

  • delete_read_only (bool, optional) – Option to delete read only

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(input_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
  • input_path (input_dir) – 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 text file in this folder
>>> text_file_location = make_text_file(output_path = testfolder)
>>> # Print all files in the testfolder
>>> get_files_in_folder(testfolder)
>>> # 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(input_path)

Checks if folder exists

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

Parameters

input_path (input_dir) – 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(input_path, output_path=None)

Copy a folder

Copies a folder from one place to another.

Parameters
  • input_path (input_dir) – Full path to the source location of the folder

  • output_path (output_dir, optional) – Full path to the destination location of the folder. If no path is specified folder will get copied in the input directory with ‘_copied’ added

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(input_path, output_path=None)

Zip

Zip folder and its contents. Creates a .zip file.

Parameters
  • input_path (input_dir) – Full path to the source location of the folder that will be zipped

  • output_path (output_dir, optional) – Full path to save the zipped folder. If no path is specified a folder with the original folder with ‘_zipped’ added

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(input_path, output_path=None)

Unzip

Unzips a file or folder from a .zip file.

Parameters
  • input_path (input_dir) – Full path to the source location of the file or folder that will be unzipped

  • output_path (output_dir, optional) – 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 file in home directory for illustration
>>> testfolder = create_folder()
>>> # Add some files to this folder
>>> make_text_file(output_path = testfolder)
>>> # 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(input_path=None)

Return most recent file in directory

Return most recent file in directory

Parameters

input_path (input_dir, optional) – Path which will be scanned for most recent file, defaults to homedir

Returns

Path to most recent file

Example

>>> # Find most recent file in homedir
>>> most_recent_file()
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

>>> 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_folder_exists(input_path, timeout=60)

Wait for folder

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

Parameters
  • input_path (input_dir, optional) – Full path to folder.

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

>>> # 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(**kwargs)
append_text(text)

Append text

Append text at end of Word document.

Parameters

text – Text to append to document

>>> # 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(output_path=None)

Export to HTML

Export to HTML

Parameters

output_path (output_file, optional) – Output path where HTML file will be exported to. Default path is home directory with filename ‘html_export.html’.

Extension output_path

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, doc, docx

Icon

las la-html5

export_to_pdf(output_path=None)

Export to PDF

Export the document to PDF

Parameters

output_path (output_file, optional) – Output path where PDF file will be exported to. Default path is home directory with filename ‘pdf_export.pdf’.

Extension output_path

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, doc, docx

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

word, wordfile, doc quit, close, doc, docx

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 (bool, optional) – 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, doc, docx

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 (string) – Placeholder text value in the document, this will be replaced, e.g. ‘Company Name’

  • replacement_text – Text to replace the placeholder values with. It is recommended to make this unique to avoid wrongful replacement, e.g. ‘XXXX_placeholder_XXX’

>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
>>> word.replace_text('sample', 'real')
Keywords

word, replace, text, template, doc, docx

Icon

lar la-file-word

save()

Save

Save active Word document

Example

>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
>>> word.save_as('automagica_document.docx')
Keywords

word, save, document, doc, docx

Icon

lar la-file-word

save_as(output_path)

Save As

Save active Word document to a specific location

Parameters

output_path (output_file) – Enter a path to open Word with an existing Word file.

Extension output_path

docx

Example

>>> # Start Word
>>> word = Word()
>>> word.append_text('This is sample text')
>>> word.save_as('document.odt')
Keywords

word, save as, document, doc, docx

Icon

lar la-file-word

set_footers(text)

Set footers

Set the footers of the document

Parameters

text – Text to put in the footer

>>> # Start Word
>>> word = Word()
>>> word.set_footers('This is a footer!')
Keywords

word, footer, footers, doc, docx

Icon

las la-heading

set_headers(text)

Set headers

Set the headers of the document

Parameters

text – Text to put in the header

>>> # Start Word
>>> word = Word()
>>> word.set_headers('This is a header!')
Keywords

word, header, headers, doc, docx

Icon

las la-subscript

Word File

class automagica.activities.WordFile(**kwargs)
append_text(text, auto_save=True)

Append text

Append text at the end of the document

Parameters
  • text (streing) – Text to append

  • auto_save – Save document after performing activity. Default value is True

>>> 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 (bool, optional) – 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 (string) – Placeholder text value (string) in the document, this will be replaced, e.g. ‘Company Name’

  • replacement_text (string) – 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

>>> 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(output_path)

Save as

Save file on specified path

Parameters

output_path (output_file) – Path to save Wordfile to

Extension output_path

docx

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 (string) – Text to put in the header

  • auto_save – Save document after performing activity. Default value is True

>>> 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(**kwargs)
add_contact(email, first_name='', last_name='')

Add a contact

Add a contact to Outlook contacts

Parameters
  • email (string, optional) – The e-mail address for the contact

  • first_name (string, optional) – First name for the contact (optional)

  • last_name – Last name for the contact (optional)

>>> 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 (string, optional) – Name of the Outlook folder, can be found using get_folders

  • limit (int) – Maximum number of e-mails to delete in one go

  • subject_contains (string, optional) – Only delete e-mail if subject contains this

  • body_contains (string, optional) – Only delete e-mail if body contains this

  • sender_contains – Only delete e-mail if sender contains this

>>> 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 (tuple, optional) – 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 (int, optional) – Maximum number of folders to retrieve

Returns

List of folders

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 (string, optional) – Name of the Outlook folder, can be found using get_folders.

  • fields (tuple, optional) – 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()
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 (string, optional) – Name of the Outlook source folder from where e-mails will be moved, can be found using get_folders

  • target_folder_name (string, optional) – Name of the Outlook destination folder to where e-mails will be moved, can be found using get_folders

  • limit (int) – Maximum number of e-mails to move in one go

  • subject_contains (string, optional) – Only move e-mail if subject contains this

  • body_contains (string, optional) – Only move e-mail if body contains this

  • sender_contains – Only move e-mail if sender contains this

>>> 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', output_path=None)

Save attachments

Save all attachments from certain folder

Parameters
  • folder_name (string, optional) – Name of the Outlook folder, can be found using get_folders.

  • output_path (output_dir, optional) – 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 (string, optional) – The subject of the e-mail

  • body (text, optional) – The text body contents of the e-mail

  • html_body (text, optional) – The HTML body contents of the e-mail (optional)

  • attachment_paths – List of file paths to attachments

>>> 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(**kwargs)
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

>>> # 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

name – Give the sheet a name (optional)

>>> # 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(column)

Delete column

Delete 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’

>>> # 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('A')
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

>>> # 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(output_path=None)

Export to PDF

Export to PDF

Parameters

output_path (output_file, optional) – Output path where PDF file will be exported to. Default path is home directory with filename ‘pdf_export.pdf’.

Extension output_path

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 (string) – Table name

Returns

List of dictionaries for each row with as key the column name

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 of 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 (string) – List of dictionaries to write as table

  • range (string, optional) – Range or startingpoint for table e.g. ‘A1’

  • table_style – Table style to apply

>>> 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 where to insert empty column e.g. ‘A’

>>> # 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('A')
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 where to insert empty row e.g 1

>>> # 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 (int) – Column number (integer) to read

  • row (int) – 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)

Read cell formula

Read the formula from a particular cell

Parameters
  • column (int) – Column number to read formula

  • row (int) – Row number 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 (string) – Range to read from, e.g. “A1:D10”

Returns

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 (string, optional) – Optional name of worksheet to read. If no name is specified will take active sheet

  • headers (bool, optional) – 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.

>>> 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. Defaults to homedir

Example

>>> # Open Excel
>>> excel = Excel()
>>> # Add the first worksheet
>>> excel.add_worksheet('My Example Worksheet')
>>> # Save the workbook
>>> excel.save()
Keywords

excel, save, store

Icon

las la-file-excel

save_as(output_path)

Save as

Save the current workbook to a specific path

Parameters

output_path (output_file) – Path where workbook will be saved.

Extension output_path

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 (int) – Column number (integer) to write

  • row (int) – Row number (integer) to write

  • value – Value to write to specific cell

>>> # 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 (int) – Column number to write formula

  • row (int) – Row number to write formula

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

>>> # 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 (string) – Range to write to, e.g. “A1:D10”

  • value – Value to write to range

>>> # 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(**kwargs)
activate_worksheet(name)

Activate worksheet

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

Parameters

name – Name of the worksheet to activate.

>>> # 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.activate_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 (string) – Name of the worksheet to add

  • auto_save – Save document after performing activity. Default value is True

>>> # 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 (int) – 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()

Save as

Save file

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()
Keywords

excel, save as, export, save

Icon

las la-file-excel

save_as(output_path)

Save as

Save file as

Parameters

output_path (output_file) – Path where workbook will be saved

Extension output_path

xlsx

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')
Keywords

excel, save as, export, save

Icon

las la-file-excel

to_dataframe()

Export file to dataframe

Export to pandas dataframe

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 (int) – Column number (integer) to write

  • row (int) – Row number (integer) to write

  • value (string) – Value to write to specific cell

  • auto_save – Save document after performing activity. Default value is True

>>> # 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(**kwargs)
add_slide(index=None, type='blank')

Add PowerPoint Slides

Adds slides to a presentation

Parameters
  • index (int, optional) – Index where the slide should be inserted. Default value is as final slide.

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

Options type

[‘blank’, ‘chart’, ‘text’, ‘title’, ‘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 (int, optional) – Slide index to add text. If none is specified, a new slide will be added as final slide

  • text (string, optional) – Text to be added

  • font_size (int, optional) – Fontsize, default value is 48

  • font_name (string, optional) – Fontname, if not specified will take default PowerPoint font

  • bold (bool, optional) – Toggle bold with True or False, default value is False

  • margin_bottom (int, optional) – Margin from the bottom in pixels, default value is 100 pixels

  • margin_left (int, optional) – Margin from the left in pixels, default value is 100 pixels

  • margin_right (int, optional) – Margin from the right in pixels, default value is 100 pixels

  • margin_top – Margin from the top in pixels, default value is 100 pixels

>>> # 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

>>> # 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(output_path=None, type='png')

Slides to images

Export PowerPoint slides to seperate image files

Parameters
  • output_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

Options type

[‘jpg’, ‘png’]

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(output_path=None)

PowerPoint to PDF

Export PowerPoint presentation to PDF file

Parameters

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

Extension output_path

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

Returns

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

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 (string) – 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’

>>> # 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()

Save PowerPoint

Save PowerPoint Slidedeck

Example

>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add a first slide
>>> powerpoint.add_slide()
>>> # Save the PowerPoint presentation
>>> powerpoint.save_as('AmazingPresentation.pptx')
Keywords

powerpoint, ppt, save, save as, save powerpoint

Icon

las la-file-powerpoint

save_as(output_path)

Save PowerPoint

Save PowerPoint Slidedeck

Parameters

output_path (output_file) – Save the PowerPoint presentation.

Extension output_path

pptx

Example

>>> # Start PowerPoint
>>> powerpoint = PowerPoint()
>>> # Add a first slide
>>> powerpoint.add_slide()
>>> # Save the PowerPoint presentation
>>> powerpoint.save_as('AmazingPresentation.pptx')
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 (string) – Client secret for office 365 account

  • to_email (string) – E-mail to send to

  • subject (string, optional) – Optional subject

  • body – Optional body of the email

>>> # 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 (string) – Action (the URL)

  • key (string) – Authorisation key

  • parameters (string) – URL params

  • method – Method (get, post or patch)

  • data (string) – Data for POST/PATCH.

Options method

[‘get’, ‘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
  • smtp_host (string) – The host of your e-mail account.

  • smtp_user (string) – The password of your e-mail account

  • smtp_password (string) – The password of your e-mail account

  • to_address (string) – The destination is the receiving mail address.

  • subject (string, optional) – The subject

  • message (text, optional) – 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.

>>> 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 (string) – 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

Returns

Window found (True)

Example

>>> # Make text file
>>> testfile = make_text_file()
>>> # Open the file
>>> open_file(testfile)
>>> #Find 'Notepad' in window titles
>>> find_window_title('Notepad')
'generated_text_file.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 (string) – IP address of remote desktop

  • username (string) – Username

  • password (string, optional) – Password

  • desktop_width (int, optional) – Resolution (width) of desktop, standard value is 1920 (full HD)

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

>>> 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 (string) – Username

  • password – New password

>>> 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 (string) – Username

  • password (string) – 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

Returns

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

>>> # 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_from_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 (input_file) – 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 (int, optional) – Integer to specify frequency (Hz), default value is 1000 Hz

  • duration (int, optional) – 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

Returns

List of network interfaces

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

>>> 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

>>> 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

Returns

Default printer name

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

>>> 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

>>> 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 (string) – Name of service

Returns

Status

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

>>> 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

>>> 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

title – Window title

>>> 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

Returns

Window title

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

>>> 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

>>> 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

>>> 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

>>> 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 (string) – Title of window

  • x (int) – Starting x position

  • y (int) – Starting y position

  • width (int) – Width

  • height – Height

>>> 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

>>> 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 (string) – User

  • host (string) – Host

  • command (string) – Command

Returns

subprocess

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 (string) – Target

  • oids (string) – oids

  • credentials (string) – credentials

  • port (int, optional) – Port (default 161)

  • engine (string, optional) – Engine (default none)

  • context (string, optional) – Contect (default none)

Returns

Results

Example

>>> snmp_get()
Keywords

snmp, simple network management protocol, protocols, get

Icon

las la-ethernet

Active Directory

class automagica.activities.ActiveDirectory(**kwargs)
get_object_by_distinguished_name(distinguished_name)

Get AD object by name

Interface to Windows Active Directory through ADSI

Parameters

distinguished_name (string) – Name

Returns

Object

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(filename=None)

Get user home path

Returns the current user’s home path

Parameters

filename (string, optional) – 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 text file
>>> make_text_file()
>>> # Refer to it
>>> home_path('generated_text_file.txt')
'C:\Users\<username>\generated_text_file.txt'
Keywords

home, home path, homepath, home directory, homedir

Icon

las la-home

automagica.activities.desktop_path(filename=None)

Get desktop path

Returns the current user’s desktop path

Parameters

filename (string, optional) – 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 text file
>>> make_text_file()
>>> # Refer to it
>>> desktop_path('generated_text_file.txt')
'C:\Users\<username>\Desktop\generated_text_file.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
>>> downloads_path()
Keywords

download, download path, downloadpath, download directory, download dir, downloaddir

Icon

lar la-download

automagica.activities.open_file(input_path)

Open file

Opens file with default programs

Parameters

input_path (input_file) – Path to file.

Returns

Path to file

Example

>>> # Make text file
>>> testfile = make_text_file()
>>> # 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

>>> # 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, output_path=None)

Download file from a URL

Download file from a URL

Parameters
  • url (string) – Source URL to download file from

  • output_path (output_dir, optional) – Target path, default to homedir with name ‘_download_’ + random addition

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, output_path ='robot.jpg')
'C:\Users\<username>\robot.jpg'
Keywords

download, download url, save, request

Icon

las la-cloud-download-alt

System

automagica.activities.rename_file(input_path, output_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. Make sure to add the exstention to specify filetype.

Parameters
  • input_path (input_file) – Full path to file that will be renamed

  • output_name (string, optional) – 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 text file in home directory
>>> text_file = make_text_file()
>>> # Rename the file
>>> rename_file(text_file, output_name='brand_new_filename.txt')
C:\Users\<username>\brand_new_filename.txt'
Keywords

file, rename, rename file, organise file, files, file manipulation, explorer, nautilus

Icon

las la-file-contract

automagica.activities.move_file(input_path, output_path=None)

Move a file

If the new location already contains a file with the same name.

Parameters
  • input_path (input_file) – Full path to the file that will be moved

  • output_path (output_dir) – Path to the folder where file will be moved to, defaults to input_path with ‘_moved’ added

Returns

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

Example

>>> # Make new text file in home directory
>>> text_file = make_text_file()
>>> # Make a folder to move the file to
>>> new_folder = create_folder()
>>> # Move text file to the folder
>>> move_file(text_file, 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 (input_file) – Full path to the file that will be deleted.

Returns

Path to removed file as a string.

Example

>>> # Make new text file in home directory
>>> text_file = make_text_file()
>>> # Remove the file
>>> remove_file(text_file)
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 (input_file) – Full path to the file to check.

Returns

True or False (boolean)

Example

>>> # Make new text file in home directory
>>> text_file = make_text_file()
>>> # Check if file exists
>>> file_exists(text_file)
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.

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

Parameters
  • path (input_file) – Full path to file.

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

>>> # Make new text file in home directory
>>> text_file = make_text_file()
>>> # Wait untile file exists # Should pass immediatly
>>> wait_file_exists(text_file)
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

  • file_path (output_file) – Path to the text-file.

Extension file_path

txt

Example

>>> # Make a list to write
>>> robot_names = ['WALL-E', 'Terminator', 'R2D2']
>>> # Create a new text file
>>> text_file = make_text_file()
>>> write_list_to_file(robot_names, text_file)
>>> # Open the file for illustration
>>> open_file(text_file)
Keywords

list, text, txt, list to file, write list, write

Icon

las la-list

automagica.activities.read_list_from_txt(input_path)

Read list from .txt file

This activity reads 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

input_path (input_file) – Path to the .txt file

Extension input_path

txt

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
>>> text_file = make_text_file()
>>> write_list_to_file(robot_names, text_file)
>>> # Read list from file
>>> read_list_from_txt(text_file)
['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.read_from_txt(input_path)

Read .txt file

This activity reads a .txt file and returns the content

Parameters

input_path (input_file) – Path to the .txt file

Extension input_path

txt

Returns

Contents of specified .txt file

Example

>>> # Create a new text file
>>> text_file = make_text_file()
>>> # Read list from file
>>> read_from_txt(text_file)
'Sample text'
Keywords

list, text, txt, list to file, 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 (string) – The text line to write to the end of the file

  • file_path (input_file) – Path to the file to write to

Extension file_path

txt

Example

>>> # Create a new text file
>>> text_file = make_text_file()
>>> # Append a few lines to the file
>>> append_line('Line 1', text_file)
>>> append_line('Line 2', text_file)
>>> append_line('Line 3', text_file)
>>> # Open the file for illustration
>>> open_file(text_file)
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_text_file(text='Sample text', output_path=None)

Make text file

Initialize text file

Parameters
  • text (string, optional) – The text line to write to the end of the file. Default text is ‘Sample text’

  • output_path (output_file, optional) – Ouput path. Will write to home directory on default

Extension output_path

txt

Returns

Path as string

Example

>>> # Create a new text file
>>> text_file = make_text_file()
C:\Users\<username>\generated_text_file.txt'
Keywords

make text file, text_file, testfile, exampel file, make file, make, new file, new text_file, txt, new txt

Icon

las la-file-alt

automagica.activities.read_text_file_to_list(file_path)

Read .txt file with newlines to list

Read a text file to a Python list-object

parameter file_path

Path to the text file which should be read to a list

type file_path

input_file

extension file_path

txt

return

List with the lines in the text file

Example

>>> # Create a new text file
>>> text_file = make_text_file(text="First line!
Second line!”)
>>> # Read the text file to a list
>>> lines = read_text_file_to_list(text_file)
>>> lines
['First line!', 'Second line!']
Keywords

read text file, list, reading text file

Icon

las la-copy

automagica.activities.copy_file(input_path, output_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
  • input_path (input_file) – Full path to the source location of the file

  • output_path (output_dir, optional) – 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
>>> text_file = make_text_file()
>>> # Copy the text file
>>> copy_file(text_file)
C:\Users\<username>\generated_text_file.txt'
Keywords

make text file, text_file, testfile, example file, make file, make, new file, new text_file, txt, new txt

Icon

las la-copy

automagica.activities.get_file_extension(file_path)

Get file extension

Get extension of a file

Parameters

file_path (input_file) – Path to file to get extension from

Returns

String with extension, e.g. ‘.txt’

Example

>>> # Create a new text file
>>> text_file = make_text_file()
>>> # Get file extension of this text file
>>> get_file_extension(text_file)
'.txt'
Keywords

file, extension, file extension, details

Icon

las la-info

automagica.activities.send_to_printer(file_path)

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 – Path to the file to print, should be a printable file

>>> # Caution as this example could result in a print from default printer
>>> # Create a new text file
>>> text_file = make_text_file(text = 'What does a robot do at lunch? Take a megabyte!')
>>> # Print the text file
>>> send_to_printer(text_file)
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 (input_file) – Path to the PDF (either relative or absolute)

Extension file_path

pdf

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(first_file_path, second_file_path, third_file_path=None, output_path=None)

Merge PDF

Merges multiple PDFs into a single file

Parameters
  • first_file_path (input_file) – Path to first PDF file

  • second_file_path (input_file, optional) – Path to second PDF file

  • third_file_path (input_file, optional) – Path to third PDF file, optional

  • output_path (output_file, optional) – Full path where joined pdf files can be written. If no path is given will write to home dir as ‘merged_pdf.pdf’

Extension first_file_path

pdf

Extension second_file_path

pdf

Extension third_file_path

pdf

Extension output_path

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 with itself for illustration, could also be different files
>>> merged_pdf = join_pdf_files(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 (input_file) – Path to the PDF (either relative or absolute)

  • start_page (int) – Page number to start from, with 0 being the first page

  • end_page (int) – Page number to end with, with 0 being the first page

  • output_path (output_file, optional) – Output path, if no path is provided same path as input will be used with ‘extracted’ added to the name

Extension file_path

pdf

Extension output_path

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')
>>> # 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 (output_dir) – Full path to store extracted images

Returns

Extracted images paths

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 (input_file) – Filepath to the document that will be watermarked. Should be pdf file.

  • watermark_path (input_file) – Filepath to the watermark. Should be pdf file.

  • output_path (output_file, optional) – Path to save watermarked PDF. If no path is provided same path as input will be used with ‘watermarked’ added to the name

Extension file_path

pdf

Extension watermark_path

pdf

Extension output_path

pdf

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 (int, optional) – 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 (bool, optional) – 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).

Options mem_type

[‘virtual’, ‘swap’]

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(file_path)

Show image

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

Parameters

file_path – Path to image

>>> # 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(file_path, angle=90)

Rotate image

Rotate an image

Parameters
  • file_path (input_file) – Path to image

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

>>> # 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(file_path, size)

Resize image

Resizes the image specified by the path variable.

Parameters
  • file_path (input_file) – 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.

>>> # 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(file_path)

Get image width

Get with of image

Parameters

file_path (input_file) – Path to image

Returns

Width

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(file_path)

Get image height

Get height of image

Parameters

file_path (input_file) – 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(file_path, box=None)

Crop image

Crops the image specified by path to a region determined by the box variable.

Parameters
  • file_path (input_file) – Path to image

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

>>> # 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(file_path)

Mirror image horizontally

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

Parameters

file_path – Path to image

>>> # 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(file_path)

Mirror image vertically

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

Parameters

file_path – Path to image

>>> # 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’

>>> # 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’.

>>> # 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 (string) – 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

>>> # 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(file_path=None)

Get text with OCR

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

Parameters

file_path (input_file) – 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 text file with some text to recognize
>>> testfile = make_text_file(text='OCR Example')
>>> # Open the text file
>>> 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 (string) – 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.

Options criteria

[‘first’, ‘last’, ‘random’]

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 text file with some text to recognize
>>> testfile = make_text_file(text='OCR Example')
>>> # Open the text file
>>> 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, delay=1)

Click on text with OCR

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

Parameters
  • text (string) – Text to find. Only exact matches are returned.

  • delay – Delay before clicking in seconds

>>> # Make a text file with some text to recognize
>>> testfile = make_text_file(text='OCR Example')
>>> # Open the text file
>>> 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, delay=1)

Double click on text with OCR

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

Parameters
  • text (string) – Text to find. Only exact matches are returned.

  • delay – Delay before clicking in seconds

>>> # Make a text_file with some text to recognize
>>> testfile = make_text_file(text='OCR Example')
>>> # Open the text file
>>> 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, delay=1)

Right click on text with OCR

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

Parameters
  • text (string) – Text to find. Only exact matches are returned.

  • delay – Delay before clicking in seconds

>>> # Make a text file with some text to recognize
>>> testfile = make_text_file(text='OCR Example')
>>> # Open the text file
>>> 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 (input_file) – path to the project file (as created within the UiPath Studio)

  • arguments (string, optional) – dictionary with input arguments/parameters for the process to use in UiPath (optional)

  • uirobot_exe_path (input_file, optional) – path to UiPath’s UiRobot.exe (optional)

Extension uirobot_exe_path

exe

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 (input_file) – path to the ‘.au3’ script file

  • arguments (string, optional) – string with input arguments/parameters for the script (optional)

  • autoit_exe_path (input_file, optional) – path to AutoIt.exe (optional)

Extension script_path

au3

Extension autoit_exe_path

exe

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

Alternative frameworks

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 (input_file) – path to the ‘.robot’ test case file

  • variables – dictionary with variable declarations

Extension test_case_path

robot

>>> # 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

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 (string) – name of the process in Blue Prism

  • username (string, optional) – Blue Prism username

  • password (string, optional) – Blue Prism password

  • sso (bool, optional) – Run as single-sign on user with Blue Prism

  • inputs (string, optional) – dictionary with inputs declarations (optional)

  • automatec_exe_path (input_file) – path to Blue Prism’s AutomateC.exe (optional)

Extension automatec_exe_path

exe

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

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 (input_file) – path to the task file of Automation Anywhere

  • aaplayer_exe_path (input_file) – path to the AAPlayer.exe (optional)

Extension aaplayer_exe_path

exe

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

General

automagica.activities.raise_exception(message='Exception', exception=<class 'Exception'>)

Raise exception

Raises an exception

Parameters
  • message – Message

  • exception (exception, optional) – Exception to raise

Type

string, optional

Keywords

sap, sap gui, sap client

Icon

las la-exclamation

SAP GUI

Portal

automagica.activities.create_new_job_in_portal(process_name, process_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 process. The bot performing this activity needs to be in the same team as the process it creates a job for.

Parameters
  • process_name (string) – name of the process

  • process_version_id (string, optional) – id of a specific version of the process, if not provided it will use the latest version (optional)

  • priority (int, optional) – priority level of the process. higher priority levels are performed first. (optional)

  • parameters – parameters for the process (optional)

>>> # Create a job in the Automagica Portal
>>> create_new_job_in_portal('My process')
Job 1234567890 created
Keywords

queueing, process, job, create job, new job

Icon

las la-robot

automagica.activities.get_credential_from_portal(credential_name)

Get a credential from the Automagica Portal

This activity retrieves a credential from the Automagica Portal.

Parameters

credential_name (string) – name of the credential

Returns

Credential

Example

>>> # Get a credential from the Portal
>>> print(get_credential_from_portal('My credential'))
'secretpassword'
Keywords

password, credential, portal, login, username

Icon

las la-key

Vision

automagica.activities.is_visible(automagica_id, delay=1, timeout=30)

Check if element is visible on screen

This activity can be used to check if a certain element is visible on the screen. Note that this uses Automagica Portal and uses some advanced an fuzzy matching algorithms for finding identical elements.

Parameters
  • automagica_id (automagica_id) – Element ID provided by the recorder

  • delay (int, optional) – Delay before checking visibility in seconds

  • timeout (int, optional) – Time before timeout (maximum time to wait) in seconds

Returns

True if visble, False if not

Example

>>> # Use the recorder to find an element ID
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> is_visible('qf41')
Keywords

click, visible, is visible, appear, computer vision, vision, AI

Icon

las la-eye

automagica.activities.wait_appear(automagica_id, delay=1, timeout=30)

Wait for an element to appear

Wait for an element that is defined the recorder

Parameters
  • automagica_id (automagica_id) – The element ID provided by the recorder

  • delay (int, optional) – Delay before waiting to appear in seconds

  • timeout (int, optional) – Maximum time to wait for an element in seconds

Returns

Blocks while element not visible

Example

>>> # Use the recorder to find the element ID to wait for
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> wait_appear('qf41')
Keywords

click, computer vision, vision, AI

Icon

las la-eye

automagica.activities.wait_vanish(automagica_id, delay=1, timeout=30)

Wait Vanish

This activity allows the bot to wait for an element to vanish.

Parameters
  • automagica_id (automagica_id) – The element ID provided by the recorder

  • delay (int, optional) – Delay before waiting for vanish in seconds

  • timeout – Maximum time to wait for an element in seconds

>>> # Use the recorder to find the element ID for the vanishing element
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> wait_vanish('qf41')
Keywords

wait, disappear, computer vision, vision, AI

Icon

las la-eye

automagica.activities.read_text(automagica_id, delay=1)

Read Text with Automagica Wand

This activity allows the bot to detect and read the text of an element by using the Automagica Portal API with a provided sample ID.

Parameters
  • automagica_id (automagica_id) – the sample ID provided by Automagica Wand

  • delay (int, optional) – Delay before reading text for vanish in seconds

Returns

Text

Example

>>> # Record an element to read with the recorder
>>> # Run the Windows calculator and try to perform the activity
>>> run('calc.exe')
>>> # Use the element ID found by the recorder, in this case ID 'qf41'. You can also view this on automagica.id/qf41
>>> #  If you have a vastly different version or layout the element might not be found, use the recorder
>>> read_text('qf41')
Keywords

click, computer vision, vision, AI

Icon

las la-eye