select chapter

laiye rpa developer guide d1-乐游棋牌官网

almost all urls need to be prefixed with http://. http is an abbreviation of hyper text transfer protocol (hyper text transfer protocol), which refers to a hypertext transfer and communication protocol between a local browser and a web server. in other words, when we use a browser to access a website, we are essentially dealing with a remote web server through the http protocol.

in fact, it does not have to be a browser. as long as it follows the standard of the http protocol, other applications can also communicate with the web server. this is great! this shows that some webpage automation operations introduced in the previous chapter can be operated directly through the http protocol instead of the browser. this opens up a new idea for the automation of network operations.

there are two main types of http requests that are used more frequently: http get and http post. let's take a look at how to implement these two types of requests in laiye rpa. the first is the http get request. in the "http" directory of the "network" in the command center, select and insert a "get" command, which will create an http get request that points to a specific url. this command has four attributes, as shown in the figure below.


figure 35: get to get data

the "link address" attribute indicates the url of the http request, and the "form data" attribute is a string in json format, indicating the data to be sent for this http request. there are two sets of key-value pairs, namely "user" and "username", "password" and "12345678", as shown below.

{
  "user": "username",
  "password": "12345678"
}


the "timeout" attribute specifies the timeout time of the http request. if no data is returned after this time, the http request is considered to have failed. the "output to" attribute fills in a variable name that will hold the result of the http request, which is also a json-formatted string, as shown below. if you need to process the returned result, you can parse the json string based on the format of the returned result.

{
  "args": {
    "password": "12345678",
    "user": "username"
  },
  "headers": {
    "accept": "*/*",
    "accept-encoding": "gzip, deflate",
    "host": "httpbin.org",
    "user-agent": "python-requests/2.21.0"
  },
  "origin": "49.94.16.174, 49.94.16.174",
  "url": "https://httpbin.org/get?user=username&password=12345678"
}


in addition to the normal get request, the http get request can also download files through the http get request. this function is realized by the "get download file" command. this command has five attributes. the meaning of the four attributes "link address", "form data", "timeout", and "output to" is the same as the four attributes of the previous "get data" command, and the other one "file path" attribute fills in the save path of the downloaded file.


figure 36: get download file

let's take a look at how to implement http post request in laiye rpa. in the "http" directory of the "network" in the command center, select and insert a "post submission form" command, which will create an http post request that points to a specific url. this command has four attributes, as shown in the figure below.


figure 37: post submission form

the meanings of the attributes of "link address", "form data", "timeout time", and "output to" are the same as those of the "get" command. it should be noted that the "form data" sent by the http get request is related to the requested url, and it needs to be carefully checked with the relevant business personnel. the key-value pairs of the "form data" are carefully filled in correctly. similarly, the result returned by the http post request is also a string in json format, as shown below. if you need to process the returned result, you can parse this json string according to the format of the returned result.

{
  "args": {},
  "data": "",
  "files": {},
  "form": {
    "custname": "yzj",
    "custtel": "123456"
  },
  "headers": {
    ……
  },
  "json": null,
  "origin": "49.94.16.174, 49.94.16.174",
  "url": "https://httpbin.org/post"
}


in the automation of enterprise business processes, the automatic sending and receiving of emails is a very important part. in addition to automating the operation of the mail client or automatically logging in to the mailbox through a browser, laiye rpa also provides commands to directly send and receive mail through the smtp and pop3 protocols.

just like using gmail or outlook to send and receive mail, before using smtp and pop3 protocols to send and receive mail directly, you must log in to the mailbox to adjust some settings. here we will use the qq mailbox as an example. open the browser, log in to the qq mailbox, click the "settings" button and then click the "account" tab, find "pop3/imap/smtp/exchange/carddav/carddav service", click "on" in the "open service: pop3/smtp service" (the service is turned off by default). at this time, the qq email system will generate a password and save it. this password will be used in subsequent email receiving and sending operations instead of your original mailbox password.


figure 38: qq mailbox opens pop and smtp

then click "how to use foxmail and other software to send and receive mail?". as shown below, this help document contains the key settings of qq mailbox: pop server address is pop.qq.com, port number is 995, ssl is "yes"; smtp server address is stmp.qq.com, port number is 465, ssl is "yes". this information will be used in subsequent laiye rpa mail commands.


