Launching Human Emulator Studio from the command line.

Launching Human Emulator Studio from the command line.

Command line options in Human Emulator Studio.
/port: “port” – indicates on which port the program is launched to receive control commands. If this parameter is not specified, the port is taken from the port.txt file in the Settings folder of the program. The port can be from 1 to 65535. For example, the /port: “7010” parameter – sets the port 7010 on which the program is running.

/script: “path to the script” – with the help of this parameter we specify which script to run in the program for execution. If the path to the script is not specified, the program is launched without executing the script. The path must be absolute, that is, for example: “C:\XWeb\Human Emulator Studio\My Scripts\1.php

/script_args: “space separated arguments” – arguments to be passed to the script being run. This parameter is used to pass any data to the script. For example, we pass: “7010 ‘1.txt’ 5″. All these values ​​will be placed in the array $argv[], that is, $argv[1] = 7010, $argv[2] =’1.txt’, and $argv[3] = 5. In this case, always $argv[0] = “path to the running script”, if the path is not specified then $argv[0] will be empty. The /port: parameter tells the whole program on which port to run, and to run the script, the port must be passed through the /script_args: parameter.

/browser_command_line: “space separated commands” – command line arguments for the Chromium browser. For example: /browser_command_line: “- disable-gpu —disable-headless-mode”. A list of available commands can be found here https://peter.sh/experiments/chromium-command-line-switches/.

/settings_folder: “path to folder” – path to the folder with settings. By default, all settings are stored in the Settings folder, which is located in the program folder. Using this parameter, you can specify a folder with settings for the program from anywhere. The path must be absolute, that is, for example: “C:\XWeb\Human Emulator Studio\Settings1

/cookies_folder: “path to the cookie folder” – set the path to the cookie folder. The path must be absolute, that is, for example: “C:\XWeb\Human Emulator Studio\7010\cookies_1

/cache_folder: “path to the cache folder” – set the folder to the cache folder. This is an obsolete parameter, since the cache folder is currently automatically placed inside the cookie folder.

/ask_port: “true” or /ask_port: “1” or /ask_port: “yes” – when starting the program, do not ask questions about switching to the next free port, if the current port is busy, then simply do not start the program.

/in_tray: “1” or /in_tray: “true” or /in_tray: “yes” – when launching, hide the program to the tray (system tray).

/hide_tray_icon: “1” or /hide_tray_icon: “true” or /hide_tray_icon: “yes” do not show the icon in the system tray (system tray).

/as_unicode: “1” or /as_unicode: “true” or /as_unicode: “yes” – the script is run in unicode format.

from version 7.0.44

/password: “psw” – to set the Password at startup setting.

/browser: “Chromium” or /browser: “Firefox” – select the browser model in which the script will be executed.

from version 7.0.47

/default_profile_path: “path” – to set the path to the default profile file.

from version 7.0.52

/decode_script_password: “password” – to pass the password when running the encoded script.

If the above parameters are not specified when starting the program from the command line, then the values ​​are taken from the program settings or take the default values.

Run the program from the command line.

How to run a program with command line parameters.

There are many ways to run with command line parameters. Consider the following:

Option 1 through a shortcut on the desktop.
Option 2 via a .bat file.

Desktop shortcut.

To do this, create a shortcut on the desktop, and then specify the command line launch parameters in the shortcut settings.

Our command line will be as follows:

/port: “7010” /script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args: “7010 ‘1.txt’ 5 “

Php script code to run from the command line:

After starting the program through this shortcut, the 1.php script will run and the following information will be displayed in the debug window:

Now, every time you run through this shortcut, we will run a script with the parameters specified in it.

Batch file

Batch file (.bat) are ordinary text files containing a set of commands and having the .bat extension. Any text editor will do for editing such a file. In this case, if you double-click on the file, then it will not open in the editor, but will execute the commands written in it.
In our case, we will register in this file the launch of the Human Emulator Studio program and pass command line parameters to it.

