humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | лог изменений

screenshot

screenshot($filepath,$x=-1,$y=-1,$width=-1,$heigth=-1); - данная функция используется для создания скриншота окна.

Функция на вход принимает параметры:

  • $filepath – путь к файлу скриншота
  • $x – x левого верхнего угла скриншота.
  • $y – y левого верхнего угла скриншота.
  • $width – ширина области скриншота.
  • $height – высота области скриншота.

    После отработки функция возвращает результат своей работы в скрипт :
  • true – результат обработки сообщения.
  • false – не смогли найти.

    Пример использования
    <?php
    $xhe_host = "localhost:7010";
    // 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: Take screenshots of the application window
    
    // Step: Get the application window interface
    $windowText = "localhost";
    $visibly = false;
    $xheWindow = WINDOW::$window->get_by_text($windowText, $visibly);
    
    // Example 1: Take a screenshot of the application
    echo "Example 1: Take a screenshot of the application\n";
    $savePath1 = "test\\1.bmp";
    $screenshotResult1 = $xheWindow->screenshot($savePath1);
    if ($screenshotResult1) {
        echo "Screenshot saved successfully to: " . $savePath1 . "\n";
    } else {
        echo "Failed to take screenshot\n";
    }
    
    // Step: Open the screenshot file
    $shellExecuteResult1 = WINDOW::$app->shell_execute("open", $savePath1);
    if ($shellExecuteResult1) {
        echo "Screenshot file opened successfully\n";
    } else {
        echo "Failed to open screenshot file\n";
    }
    sleep(5);
    
    // Example 2: Take a screenshot of the application including non-client area
    echo "Example 2: Take a screenshot of the application including non-client area\n";
    $savePath2 = "test\\1.bmp";
    $x1 = -1;
    $y1 = -1;
    $x2 = -1;
    $y2 = -1;
    $includeNonClient = true;
    $includeChildWindows = true;
    $screenshotResult2 = $xheWindow->screenshot($savePath2, $x1, $y1, $x2, $y2, $includeNonClient, $includeChildWindows);
    if ($screenshotResult2) {
        echo "Screenshot with non-client area saved successfully to: " . $savePath2 . "\n";
    } else {
        echo "Failed to take screenshot with non-client area\n";
    }
    
    // Step: Open the screenshot file
    $shellExecuteResult2 = WINDOW::$app->shell_execute("open", $savePath2);
    if ($shellExecuteResult2) {
        echo "Screenshot file with non-client area opened successfully\n";
    } else {
        echo "Failed to open screenshot file with non-client area\n";
    }
    
    // Quit the application
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:3036"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>windowinterface.xxxxxxxxx</font><hr>")
    
    # 1 
    echo("1. Сделаем скриншот XWeb : ");
    echo(window.get_by_text("localhost",false).screenshot("test\\1.bmp"),"<br>");
    
    app.shell_execute("open","test\\1.bmp");
    sleep(5);
    
    # 2
    echo("2. Сделаем скриншот XWeb включая неклиентскую часть : ");
    echo(window.get_by_text("localhost",false).screenshot("test\\1.bmp",-1,-1,-1,-1,false,true),"<br>");
    
    app.shell_execute("open","test\\1.bmp");
    
    # конец
    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.screenshot</font><hr>");
    				
    			// 1 
    			echo("1. Сделаем скриншот XWeb : ");
    			echo(window.get_by_text("localhost",false).screenshot("test\\1.bmp")+"<br>");
    
    			app.shell_execute("open","test\\1.bmp");
    			sleep(5);
    
    			// 2
    			echo("2. Сделаем скриншот XWeb включая неклиентскую часть : ");
    			echo(window.get_by_text("localhost",false).screenshot("test\\1.bmp",-1,-1,-1,-1,false,true)+"<br>");
    
    			app.shell_execute("open","test\\1.bmp");
    
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:3036";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>windowinterface.screenshot</font><hr>");
    
    // 1 
    echo("1. Сделаем скриншот XWeb : ");
    echo(window.get_by_text("localhost",false).screenshot("test\\1.bmp")+"<br>");
    
    app.shell_execute("open","test\\1.bmp");
    app.sleep(5);
    
    // 2
    echo("2. Сделаем скриншот XWeb включая неклиентскую часть : ");
    echo(window.get_by_text("localhost",false).screenshot("test\\1.bmp",-1,-1,-1,-1,false,true)+"<br>");
    
    app.shell_execute("open","test\\1.bmp");
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    Window Interface    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .