humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
get_pos_of_image
get_pos_of_image($src_path,$image_path,$koeff=0.95); - получить позицию вхождения заданной картинки доступна с версии 7.0.34Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Get the position (X and Y coordinates) of where an image appears within another image $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); } // Path to the main image (where we're searching) $mainImagePath = "images/main_screenshot.png"; // Path to the sub-image (what we're looking for) $subImagePath = "images/logo_to_find.png"; // Make sure both image files exist if (file_exists($mainImagePath) && file_exists($subImagePath)) { echo "Both image files found\n"; echo "Main image: " . $mainImagePath . "\n"; echo "Sub-image to find: " . $subImagePath . "\n"; // Get the position of where the sub-image appears in the main image // Using default similarity coefficient (0.95) $position = DOM::$image->get_pos_of_image($mainImagePath, $subImagePath); if ($position->x >= 0 && $position->y >= 0) { echo "Sub-image found at position:\n"; echo "X coordinate: " . $position->x . "\n"; echo "Y coordinate: " . $position->y . "\n"; // Use the position to click at that location SYSTEM::$mouse->click($position->x, $position->y); echo "Clicked at the found position\n"; } else { echo "Sub-image not found in the main image\n"; } } else { echo "One or both image files not found\n"; // For demonstration purposes echo "For this example to work, you would need:\n"; echo "- A main image file at: " . $mainImagePath . "\n"; echo "- A sub-image file at: " . $subImagePath . "\n"; } // Quit the application WINDOW::$app->quit();
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7070" from xweb_human_emulator import * # начало echo("<hr><font color=blue>image.xxxxxxxxx</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("http://rpa-bot.ru/wiki/"),"<br>") time.sleep(1) # 2 echo("2. Скриншот вебстраницы в файл: ") echo(webpage.print_screen("test\\test.bmp"),"\n") time.sleep(1) # 3 echo("3. Получим координаты картинки : ") pos = image.get_pos_of_image("test\\test.bmp","test\\kak1.bmp") echo(pos.x + " x "+ pos.y,"\n") # 4 echo("4. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html"),"<br>") # 5 echo("5. Скриншот картинки по src в файл : ") echo(image.screenshot_by_src("test\\test.bmp","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg"),"\n") # 6 echo("6. Вырежем картинку из файла : ") echo(image.get_image("test\\test.bmp","test\\part.bmp",126,72,40,33),"\n") # 7 echo("7. Получим координаты картинки : ") pos=image.get_pos_of_image("test\\test.bmp","test\\part.bmp") echo(pos.x + " x "+ pos.y,"\n") # конец 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; using System.Drawing; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>image.get_x_of_image</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki")+"<br>"); // 2 шаг echo("2. Скриншот вебстраницы в файл: "); echo(webpage.print_screen("test\\test.bmp")+"\n"); // 3 шаг echo("3. Получим координаты картинки : "); Point pt = image.get_pos_of_image("test\\test.bmp","image\\kak.bmp"); echo(pt.X+" x "+pt.Y+"\n"); // 4 шаг echo("4. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html")+"<br>"); // 5 шаг echo("5. Скриншот картинки по src в файл : "); echo(image.screenshot_by_src("test\\test.bmp","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg")+"\n"); // 6 шаг echo("6. Получим координаты картинки : "); pt = image.get_pos_of_image("test\\test.bmp","image\\part.bmp"); echo(pt.X+" x "+pt.Y+"\n"); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7070"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>image.get_x_of_image</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/")+"<br>"); // 2 шаг echo("2. Скриншот вебстраницы в файл: "); echo(webpage.print_screen("test\\test.bmp")+"\n"); // 3 шаг echo("3. Получим координаты картинки : "); var pos=image.get_pos_of_image("test\\test.bmp","image\\kak.bmp"); echo(pos.x + " x " + pos.y+"\n"); // 4 шаг echo("4. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html")+"<br>"); // 5 шаг echo("5. Скриншот картинки по src в файл : "); echo(image.screenshot_by_src("test\\test.bmp","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg")+"\n"); // 6 шаг echo("6. Получим координаты картинки : "); pos=image.get_pos_of_image("test\\test.bmp","image\\part.bmp"); echo(pos.x + " x " + pos.y+"\n"); // конец echo("\n"); // Quit app.quit();
=============================================
Image Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.