So, let’s run the program with the following command line /port: “7012” /script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args: “7012 ‘2332.txt’ 1123 ″. For clarity, we will run the program on port 7012 and use other arguments in this case.

Create a batch file and add the following line to it:

start “XHE Studio” “C:\XWeb\Human Emulator Studio\XWeb Human Emulator Studio.exe” /port: “7012” /script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args : “7012 ‘2332.txt’ 1123 ″.

The script will run the same one that was launched through the shortcut.

After starting the file, the program will open with the launch of the 1.php script for execution. After running the script, the following information will be displayed in the debug window:

Unlike a shortcut using a bat file, you can run several programs at once if you have a multi-threaded version of Human Emulator Studio.

In this case, our bat file will be like this:

start “XHE Studio” “C:\XWeb\Human Emulator Studio\XWeb Human Emulator Studio.exe” / port: “7012” / script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args : “7012 ‘2332.txt’ 1123 ″.
ping -n 2 localhost> nul
start “XHE Studio” “C:\XWeb\Human Emulator Studio 7011\XWeb Human Emulator Studio.exe” /port: “7011” /script: “C:\XWeb\Human Emulator Studio 7011\My Scripts\2.php” /script_args: “7011 ‘file.txt’ 123121 ″
.

Based on the results of the script, two programs will be launched and each of them will execute its own script.

You can read more about batch files and the commands they use here https://sysadmin.ru/docs/bat.

Record user actions in the Human Emulator Studio browser using the Macros

User actions record using tool the Macros

In the article we in detail explain how you can use the Macros in the Human Emulator Studio.

One of the first tools built into the program, which was added to simplify the creation of scripts, is the Macros.

How does it work?

When you enable the Macros, your actions in the browser are recorded, such as going to pages in the browser, all possible clicks on elements, and entering data in various browser fields. In this case, there are two modes of operation, this is when all actions are recorded via mouse control or using functions for working with individual objects.

Configuring the Macros

Before you start recording, you need to configure the Macros. The Macros settings are located in the General settings of the program, the Macros tab.

Now let’s go through all the settings.

Add focus by click — when you select this check box, the focus command will be added to each of your clicks.
Add mouse move to click — when you select this check box, the send_mouse_move command will be added to each of your clicks.
Add pause to click — if you select this check box, the sleep(1) command will be added after each click, i.e. wait for one second.

In other words, when you select these settings, your code will look like this:

without selecting these settings like this:

Check boxes Full mouse emulation and Full keyboard emulation. When you select these check boxes, functions will be substituted that fully emulate mouse movements and keyboard input to the active window. When script run in full emulation mode you will not be able to use your computer or work in multithreaded mode, as any actions with the mouse cursor or using the keyboard may interfere with the script.

In the script code it will be like this:

and

instead of

The group of radio button Catch events. In this group, exhibited the device of the action which will be to record a Macros.

When you select the Mouse, all actions in the script will be recorded as actions with the mouse.
In the script it will be written like this:

When you select the Keyboards option, all input actions will be recorded via the $keybord object
in the script, this will be

If the item Click on elements is selected, then writing to the script will go through the objects of these elements.
In the script :

The radio button group Create function. Responsible for the priority parameter with the program define the element to work with. By default, the item is selected Auto, in other words, the item is determined by the first available parameter, starting with the item ID and ending with the item number.

The check box Create new script. If you select this check box, a new script will be created when you start recording the Macros and all actions will be recorded in this script. If the check box is removed, then the entry will go to the current script, in the place where the carriage is installed in the editor.

Start the Macros

Use the Actions menu to enable the Macros.

Press menu item Start Record or use hotkey Ctrl+Shift+R.

Create simple script using the Macros.

Now let’s write a simple script. In built-in bowser enter google.com and press Go.

