You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Usage.py

101 lines
2.8 KiB

###############################
#Technology GUI
###############################
#Init UIDesktop
from pyOpenRPA.Robot import UIDesktop
#Selector: Folder list (framework uia)
lGUISelectorFolderList = [
{"class_name":"CabinetWClass","backend":"uia"},
{"ctrl_index":2},
{"ctrl_index":0},
{"ctrl_index":2},
{"ctrl_index":0}
]
#Highlight the list in folder app (uia framework)
UIDesktop.UIOSelector_Get_UIO(lGUISelectorFolderList).draw_outline()
#Print the children list
print(UIDesktop.UIOSelector_Get_UIO(lGUISelectorFolderList).children())
#Right click
UIDesktop.UIOSelector_Get_UIO(lGUISelectorFolderList).right_click_input()
###############################
#Technology Selenium
###############################
#Init the selenium driver
import os
#Add chrome webdriver to PATH system enviroment (need to selenium)
os.environ["PATH"]=os.environ["PATH"]+";C:\\Abs\\Archive\\scopeSrcUL\\OpenRPA\\Resources\\SeleniumWebDrivers\\Chrome\\chromedriver_win32 vchromedriver_win32 v79.0.3945.36\\"
#Import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
#Open URL
driver.get("http://www.python.org")
#Find the search input
elem = driver.find_element_by_name("q")
#Type text in search imput
elem.send_keys("pycon")
#Submit the search
elem.send_keys(Keys.RETURN)
#Close the driver
driver.close()
###############################
#Technology Image & Mouse
###############################
#https://pypi.org/project/PyAutoGUI/
import pyautogui
lScreenPath = "Path\\to\\image.png"
#Search image on screen
buttonx, buttony = pyautogui.locateCenterOnScreen(lScreenPath) # returns (x, y) of matching region
#Moucse click on X:buttonx Y:buttony
pyautogui.click(buttonx, buttony)
###############################
#Technology Keyboard & Clipboard
###############################
#https://pypi.org/project/keyboard/
import keyboard
#Write a text (selected language dont affect)
keyboard.write('The quick brown fox jumps over the lazy dog.')
# Blocks until you press esc.
keyboard.wait('esc')
# Record events until 'esc' is pressed.
recorded = keyboard.record(until='esc')
# Then replay back at three times the speed.
keyboard.play(recorded, speed_factor=3)
#Add hotkey
keyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey'))
###############################
#Technology Message boxes
###############################
#https://pypi.org/project/PyAutoGUI/
import pyautogui
#Show alert message box
pyautogui.alert('This is an alert box.')
#Ask a question (Yes/No)
pyautogui.confirm('Shall I proceed?')
#Ask a question with answer options
pyautogui.confirm('Enter option.', buttons=['A', 'B', 'C'])
#Ask a question with text answer
pyautogui.prompt('What is your name?')
#Ask a password (password will be hidden)
pyautogui.password('Enter password (text will be hidden)')