figure 39: qq mailbox setting information

let's take a look at the command to receive mail, the first step to connect to the mailbox. in the "smtp/pop" directory of the "network" in the command center, select and insert a "connect mailbox" command, which will use the pop protocol to connect to the specified mailbox and support subsequent operations for receiving mail.


figure 40: connect mailbox

the command has the following attributes: fill in the pop server address of the mailbox in the "server address" attribute, fill in the pop protocol port number in the "server port" attribute, and select "yes" in the "ssl encryption" attribute. these three settings have been obtained from the setting of qq mailbox in the previous step, where the server address is pop.qq.com and the port number is 995. fill in the mailbox account that needs to receive mail in the "mailbox account" attribute, fill in the email account password in the "login password" attribute, and the password has been generated in qq email in the previous step. then, fill in "pop3" in the "use protocol" attribute by default and fill in the variable name objmail in the "output to" attribute. this variable will save the mailbox object obtained after connecting to the mailbox, and use this mailbox object for subsequent commands such as reading the mail title, the body of the mail, and downloading the mail attachments.

after successfully connecting to the mailbox, you can receive the mail next. some of the mail collection operations supported in laiye rpa are: get the mail title, get the mail body, get the mail sender, get the mail address, get the mail time, and save the attachment.

in the "smtp/pop" directory of the "network" in the command center, select and insert a "get email header" command, which will get the mail header. this command has several attributes. in the "operation object" attribute, fill in objmail, which was obtained in the "connect mailbox" command. then, fill in which mail we need to read in the "mail serial number". here it contains "1", which means to read the first mail (the most recent mail). you can iterate through the mail in the mailbox by increasing the "mail serial number". fill in the name of a variable in "output to" attribute. the variable holds the result of the "get message header" command or the text information for the message header.


figure 41: get email header

several other mail collection commands, such as "get mail body", "get mail sender", "get mail address", and "get mail time", are similar to the "get mail header" command. most of their attributes are the same, with the exception of getting message information. however, the "save attachment" command is different from the other five commands. there is one less "output to" attribute and one more "save address" attribute. the "save attachment" command does not save the attachment to "output to" variable, but instead stores the attachment directly to the file address filled in the "save address" attribute.


figure 42: save attachment

in addition to receiving emails, laiye rpa also supports sending emails. in the "smtp/pop" directory of the "network" in the command center, select and insert a "send mail" command, which will use the smtp protocol to send an email to the specified mailbox.


figure 43: send email

the command has several attributes. fill in the smtp server address of the mailbox in the "smtp server" attribute, fill in the smtp protocol port number in the "server port" attribute, and select "yes" in the "ssl encryption" attribute. these three settings were obtained in the previous step of qq mailbox settings, where the server address is smtp.qq.com, and port number is 465. fill in the mailbox account that needs to be logged in in the "mailbox account" attribute, fill in the email account password in "login password" attribute, and the password in qq email has been generated in the previous step. fill in the "mailbox" attribute with the other party's mailbox account and the subject of the message to be sent. then, enter the body of the message to be sent. the "email attachment" attribute should contain the address of the attachment file to be sent. finally, the "output to" attribute returns whether the mail sending operation was successful: true on success, or false on failure.

laiye rpa provides some practical system commands, such as playing sounds, reading and setting environment variables, executing command lines and powershell, obtaining system and user folder paths, etc. these practical system commands can be used in conjunction with other commands to achieve unexpectedly good results. under "system operation" in the command center, select and insert a "play sound" command that plays the sound file with the specified file path. there is only one attribute of this command: "file path" attribute, which filled in the complete file path of the sound to be played. currently, laiye rpa only supports sound playback in wav format.


figure 44: playing sound