Turn on the Macros using menu item Start Record. Enter phrase human emulator in the Google search field. Press Enter. Click on the first link in the output. Turn off the Macros using menu item Stop Record. And we have the script like as:

Slightly change the Macros settings and disable the check boxes with focus, mouse movement and pause. And instead of Enter, press the Google search button.
We get the script like as:

Features of working with the Macros.

As it is not difficult to notice, the work in the Macros goes through the Dom Interface of objects. That is when you get the element itself you can do various actions with it such as:

Actions with an element
click – click on an element
meta_click – focus, move the mouse to the element at random coordinates, and click
event – send an event to the element
check – check the element
focus – set the input focus on the element
scroll_to_view – scroll the page so that the element is visible (via java script)
ensure_visible – scroll the page so that the element is visible (via scrolling)
scroll – scroll the element
screenshot – take a screenshot of an item

Change an item
set_value – set a value
set_inner_text-set internal text
set_inner_html-set internal htmlml
add_attribute – add an attribute
set_attribute – set an attribute
remove_attribute – remove an attribute

etc.

And all these actions can be performed with any element, be it a anchor or a button. You can also get a page element as an interface using the same functions for all page elements:

Getting the DOM interface
get_by_number – get the DOM interface by number
get_by_name – get the DOM interface by name
get_by_id – get the DOM interface by id
get_by_inner_text – get the DOM interface by internal text
get_by_inner_html – get the DOM interface from internal html
get_by_outer_text – get the DOM interface from external text
get_by_outer_html – get the DOM interface from external html
get_by_href – get the DOM interface by href
get_by_alt – get the DOM interface by alt
get_by_src – get the DOM interface by src
get_by_value – get the DOM interface by value
get_by_attribute – get the DOM interface by attribute value
get_by_properties – get the DOM interface by the value of several properties
get_by_xpath – is to obtain the DOM interface by its XPath

In other words, as in other functions, we work with page elements by several parameters, such as name, id, sequence number, and so on. All this can be viewed through the element inspector or use the same context menu.

Use of macros.

The macros is useful when you need to write simple scripts or some parts of scripts, when you can’t define some elements with other tools. At the same time, you should understand that the scripts recorded by the Macros will still have to be edited, since we use the Macros to record actions with page elements. You can add commands that are not related to page elements using another tool, the code Helper.

Browsers built into Human Emulator Studio.

Browsers built into Human Emulator Studio.

All automation actions that are specified using commands in scripts are performed in the browser built into the program. The main browser in Human Emulator Studio is Chromium. It was on the basis of this browser that the first version of the program was made. Later, other browsers were added to the program, and currently the following browsers Chromium, Chromium (Compact), Chromium (Offscreen), Firefox (beta) and Chrome Selenium WebDriver (alpha) were built into the program.

The browser model can be selected using the settings dialog, the Browser tab, the Browser Model drop-down list.

or using the command of object browser set_model

php usage example:

options:

  • Chromium
  • Chromium (Compact)
  • Chromium (Offscreen)
  • Firefox
  • Chrome Selenium WebDriver

The same options can be used when working with the program through the command line in the command line parameter /browser: “XXX”.

Chromium Browser.

The Chromium browser is an open source project that allows its source code to be used in other products, which is why many browser applications and browsers use Chromium as the basis. This also applies to the Human Emulator Studio program, as well as browsers such as Google Chrome, Yandex.Browser, the latest versions of the Opera browser, the new Internet Explorer, etc. The differences between these browsers from each other is only in their additional functions added to the Chromium browser.

Chromium updates come out quite often, and as soon as a new stable version of Chromium appears, our developers implement it in the program, so in the latest versions of Human Emulator Studio, as a rule, the last stable Chromium is introduced. You can view the current version of the program by going to the chrome://version/ information page in the program.

Chromium (Compact).

