【问题标题】:How to read SAP HTMLViewer Control data with VBA or C#如何使用 VBA 或 C# 读取 SAP HTMLViewer 控件数据
【发布时间】:2018-03-26 11:45:36
【问题描述】:

我正在尝试自动化一个 SAP 任务,其中 HTMLViewer 控件用于显示一些数据并在需要时进行更新。

加载后的 HTMLViewer 控件如下所示。

我试图记录页面的加载,但遗憾的是,其中没有任何事件。

在摸索了几个小时后,我尝试在编辑值时记录脚本并得到以下脚本。

session.findById("wnd[0]/usr/cntlMAIN_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell").sapEvent "","COMMAND=NEW&ELEMENT=INP_I_5_I_=123456789&INP_I_6_I_=1.000&INP_I_7_I_=&INP_I_8_I_=16.99&INP_I_9_I_=16.99&INP_I_10_I_=5.50&INP_I_11_I_=","sapevent:A1F1"
session.findById("wnd[0]/usr/cntlMAIN_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell/shellcont[1]/shell").sapEvent "","COMMAND=ENT&ELEMENT=INP_I_5_I_=123456789&INP_I_6_I_=1.000&INP_I_7_I_=&INP_I_8_I_=16.99&INP_I_9_I_=16.99&INP_I_10_I_=5.50&INP_I_11_I_=","sapevent:A1F1"

我不知道如何在编辑之前读取 sapevent 值。

谁能分享他们在这方面的专业知识。

【问题讨论】:

    标签: c# vba browser sap-gui


    【解决方案1】:

    我设法通过以下代码在 SAP HTMLViewer 上编辑数据:

    //Record the script.
    //Assign `RecordFile` name as your choice
    _session.RecordFile = @"SalesScript.vbs";
    //Start recording
    _session.Record = true;
    //Get session window handle
    var handle = _session.ActiveWindow.Handle;
    //Set the handle as foreground.
    if (SetForegroundWindow(handle))
    {
     //Send Enter key
     SendKeys.SendWait("{ENTER}");                                      
     Thread.Sleep(1000);
    }
    //Get the recording file path to open and get the required fields from it.
    var scriptPath = _session.RecordFile;
    //Stop the recording.
    _session.Record = false;
    //You will get the recording script file. You can get the file contains by opening it with `StreamReader`
    
    
    //Method to set SAP screen foreground.
    [DllImport("user32.dll")]
        public static extern bool SetForegroundWindow(
            int hWnd // handle to window
            );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-14
      相关资源
      最近更新 更多