Autoclicker is a program that records all actions related to mouse and keyboard control and then reproduces all these actions automatically. Accordingly, an autoclicker for a browser is a program that repeats the necessary actions in the browser.
All versions of the program have all the necessary tools for recording and controlling the keyboard and mouse. For recording, the Macros tool is used, which records your actions in the browser built into the program.
Macros.
Working with Macros is described in the article User actions record using tool the Macros. This work is identical in all versions of the program. The only thing is that to write an autoclicker, you will need to select the Full mouse emulation and Full keyboard emulation checkboxes in the Macros settings. In this case, a real keyboard and mouse will be used.
Keyboard simulation.
To control the keyboard, the keyboard object has been added to all versions of the program. This object provides complete control over all keyboard capabilities. And in two modes: full keyboard simulation and transfer of events from the keyboard to the browser.
Full keyboard simulation.
In full keyboard emulation mode, Human Emulator controls input from a real keyboard, that is, it sends events as if a real person presses keyboard keys. In this case, all actions with the keyboard will be performed in any active window, be it a window of the built-in browser program or an open Notepad window.
An example of working in php in full emulation mode:
1 2 3 4 5 6 7 8 9 |
// go to the search engine $browser->navigate("http://www.google.com"); // make the text input field active $input->set_focus_by_name("q"); // enter text $keyboard->input("human emulator\n", 10); |
An example of keyboard input into an open Notepad window for programs based on Internet Explorer:
1 2 3 4 5 6 7 8 9 10 |
// create a file $textfile->write_file("1.txt", "1"); // open the program for editing $app->shell_execute("open", "1.txt", "", '', true); // pause to start the program sleep(5); // enter text into the active window $keyboard->input("human emulator\n", 10); |
In Human Emulator Studio, working with the input command is slightly different, so in order to perform the same action as in the example above, you either need to use the clipboard:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// create a file $textfile->write_file("1.txt", ""); // open the program for editing $app->shell_execute("open", "1.txt", "", '', true); // pause to start the program sleep(5); // save to clipboard $clipboard->put_text("human emulator"); // hold CTRL $keyboard->set_ctrl_prefix(true); // press V $keyboard->key(86); // press CTRL $keyboard->set_ctrl_prefix(false); |
Or use the functionality to manage external windows.
An example on php for working in Studio:
1 2 3 4 5 6 7 8 9 10 11 12 |
// create a file $textfile->write_file("1.txt", ""); // open the program to edit the file $app->shell_execute("open", "1.txt", "", '', true); // pause to start the program sleep(5); // get notepad window $ntp_wnd = $window->get_by_text("Notepad"); // enter text into it from the keyboard $ntp_wnd->input("human emulator\n"); |
Passing events from the keyboard to the browser.
The second mode is event transmission. In fact, when you work with the keyboard, after each keystroke, the active window of the program receives a number of messages and the corresponding action is performed based on these messages. Moreover, this event moves from one active window to the next. That is, when you enter text from the keyboard into a text field in a browser, this message is received first by the browser window, and then through the chain of parent elements and the text field, as well as all its child elements.
Thus, you can work simultaneously in several dozen browsers, while in full emulation mode you can work with only one active browser window, as is the case with real keyboard use. All commands for sending events of the keyboard object have the send_ * prefix.
An example of sending events to php:
1 2 3 4 5 6 7 8 9 |
// go to the search engine $browser->navigate("http://www.google.com"); // make the text input field active $input->set_focus_by_name("q"); // enter text $keyboard->send_input("human emulator \n", 10); |
In addition to the keyboard object commands, all HTML DOM objects have send_keyboard_input_by_ * commands. These commands pass keyboard input events to the HTML element.
Mouse simulation.
To control the mouse, the mouse object has been added to all versions of the program. As with the keyboard, you can also work with the mouse in two modes: full emulation of mouse actions and transmission of events from the mouse to the browser element. The principle of operation is the same and with the keyboard, full emulation of the use of a real mouse cursor, and in the event transmission mode, all events from the mouse are transmitted to the element.
Full mouse simulation.
Working with a real mouse. In this mode, the real mouse cursor will be used and during the execution of mouse actions, it will be possible to observe how the cursor on the monitor moves across the screen. For complete emulation, the corresponding commands were added to the object. With the help of these commands, you can perform all the actions that a person can perform with a real mouse: perform clicks on different buttons, spin the wheel, pinch and release buttons, move the cursor.
An example of using full emulation in php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// go to the site $browser->navigate("http://humanemulator.net"); // move the mouse cursor to the desired point $mouse->move(250,150,2); // hold down the right mouse button $mouse->left_button_down(250,150); // move the mouse cursor to the new coordinates $mouse->move(1050,650,3); // release the right mouse button $mouse->left_button_up(1050,650); |
The example above moves the mouse cursor to a specified point on the page, holds down the left mouse button and moves the cursor to new coordinates. After completing this example, a portion of the text on the page will be selected.
Example of mouse clicks in an outer window in an IE based Human Emulator:
1 2 3 4 5 6 7 8 9 |
// create a file $textfile->write_file("1.txt", "1"); // open the program for editing $app->shell_execute("open", "1.txt", "", '', true); // pause to start the program sleep(5); // open the context menu by right-clicking $mouse->right_button_click(); |
An example of mouse clicks in an outer window in Chromium-based Human Emulator Studio:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// create a file $textfile->write_file("1.txt", ""); // open the program to edit the file $app->shell_execute("open", "1.txt", "", '', true); // pause to start the program sleep(5); // get notepad window $ntp_wnd = $window->get_by_text("Notepad"); // enter text into it from the keyboard $ntp_wnd->mouse_right_click(10, 10); |
Passing mouse events.
To send events directly to the browser, use the send_ * prefix commands. Unlike full emulation commands, these commands allow you to work even with a minimized program window and are suitable for multi-threaded work.
An example of sending mouse events to php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// go to the site $browser->navigate("http://humanemulator.net"); // move the mouse cursor to the desired point $mouse->send_move(250,150,2); // hold down the right mouse button $mouse->send_left_button_down(250,150); // move the mouse cursor to the new coordinates $mouse->send_move(1050,650,3); // release the right mouse button $mouse->send_left_button_up(1050,650); |
Through the functionality of the windowinterface object (an interface for managing external windows), you can not only work in full emulation mode, but also send mouse events to these windows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// create a file $textfile->write_file("1.txt", ""); // open the program to edit the file $app->shell_execute("open", "1.txt", "", '', true); // pause to start the program sleep(5); // get notepad window $ntp_wnd = $window->get_by_text("Notepad"); // get editor window $ntp_wnd_edt = $ntp_wnd->get_child_by_class("Edit"); // call the context menu $ntp_wnd_edt->send_mouse_right_click(10, 10); |
Element interface.
Another way to work with the mouse and keyboard with page elements in a browser is to use the functionality of connecting to an element through an interface.
To obtain this interface, one of the commands available from any DOM object of the program is used.
After we have received a link to the interface, we use the commands: Full mouse emulation over the element, Mouse emulation at the event level over the element, Full keyboard emulation over the element, Keyboard emulation at the event level above the element.
In this case, our example for a full keyboard and mouse emulation to work with a google textbox would be:
1 2 3 4 5 6 7 8 9 10 11 |
// go to the search engine $browser->navigate("http://www.google.com"); // get the textbox interface $q_txt = $input->get_by_name("q"); // emulate keyboard events $q_txt->input("human emulator \ n", "10"); sleep(1); // passing mouse events $q_txt->mouse_click(10,10); |
and sending the event to the same field will look like this:
1 2 3 4 5 6 7 8 9 10 11 12 |
// go to the search engine $browser->navigate("http://www.google.com"); // get the textbox interface $q_txt = $input->get_by_name("q"); // emulate keyboard events $q_txt->send_input("human emulator \ n", "10"); sleep(1); // passing mouse events $q_txt->send_mouse_click(10,10); |
A random trajectory of the mouse.
When the command move the mouse cursor move or send_move is called, the mouse cursor moves in a straight line from the starting point to the point specified in the command. But sometimes it becomes necessary to move the mouse along complex and random trajectory, that is, as a person would do by viewing the page or reading text on it. For this purpose, the move_to and send_move_to commands have been added to the program. These commands move the cursor along random trajectory in the form of a line, curve, chaotic movement, along a circular path and along a trajectory to simulate text reading.
Php example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// Go to google $browser->navigate("http://bigfozzy.com"); // pause sleep(2); // Go to point 100,100 along the line in 1000 ms $mouse->move_to(100,100, "line", 1000); // pause sleep(2); // Go to a point along the curve in 1000 ms $mouse->move_to(500,500, "curve", 1000); // pause sleep(2); // Go to point 300,300 by chaos in 500 ms $mouse->move_to(300,300, "chaotic", 1000); // pause sleep(2); // Go to point 400,400 in a circle in 1000 ms $mouse->move_to(400,4000, "circle", 1000); |
Autoclicker based on Human Emulator.
As you can see from this article, all versions of the Human Emulator have enough functionality to use it to make not only a browser autoclicker, but also an autoclicker for external windows.