From the version of Human Emulator Studio 7.0.47, the Chromium (Compact) browser model has been added. This is the same Chromium browser operating in a special mode in which the browser consumes less RAM, but loads a little more CPU. This is achieved through the use of WPF, which is based on a vector visualization system that does not depend on the resolution of the output device and is created taking into account the capabilities of modern graphics equipment. The graphic technology underlying WPF is DirectX.

Chromium (Offscreen).

From the version of Human Emulator Studio 7.0.48, the Chromium (Offscreen) browser model has been added. This is the same Chromium browser working in a special mode in which the browser does not draw the pages that are opened. That is, you simply will not see the page, although the program itself will work with it without problems.

In this mode, the browser works faster and consumes less memory, since it does not render anything on the real screen, including huge pictures by weight and other heavy elements. When working in this mode, there are restrictions on the use of a real mouse and keyboard; they do not work on a hidden browser. You can also take screenshots of only the visible part of the browser, but this can be easily solved by setting the size of the browser. Otherwise, there are no restrictions when working in this mode.

These two Chromium models were added to the program to optimize memory handling.

Firefox Browser.

Since version Human Emulator Studio 7.0.44, the Firefox browser has been added to the program. This is a free browser on the Gecko engine, developed and distributed by Mozilla Corporation. This browser is currently in beta mode. This means that almost all the functionality existing in the program is supported by this browser and it can be used to automate your tasks on a par with other browser models available in the program.

To work in this browser, select it in the program settings. The number of the built-in version can be viewed by going to the about: config page in the program browser and finding the fields containing the version word.

Chrome Selenium WebDriver Browser.

Since Human Emulator Studio 7.0.44 in alpha mode, an experimental model of the Chrome Selenium WebDriver browser has been added. Essentially, it’s controlling the Chrome browser installed on your computer using Selenium WebDriver. This browser model currently supports only the basic functionality of the program.

Selenium WebDriver is the software library of the Selenium project, with which you can control the behavior of the browser. This project is mainly used for testing sites or online services and their individual elements. Working in this mode does not guarantee anonymity, but since WebDriver works with real Chrome, it can help to solve some problems that for some reason do not work in other browsers built into the program.

When working in this mode, a separate Chrome browser window is launched, in which all actions are performed. In this case, Human Emulator Studio broadcasts this window.

In this browser, you can use program tools such as the Element Inspector and the Elements Tree to work with the HTML elements of the page open in the browser.

To exit this mode, you need to select a different browser model in the program settings.

To discuss on the forum

Anonymity in Human Emulator Studio. Managing embedded browser information.

Anonymity in Human Emulator Studio. Managing embedded browser information.

Human Emulator Studio has the ability to change a wide range of settings. All browser settings and other commands for managing the browser can be found in the documentation for the object – browser. This article will talk specifically about changing those settings that contain information about the browser.

Browser sizes.

The width and height of the browser are set using the commands set_width and set_height of the object browser.

php example:

The scale of the browser.

You can set the browser scale using command set_zoom of the object browser.

php example:

Screen resolution and color depth.

Screen resolution and bit rate are set by one command of the object browser set_screen_resolution. Defines navigator: (width, height, pixelDepth) and their duplicates (availWidth, availHeight, colorDepth).

php example:

Useragent string.

To set the Useragent string or the so-called browser identifier, the object browser command set_user_agent is used. Together with the browser identifier, you must fill in the following navigator parameters (window.navigator): appVersion, appName, appCodeName, language (s), platform, product, productsub.

php example:

Information about the plugins.

Substitution of the list of plugins preinstalled in your browser is carried out using command set_plugins_info of the object browser.

Obtaining this information is included in the so-called browser fingerprints. Using this technology, the site owner can get your unique profile as a user and then determine all your subsequent visits and actions. We’ll talk about browser fingerprints in a separate article.

The list of plugins is given as a string:

