Web / browser



run_command

run_command($command); - выполнить команду браузера

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

  • $command – номер команды. Номера команды могут быть следующие :
        OLECMDID_OPEN = 1
        OLECMDID_NEW = 2
        OLECMDID_SAVE = 3
        OLECMDID_SAVEAS = 4
        OLECMDID_SAVECOPYAS = 5
        OLECMDID_PRINT = 6
        OLECMDID_PRINTPREVIEW = 7
        OLECMDID_PAGESETUP = 8
        OLECMDID_SPELL = 9
        OLECMDID_PROPERTIES = 10
        OLECMDID_CUT = 11
        OLECMDID_COPY = 12
        OLECMDID_PASTE = 13
        OLECMDID_PASTESPECIAL = 14
        OLECMDID_UNDO = 15
        OLECMDID_REDO = 16
        OLECMDID_SELECTALL = 17
        OLECMDID_CLEARSELECTION = 18
        OLECMDID_ZOOM = 19
        OLECMDID_GETZOOMRANGE = 20
        OLECMDID_UPDATECOMMANDS = 21
        OLECMDID_REFRESH = 22
        OLECMDID_STOP = 23
        OLECMDID_HIDETOOLBARS = 24
        OLECMDID_SETPROGRESSMAX = 25
        OLECMDID_SETPROGRESSPOS = 26
        OLECMDID_SETPROGRESSTEXT = 27
        OLECMDID_SETTITLE = 28
        OLECMDID_SETDOWNLOADSTATE = 29
        OLECMDID_STOPDOWNLOAD = 30
        OLECMDID_ONTOOLBARACTIVATED = 31
        OLECMDID_FIND = 32
        OLECMDID_DELETE = 33
        OLECMDID_HTTPEQUIV = 34
        OLECMDID_HTTPEQUIV_DONE = 35
        OLECMDID_ENABLE_INTERACTION = 36
        OLECMDID_ONUNLOAD = 37
        OLECMDID_PROPERTYBAG2 = 38
        OLECMDID_PREREFRESH = 39
        OLECMDID_SHOWSCRIPTERROR = 40
        OLECMDID_SHOWMESSAGE = 41
        OLECMDID_SHOWFIND = 42
        OLECMDID_SHOWPAGESETUP = 43
        OLECMDID_SHOWPRINT = 44
        OLECMDID_CLOSE = 45
        OLECMDID_ALLOWUILESSSAVEAS = 46
        OLECMDID_DONTDOWNLOADCSS = 47
        OLECMDID_UPDATEPAGESTATUS = 48
        OLECMDID_PRINT2 = 49
        OLECMDID_PRINTPREVIEW2 = 50
        OLECMDID_SETPRINTTEMPLATE = 51
        OLECMDID_GETPRINTTEMPLATE = 52
        OLECMDID_PAGEACTIONBLOCKED = 55
        OLECMDID_PAGEACTIONUIQUERY = 56
        OLECMDID_FOCUSVIEWCONTROLS = 57
        OLECMDID_FOCUSVIEWCONTROLSQUERY = 58
        OLECMDID_SHOWPAGEACTIONMENU = 59
        OLECMDID_ADDTRAVELENTRY = 60
        OLECMDID_UPDATETRAVELENTRY = 61
        OLECMDID_UPDATEBACKFORWARDSTATE = 62
        OLECMDID_OPTICAL_ZOOM = 63
        OLECMDID_OPTICAL_GETZOOMRANGE = 64
        OLECMDID_WINDOWSTATECHANGED = 65
        OLECMDID_ACTIVEXINSTALLSCOPE = 66
        OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67

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

    Пример использования (PHP):
    ===============================================================

    <?php
     
    // подключим объект для управления эмулятором, если еще не подключен
    if (!isset($path))
      $path="../../../Templates/xweb_human_emulator.php";
    require($path);
     
    // начало
    echo "<hr><font color=blue>browser->".basename (__FILE__)."</font><hr>";
     
    // navigate to google
    $browser->navigate("http://www.google.com");
    $browser->wait(1);
     
    // выполним команду Print Preview
    $browser->run_command(40);
     
    // конец
    echo "<hr><br>";
     
    // Quit
    $app->quit();
     
    /*
    OLECMDID_OPEN = 1,
            OLECMDID_NEW = 2,
            OLECMDID_SAVE = 3,
            OLECMDID_SAVEAS = 4,
            OLECMDID_SAVECOPYAS = 5,
            OLECMDID_PRINT = 6,
            OLECMDID_PRINTPREVIEW = 7,
            OLECMDID_PAGESETUP = 8,
            OLECMDID_SPELL = 9,
            OLECMDID_PROPERTIES = 10,
            OLECMDID_CUT = 11,
            OLECMDID_COPY = 12,
            OLECMDID_PASTE = 13,
            OLECMDID_PASTESPECIAL = 14,
            OLECMDID_UNDO = 15,
            OLECMDID_REDO = 16,
            OLECMDID_SELECTALL = 17,
            OLECMDID_CLEARSELECTION = 18,
            OLECMDID_ZOOM = 19,
            OLECMDID_GETZOOMRANGE = 20,
            OLECMDID_UPDATECOMMANDS = 21,
            OLECMDID_REFRESH = 22,
            OLECMDID_STOP = 23,
            OLECMDID_HIDETOOLBARS = 24,
            OLECMDID_SETPROGRESSMAX = 25,
            OLECMDID_SETPROGRESSPOS = 26,
            OLECMDID_SETPROGRESSTEXT = 27,
            OLECMDID_SETTITLE = 28,
            OLECMDID_SETDOWNLOADSTATE = 29,
            OLECMDID_STOPDOWNLOAD = 30,
            OLECMDID_ONTOOLBARACTIVATED = 31,
            OLECMDID_FIND = 32,
            OLECMDID_DELETE = 33,
            OLECMDID_HTTPEQUIV = 34,
            OLECMDID_HTTPEQUIV_DONE = 35,
            OLECMDID_ENABLE_INTERACTION = 36,
            OLECMDID_ONUNLOAD = 37,
            OLECMDID_PROPERTYBAG2 = 38,
            OLECMDID_PREREFRESH = 39,
            OLECMDID_SHOWSCRIPTERROR = 40,
            OLECMDID_SHOWMESSAGE = 41,
            OLECMDID_SHOWFIND = 42,
            OLECMDID_SHOWPAGESETUP = 43,
            OLECMDID_SHOWPRINT = 44,
            OLECMDID_CLOSE = 45,
            OLECMDID_ALLOWUILESSSAVEAS = 46,
            OLECMDID_DONTDOWNLOADCSS = 47,
            OLECMDID_UPDATEPAGESTATUS = 48,
            OLECMDID_PRINT2 = 49,
            OLECMDID_PRINTPREVIEW2 = 50,
            OLECMDID_SETPRINTTEMPLATE = 51,
            OLECMDID_GETPRINTTEMPLATE = 52,
            OLECMDID_PAGEACTIONBLOCKED = 55,
            OLECMDID_PAGEACTIONUIQUERY = 56,
            OLECMDID_FOCUSVIEWCONTROLS = 57,
            OLECMDID_FOCUSVIEWCONTROLSQUERY = 58,
            OLECMDID_SHOWPAGEACTIONMENU = 59,
            OLECMDID_ADDTRAVELENTRY = 60,
            OLECMDID_UPDATETRAVELENTRY = 61,
            OLECMDID_UPDATEBACKFORWARDSTATE = 62,
            OLECMDID_OPTICAL_ZOOM = 63,
            OLECMDID_OPTICAL_GETZOOMRANGE = 64,
            OLECMDID_WINDOWSTATECHANGED = 65*/
    ?>

    Пример использования (Python):
    ===============================================================

    ?# Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7013"
    from xweb_human_emulator import *
     
    # начало
    echo("<hr><font color=blue>browser.run_command</font><hr>")
     
    # navigate to google
    browser.navigate("http://www.google.com")
     
    # выполним команду Print Preview
    browser.run_command(40)
     
    # конец
    echo("<hr><br>")
     
    # Quit
    app.quit()

    Пример использования (C#):
    ===============================================================

    #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="127.0.0.1:7010";
    			InitXHE();
     
    			// начало
    			echo("<hr><font color=blue>browser.run_command</font><hr>");
     
    			// navigate to google
    			browser.navigate("http://www.google.com");
     
    			// выполним команду Print Preview
    			browser.run_command(7);
     
    			// конец
    			echo("<hr><br>");
     
    			app.quit();            
    	  }
    }
     
    /*OLECMDID_OPEN = 1,
    OLECMDID_NEW = 2,
    OLECMDID_SAVE = 3,
    OLECMDID_SAVEAS = 4,
    OLECMDID_SAVECOPYAS = 5,
    OLECMDID_PRINT = 6,
    OLECMDID_PRINTPREVIEW = 7,
    OLECMDID_PAGESETUP = 8,
    OLECMDID_SPELL = 9,
    OLECMDID_PROPERTIES = 10,
    OLECMDID_CUT = 11,
    OLECMDID_COPY = 12,
    OLECMDID_PASTE = 13,
    OLECMDID_PASTESPECIAL = 14,
    OLECMDID_UNDO = 15,
    OLECMDID_REDO = 16,
    OLECMDID_SELECTALL = 17,
    OLECMDID_CLEARSELECTION = 18,
    OLECMDID_ZOOM = 19,
    OLECMDID_GETZOOMRANGE = 20,
    OLECMDID_UPDATECOMMANDS = 21,
    OLECMDID_REFRESH = 22,
    OLECMDID_STOP = 23,
    OLECMDID_HIDETOOLBARS = 24,
    OLECMDID_SETPROGRESSMAX = 25,
    OLECMDID_SETPROGRESSPOS = 26,
    OLECMDID_SETPROGRESSTEXT = 27,
    OLECMDID_SETTITLE = 28,
    OLECMDID_SETDOWNLOADSTATE = 29,
    OLECMDID_STOPDOWNLOAD = 30,
    OLECMDID_ONTOOLBARACTIVATED = 31,
    OLECMDID_FIND = 32,
    OLECMDID_DELETE = 33,
    OLECMDID_HTTPEQUIV = 34,
    OLECMDID_HTTPEQUIV_DONE = 35,
    OLECMDID_ENABLE_INTERACTION = 36,
    OLECMDID_ONUNLOAD = 37,
    OLECMDID_PROPERTYBAG2 = 38,
    OLECMDID_PREREFRESH = 39,
    OLECMDID_SHOWSCRIPTERROR = 40,
    OLECMDID_SHOWMESSAGE = 41,
    OLECMDID_SHOWFIND = 42,
    OLECMDID_SHOWPAGESETUP = 43,
    OLECMDID_SHOWPRINT = 44,
    OLECMDID_CLOSE = 45,
    OLECMDID_ALLOWUILESSSAVEAS = 46,
    OLECMDID_DONTDOWNLOADCSS = 47,
    OLECMDID_UPDATEPAGESTATUS = 48,
    OLECMDID_PRINT2 = 49,
    OLECMDID_PRINTPREVIEW2 = 50,
    OLECMDID_SETPRINTTEMPLATE = 51,
    OLECMDID_GETPRINTTEMPLATE = 52,
    OLECMDID_PAGEACTIONBLOCKED = 55,
    OLECMDID_PAGEACTIONUIQUERY = 56,
    OLECMDID_FOCUSVIEWCONTROLS = 57,
    OLECMDID_FOCUSVIEWCONTROLSQUERY = 58,
    OLECMDID_SHOWPAGEACTIONMENU = 59,
    OLECMDID_ADDTRAVELENTRY = 60,
    OLECMDID_UPDATETRAVELENTRY = 61,
    OLECMDID_UPDATEBACKFORWARDSTATE = 62,
    OLECMDID_OPTICAL_ZOOM = 63,
    OLECMDID_OPTICAL_GETZOOMRANGE = 64,
    OLECMDID_WINDOWSTATECHANGED = 65*/

    Пример использования (JS):
    ===============================================================

    // подключим объект для управления эмулятором, если еще не подключен
    xhe_host="127.0.0.1:7010";
    echo=require("../../../Templates JS/xweb_human_emulator.js");
     
    // начало
    echo("<hr><font color=blue>browser.run_command</font><hr>");
     
    // 1 шаг
    echo("1. Перейдем на гугл : ");
    echo(browser.navigate("http://www.google.com")+"\n");
     
    // 2 шаг
    echo("2. Выполним команду Print Preview : ");
    echo(browser.run_command(17));
     
    // конец
    echo("<hr><br>");
     
    // Quit
    app.quit();
     
    /*
    OLECMDID_OPEN = 1,
            OLECMDID_NEW = 2,
            OLECMDID_SAVE = 3,
            OLECMDID_SAVEAS = 4,
            OLECMDID_SAVECOPYAS = 5,
            OLECMDID_PRINT = 6,
            OLECMDID_PRINTPREVIEW = 7,
            OLECMDID_PAGESETUP = 8,
            OLECMDID_SPELL = 9,
            OLECMDID_PROPERTIES = 10,
            OLECMDID_CUT = 11,
            OLECMDID_COPY = 12,
            OLECMDID_PASTE = 13,
            OLECMDID_PASTESPECIAL = 14,
            OLECMDID_UNDO = 15,
            OLECMDID_REDO = 16,
            OLECMDID_SELECTALL = 17,
            OLECMDID_CLEARSELECTION = 18,
            OLECMDID_ZOOM = 19,
            OLECMDID_GETZOOMRANGE = 20,
            OLECMDID_UPDATECOMMANDS = 21,
            OLECMDID_REFRESH = 22,
            OLECMDID_STOP = 23,
            OLECMDID_HIDETOOLBARS = 24,
            OLECMDID_SETPROGRESSMAX = 25,
            OLECMDID_SETPROGRESSPOS = 26,
            OLECMDID_SETPROGRESSTEXT = 27,
            OLECMDID_SETTITLE = 28,
            OLECMDID_SETDOWNLOADSTATE = 29,
            OLECMDID_STOPDOWNLOAD = 30,
            OLECMDID_ONTOOLBARACTIVATED = 31,
            OLECMDID_FIND = 32,
            OLECMDID_DELETE = 33,
            OLECMDID_HTTPEQUIV = 34,
            OLECMDID_HTTPEQUIV_DONE = 35,
            OLECMDID_ENABLE_INTERACTION = 36,
            OLECMDID_ONUNLOAD = 37,
            OLECMDID_PROPERTYBAG2 = 38,
            OLECMDID_PREREFRESH = 39,
            OLECMDID_SHOWSCRIPTERROR = 40,
            OLECMDID_SHOWMESSAGE = 41,
            OLECMDID_SHOWFIND = 42,
            OLECMDID_SHOWPAGESETUP = 43,
            OLECMDID_SHOWPRINT = 44,
            OLECMDID_CLOSE = 45,
            OLECMDID_ALLOWUILESSSAVEAS = 46,
            OLECMDID_DONTDOWNLOADCSS = 47,
            OLECMDID_UPDATEPAGESTATUS = 48,
            OLECMDID_PRINT2 = 49,
            OLECMDID_PRINTPREVIEW2 = 50,
            OLECMDID_SETPRINTTEMPLATE = 51,
            OLECMDID_GETPRINTTEMPLATE = 52,
            OLECMDID_PAGEACTIONBLOCKED = 55,
            OLECMDID_PAGEACTIONUIQUERY = 56,
            OLECMDID_FOCUSVIEWCONTROLS = 57,
            OLECMDID_FOCUSVIEWCONTROLSQUERY = 58,
            OLECMDID_SHOWPAGEACTIONMENU = 59,
            OLECMDID_ADDTRAVELENTRY = 60,
            OLECMDID_UPDATETRAVELENTRY = 61,
            OLECMDID_UPDATEBACKFORWARDSTATE = 62,
            OLECMDID_OPTICAL_ZOOM = 63,
            OLECMDID_OPTICAL_GETZOOMRANGE = 64,
            OLECMDID_WINDOWSTATECHANGED = 65*/

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