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.

// 1 
echo "1. Start screen recording : ";
echo $windows->start_video_record("d://record.avi");

// actions
// navigate to aol
// navigate to google
// navigate to msn

// 2 
echo "\n2. Stop recording video : ";
echo $windows->stop_video_record();

// open video file 

An example of a video recorded using start_video_record commands.

Using C # scripts in the Human Emulator

Using C # scripts in the Human Emulator.

There are two ways to work with a program using C # code.

  1. Writing scripts in C # in the program.
  2. Connecting separately written applications to the Human Emulator functionality.

Both methods use the XHE.dll library. The only differences are that when writing scripts in the program you do not need to connect the library, since it is already connected, and when creating separate projects you will need to connect this library.

XHE.dll library.

This dll library is a set of all objects and their functions that exist in the program.

A detailed description of the functionality of the objects can be found in our official documentation. The description for each function includes an example in C#.

The library was added to the program along with sources that are in the folder “folder with the program\Templates CSHARP\Lib\XHE\ XHE.sln“. The library sources are opened using Microsoft Visual Studio. If for some reason you need to make your changes to our library, you open the project in Microsoft Visual Studio, add your code there and then compile. The library connected to the Human Emulator is in the folder “folder with the program\Templates CSHARP\Lib\XHE\XHE\bin\Release\XHE.dll“. The main thing to note is that with the release of the new version, you will again have to reduce the library code, adding your changes to it. Whatever you do, you can send your code to us and we will add it to all subsequent versions of the program, but in this case your code will be available to all users of Human Emulator.

The library has been added to both “Human Emulator” (based on Internet Explorer) and “Human Emulator Studio” (based on Chromium) ranges. Work with the library in all versions of the program is completely identical. The differences are only in the available functionality.

Writing scripts in C # in a program.

To create a script in C # in the Human Emulator, just click on the File menu, point to New, and then click C# Script.

The “0.cs” script will open in the Scripts Editor with the following code:

#region using

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using XHE;
using XHE.XHE_DOM;
using XHE.XHE_System;
using XHE.XHE_Window;
using XHE.XHE_Web;


 class MyScript:XHEScript
	  static void Main(string[] args)
			// init XHE
			server = "";

			// go to google
			echo("Go to Google : "+browser.navigate(""));

			// exit

The first part of the script is used to allow the use of types in the namespace.

The second part is the script itself. The InitXHE function is the entry point for every the Human Emulator objects. This function is called before using any program object. Without this call, you cannot work normally with it. After calling this function, work is going on with objects. In this case, it is browser.navigate(“”) and app.quit ();.
When the script is executed, it is compiled into EXE file and this EXE file is launched. Exe itself appears in the folder with the script and later it can be run as a regular EXE file. The main thing is that at the same time the Human Emulator would be opened. In it all the actions prescribed in EXE file will be performed.

Connecting third-party projects to the Human Emulator functionality.

In this case, you connect the xhe.dll library to your project just like any other.

After that, all objects and functions for controlling the Human Emulator become available in your project.