in the "system" directory of "system operation" in the command center, select and insert a "read environment variable" command, which can read the environment variables of the windows operating system. there are two attributes of this command. in the "environment variable" attribute, fill in the name of the environment variable, and in the "output to" attribute, fill in a variable name. this variable will save the value of the environment variable read out. it should be noted that the "read environment variable" command can only read one variable at a time. if you need to read the values of multiple environment variables, you can call this command multiple times. in addition, the text format of the read environment variables is completely consistent with the text format of the environment variables in the operating system. if you need to further parse the text of the environment variables, please consult the relevant documentation. the usage of the "set environment variable" command is similar to the "read environment variable" command and will not be explained here.


figure 45: reading environment variables

in the "system" directory of the "system operations" in the command center, select and insert an "execute command line" command, which can execute windows scripts. the command has two attributes. in the "command line" attribute, fill in the to be executed windows script, and in the "output to" attribute, fill in a variable. this variable saves the execution result of the script. for the writing of windows scripts, please refer to the relevant documents.


figure 46: execute command line

in the "system" directory of "system operations" in the command center, select and insert a "get system folder path" command. this command can get the path of each system folder. the command has two attributes. for "get directory", laiye rpa currently supports the acquisition of the following paths: system directory, windows directory, desktop directory, software installation directory, and start menu directory. in the "output to" attribute, fill in a variable, this variable saves the execution result of "acquisition of system folder path" command, which is the last path obtained.


figure 47: get the system folder path

the commands "get temporary folder path" and "get user folder path" are similar to the "get system folder path" commands, and will not be explained here.

in addition to simulating human operation of the application through the interface, laiye rpa can also directly manage the life cycle of the application, start the application, close the application, and obtain the status of the application. in the "application" directory of the "system operation" in the command center, select and insert a "start application" command. this command can start an application. this command has several attributes. in the "file path" attribute, fill in the application to start the file path. the "waiting mode" attribute refers to the waiting relationship between the system and the application. laiye rpa provides three waiting modes: "do not wait", "wait for application ready", "wait for application execution to exit". "do not wait" means that the target program starts immediately and the command is completed. "waiting for the application is ready" means that the application is only started when the application is ready, otherwise the system will always wait. "wait for application execution to exit" means that after the application is started, the system will wait until the application exits, the command will be executed; the "display style" attribute refers to the way in which the application is displayed when it starts, supported by laiye rpa. the display styles are: "default", "maximize", "minimize", "hide". "default" means that the application is started in the default display mode. "maximize" means that the application window is maximized at startup. "minimize" means that the application window is minimized at startup, and "hide" means the application window is not displayed at startup. finally comes the "output to" attribute, fill in a variable that saves the pid of the application after startup, and this pid will be used in subsequent commands.


figure 48: start the application

the "start application" command opens an application, but some scenarios require not only the application to open, but also the application to open a file or url. at this time, the "open file or url" command can be used. several attributes of this command are almost the same as the "start application" command. the only difference is the "file path" attribute, fill in the file or url to be opened here.


figure 49: open file or url

after starting the application through the "start application" command or the "open file or url" command, we can always check whether a specific application is still running while the process is running. select and insert a "get application running status" command, which can determine whether a process is active based on the process name or pid. there are two attributes of this command. the "process name or pid" attribute requires the process name or pid of the application. if you fill in the pid, it is the pid obtained from the "output to" attribute of the last "start application" command. if you fill in the process name, you should also fill in the full file name of the application. for example, the process name of the last "start application" command is "notepad.exe"; the "output to" attribute saves the execution result of the command, which is a boolean value. true indicates the process is still alive; false means the process has been shut down.


figure 50: get the application running status

finally, do not forget to close the application. select and insert a "close application" command, which can close a process based on the process name or pid. there is only one attribute of this command: "process name or pid" attribute, fill in the process name or pid of the application to be closed. the meaning is the same as the attribute of the same name of the "get application running status" command.


figure 51: close the application


during the operation of the rpa process, generally no human intervention is required. however, in some scenarios, the process requires two-way information communication between people. on the one hand, the key information of the process is notified to people; on the other hand, the control and decision information of people is obtained. the powerful laiye rpa provides a dialog box mechanism, which can print out key process information or show a dialog box to allow users to make selections and input, realizing the two-way information communication between process and people.

in the "dialog" directory of "system operations" in the command center, select and insert a "message box" command, which will pop up a message box in the middle of the screen during the process.


figure 52: message box