«[{ name : ‘plugin name 1’, description : ‘plugin description 1’, filename : ‘plugin file 1’, version : ‘plugin version 1’ },
{ name : ‘plugin name 2’, description : ‘plugin description 2’, filename : ‘plugin file 2’, version : ‘plugin version 2’ },
{ name : ‘plugin name 3’, description : ‘plugin description 3’, filename : ‘plugin file 3’, version : ‘plugin version 3’ },
{ и т.д.}]»

From version 7.0.41, you can also specify a Mime list for plugins. Set as a string:

«[{type: ‘type’, suffixes: ‘suffixe’, description: ‘description’, __pluginName: ‘ plugin name 1′ },
{type: ‘type’, suffixes: ‘suffixe’, description: ‘description’, __pluginName: ‘ plugin name 2′ }
{type: ‘type’, suffixes: ‘suffixe’, description: ‘description’, __pluginName: ‘ plugin name 3′ }
{type: ‘type’, suffixes: ‘suffixe’, description: ‘description’, __pluginName: ‘ plugin name 3′ } ]»

php example:

You can view information on a real plug-in by installing them in the Chrome browser, and then through the Developer Tools (press F12) go to the console and there enter “navigator.plugins“. Information on the plugins appears as follows:

Hardware Information.

To set the parameters navigator hardwareConcurrency – the number of processors (threads) that are available to the browser and deviceMemory – the number of gigabytes of memory that are available to the browser using the object browser command set_hardware_info.

Also, from version 7.0.42, this command can also be used to set the devicePixelRatio parameter. DevicePixelRatio returns the ratio of resolution in physical pixels to resolution in CSS pixels for the current display device. This value can also be interpreted as the ratio of pixel sizes: the size of one CSS pixel to the size of one physical pixel. Simply put, this tells the browser how many actual pixels on the screen should be used to draw one pixel of CSS.

The parameter depends on the device: for ordinary displays it is 1, but there can be 2 and 1.5

php example:

Do Not Track (DNT).

This is the proposed HTTP header field, designed to allow Internet users to opt out of web site tracking, which includes collecting data about user activity in several different contexts, as well as storing, using or sharing data received from this activity outside the context in which it occurred.

To set this flag, use the object browser command set_do_not_track.

php example:

Touch screen.

You can set data about the used touch screen using the object browser command set_touch_info. The command changes the parameters of navigator.maxTouchPoints – the maximum number of simultaneous touch contacts and window.ontouchstart – whether touch events are enabled.

php example:

discuss the article on the forum

Record video in the Human Emulator

Record video in the Human Emulator Studio.

In the version of Human Emulator Studio 7.0.38, several interesting commands appeared that we would like to draw the attention of users to.

These are the start_video_record and stop_video_record commands added to two objects – windows and browser. Commands added to the object – windows – record video from a given area of the screen, commands added to the object – browser record video from a specified area of the browser.

How it works?

When you start recording video, the program performs the specified number of screenshots-frames per second with the specified quality, after which a file is created with the recording in avi format.

Description of the commands.

The start_video_record command accepts the following parameters:

path – full or relative path to the video file.
fps – is the number of frames per second. So with fps = 10, 10 frames per second will be done, and with fps = 30, 30 frames per second or 1 frame in 33 milliseconds. The optimal FPS value will depend on how quickly actions take place in the recorded area. To record normal browsing, fps = 10 will be enough. Default: 10.
quality – JPEG image quality. Maximum quality 100%. Image quality is understood as the amount of useful data that JPEG can save. Default: 70.
x – X coordinate of the upper left corner of the recorded area. Default: -1.
y – Y coordinate of the upper left corner of the recorded area. Default: -1.
width – the width of the recorded area. Default: -1.
height – the height of the recorded area. Default: -1.

With x = -1, y = -1, width = -1, height = -1 – the entire area of the screen or the built-in browser is recorded.

The stop_video_record command does not require any parameters. After calling this command, a record avi file will be created.

An example of use in php.

An example of a video recorded using start_video_record commands.