humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
key_up
key_up($key); - данная функция используется для эмуляции отжатия заданной клавиши на клавиатуре на уровне железа, относительно текущего окна (фокус ввода передается текущему окну при вызове этой функции) (доступна с 4.6.37)Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php $xhe_host = "localhost:7010"; if (!isset($path)){ // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } // Scenario: Send key down and key up commands to navigation input echo "\n"; // Step: Get the main window interface $windowText = "localhost"; $mainWindow = WINDOW::$window->get_by_text($windowText, false); // Step: Get the navigation input field through child elements $childNumber1 = 0; $toolbarClass = "XTPToolBar"; $richEditClass = "RichEdit"; $navigate = $mainWindow->get_child_by_number($childNumber1) ->get_child_by_class($toolbarClass) ->get_child_by_class($richEditClass); // Example 1: Set text in navigation by first letter using key down and key up echo "Example 1: Set text in navigation by first letter using key down and key up\n"; $keyChar = "g"; $keyDownResult = $navigate->key_down($keyChar); $keyUpResult = $navigate->key_up($keyChar); if ($keyDownResult && $keyUpResult) { echo "Key down and key up operations executed successfully\n"; } else { echo "Failed to execute key down and key up operations\n"; } sleep(2); // Example 2: Press Enter key to submit the navigation echo "Example 2: Press Enter key to submit the navigation\n"; $enterKeyCode = 13; $keyResult = $navigate->key($enterKeyCode); if ($keyResult) { echo "Enter key pressed successfully\n"; } else { echo "Failed to press Enter key\n"; } sleep(1); // Quit the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7010" from xweb_human_emulator import * # начало echo("<hr><font color=blue>windowinterface.xxxxxxxxx</font><hr>") # 1 echo("1. Зададим текст в навигацию по первой букве : ") navigate=window.get_by_text("XWeb").get_child_by_number(0).get_child_by_number(0).get_child_by_number(0).get_child_by_number(2).get_child_by_number(0).get_child_by_number(0).get_child_by_number(0).get_child_by_number(1).get_child_by_number(0) echo(navigate.key_down("y")," ") echo(navigate.key_up("y")," ") echo(navigate.key_down("a")," ") echo(navigate.key_up("a")," ") echo(navigate.key_down(".")," ") echo(navigate.key_up(".")," ") echo(navigate.key_down("r")," ") echo(navigate.key_up("r")," ") echo(navigate.key_down("u")," ") echo(navigate.key_up("u")," ") sleep(2) echo(navigate.key(13),"<br>") sleep(1) # конец echo("<hr><br>") # Quit app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>windowinterface.key_up</font><hr>"); // 1 шаг echo("1. Зададим текст в навигацию по первой букве : "); XHEWindowInterface navigate=window.get_by_text("XWeb",false).get_child_by_number(0).get_child_by_class("XTPToolBar").get_child_by_class("RichEdit"); echo(navigate.key_down("g")+" "+navigate.key_up("g")+" ");sleep(2); echo(navigate.key(13)+"<br>");sleep(1); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>keyboard.key_up</font><hr>"); // 1 шаг echo("1. Зададим текст в навигацию по первой букве : "); navigate=window.get_by_text("XWeb",false).get_child_by_number(0).get_child_by_class("XTPToolBar").get_child_by_class("RichEdit"); echo(navigate.key_down("g")+" "+navigate.key_up("s")+" ");browser.sleep(2); echo(navigate.key(13)+"<br>");browser.sleep(1); // конец echo("\n"); // Quit app.quit();
=============================================
Window Interface Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.