this command has several attributes. the "message content" attribute fills in the message content body, the "dialog title" attribute refers to the title bar of the pop-up dialog, and the "button style" attribute refers to which buttons are displayed in this dialog. the options for the "button style" attribute are: "only show ok", "show yes and no buttons", "show abandon, retry and skip buttons", "show yes, no and cancel buttons", "show retry and cancel button", "display confirmation and cancel button". you can choose the "button style" attribute reasonably according to particular business needs.


figure 53: message box settings

the "icon style" attribute specifies what icons are displayed in the dialog box. the options are: "don't display icon", "display message icon", "display query icon", "display warning icon", "display error icon". reasonably select the icon for the business scenario; the "timeout" attribute refers to how many milliseconds later the dialog box is forced to close. for example, fill in 5000, which means that after 5000 milliseconds. even if the user does not click any button of the dialog box, the dialog box will be forced to close. if the "timeout" attribute is filled with 0, it means that the timeout period is not used; that is, the user must click the dialog box, or the dialog box will disappear; the "output to" attribute fills in a variable, which will be changed after the user clicks the dialog button and it will record which button the user clicked. the following flow operation logic can choose different flow directions according to which button the user clicks. the values of the buttons are as follows:

button value

button meaning

1

ok

2

cancel

3

give up

4

retry

5

skip

6

yes

7

no


the "message box" command is a very powerful command. the user can fill in the content, title, button style, or icon style of the message box according to their needs. however, sometimes such a complicated dialog box is not needed, and a simple message notification can pop up. in this case, you can use the "message notification" command. the "message notification" command is also located in the "dialog" directory of the "system operation" in the command center. this command will pop up an operating system notification message in a bubble.

the "message notification" command has several attributes. "message content", "dialog title", and "dialog icon" have the same meaning as the "message box" command. it should be noted that the "message box" command generally stays for a few seconds before disappearing, but if the process ends, the message box that pops up in the process will also disappear. you can follow the "message box" command with a "delay" command. a delay of a few seconds allows users more time to view the message box.


figure 54: message box settings

the "message box" command and the "message notification" command realize the process of delivering messages to the user. although the "message box" command can get "which button the user clicks" to complete part of the user's function of delivering messages to the process, it is very limited. what if the user wants to deliver more information to the process? laiye rpa provides the "input dialog" command, which pops up a dialog where the user can enter information that needs to be passed, which will be passed into the process.

let's take a look at the specific usage of the "input dialog" command. the meaning of the "message content" attribute and the "dialog title" attribute is the same as the "message box" command; the "default content" attribute is a prompt message to the user. if the user does not modify it, the content in the "default content" attribute will be passed to the process. the "number only" attribute is a boolean value: "yes" indicates that the user can only enter numbers and "no" indicates that the user input is not limited, so the user can enter any character. the "output to" attribute requires a variable. when executed, the user's input information will be saved in this variable, and subsequent processes can use this variable, which opens up the channel for the user to enter the process.


figure 55: input dialog

in addition to supporting user input text, laiye rpa also supports user input files. insert an "open file dialog" command, which can pop up an "open file dialog" during the process of running. the user selects the file, and passes the file path to the process. this command has several attributes. the "initial directory" attribute refers to which directory is opened by default when a dialog box is popped up. we can click the folder button to the right of the "initial directory" attribute to select the initial directory. if the initial directory is not selected (i.e. the the default value of the attribute is "") or the selected initial directory does not exist, laiye rpa will open a default directory as the initial directory. the "file type filter" attribute is a string that indicates which types of files can be opened in this dialog box. for the writing of the file filter, please refer to the relevant documents. the meaning of the "dialog title" attribute is the same as other dialog box commands. fill in a variable in the "output to" attribute. when the command is executed, the full path of the file selected by the user will be saved in this variable, that is to say, the "open file dialog" does not "open" the file, and it is to get the file path. this variable can be used in the subsequent process, so as to open up the channel for user input to the process.


figure 56: open file dialog

the "open file dialog [multiple selections]" and "save file dialog" commands are similar to the "open file dialog" command. the "open file dialog [multiple selections]" command can select multiple files. this command returns to an array of file paths, and users can traverse the array to process each file in turn. we will not explain them here.

the operation of the clipboard is a very practical function, which is used to move text and images from one system to another. in addition to using variable storage, using the clipboard is also a common usage. in the "clipboard" directory of "system operations" in the command center, select and insert a "set clipboard text" command, which sets a section of text to the clipboard. this command has only one "clipboard content" attribute. and this attribute fills in the text content to be set in the clipboard.


figure 57: setting clipboard text

we can then insert a "read clipboard text" command to see if the last "set clipboard text" command was successful. the "read clipboard text" command also has only one attribute---the "output to" attribute. after running this command, the variable sret filled in the attribute will save the text in the clipboard. add an "export debugging information" command and output sret to see if the settings and reading clipboard text are executed successfully.

in addition to transferring text via the clipboard, the clipboard can also transfer images. in the "clipboard" directory of "system operations" in the command center, select and insert a "picture set to clipboard" command, which sets an image file to the clipboard. this command has only one "file path" attribute. this attribute fills in the path of the image file to be set to the clipboard.


figure 58: picture settings to clipboard

we can insert a "save clipboard image" command to see if the last "picture set to clipboard" command was successful. "save clipboard image" command has only one "save path" attribute. this attribute fills in the save path of the image file in the clipboard.


figure 59: saving the clipboard image

the text writing screen is a very intuitive and practical tool command. when running, the log and other information cannot be seen. by writing the text on the screen, whether it is an rpa operation with a maintenance engineer, an end customer, or a record screen software, it can be seen directly. in the "system operation" in the command center, under the "text writing screen" directory, select and insert a "create screen writing object" command, which will create a screen writing object.


figure 60: create screen writing object

this command has three attributes. "write screen area" is a json string that indicates which area of the screen the text is written on. it is okay if users do not entirely understand this string. click the range selection button on the right side of the writing screen area. at this time, the interface is covered with a layer of curtain. laiye rpa will automatically help you choose the screen writing area. for example, the area we just selected is based on the 768×1366 resolution. the starting point coordinates (upper left corner) are (312, 174), the height of the screen writing area is 346, and the width is 598. the units are pixels. the "adaptive" attribute is a boolean value that indicates whether the writing screen area automatically adapts to changes in resolution. true means that the "writing screen area" attribute will automatically adapt to changes in resolution. false means the "write the value of the screen area" attribute is strictly used to write the screen. the "output to" attribute fills in the write screen object objwindow, and subsequent operations will use this screen write object.

{
  "height": 346,
  "resolution": {
    "height": 768,
    "width": 1366
  },
  "width": 598,
  "x": 312,
  "y": 174
}



figure 61: setting the screen writing area

after creating the screen writing object, you can use this screen writing object to draw text. select and insert a "draw text" command, which will write a piece of text on the screen. this command has four attributes. the "write screen window object" attribute fills in the write screen object objwindow, the "display content" attribute fills in the text content to be displayed, the "text size" fills in the font size of the text, and "text color" fills in the rgb of the text color, where [255,0,0] represents red, [0,0,255] represents blue, and [255,255,0] represents yellow. for the relevant knowledge of rgb colors, please refer to the relevant tutorial.


figure 62: draw text

if we need to write the screen multiple times, the write screen object objwindow can be used repeatedly. after the last "draw text" command, add a "draw text" command. the two "draw text" commands differ only in the "display content" attribute. after running, i found that the text displayed in the last "draw text" command did not disappear. it turns out that laiye rpa does not erase the screen writing content of the last "draw text" command by default. if you want to erase the screen writing text, you need to use the "clear text" command. the "clear text" command has only one "write screen window object" attribute. this attribute has the same meaning as the "write screen window object" attribute of the "draw text" command. just fill in objwindow.

run the process again, this time the content of the previous text is erased, but the time of the text display is too short. the original laiye rpa commands are all executed in real time. if text needs to stay on the screen for a period of time, here is a small trick: insert a "delay" command between the "draw text" command and the "clear text" command.

finally, remember that after all screen writing operations are completed, you must add a "close window" command. this command corresponds directly with the "create screen writing object" to release the objwindow object created by the "create screen object" command.