SAP GUI scripting - Button press fails

别等时光非礼了梦想. 提交于 2021-01-24 07:17:40

问题


I am using a macro in an Excel file that runs the SAP GUI. There is a step where, when I click a button in SAP there will be another window that pops up.

For that I have written a code like this:

session.findbyid("wnd[0]/XX/btnXX").press
session.findbyid("wnd[1]/XX/btnXXX").press

There is a button (btnXXX) in the window (wnd[1]). But when I execute this query, I am getting an error object not found for findbyid.

When I keep the break point and execute it, it is throwing error on 2nd line in the above code. I try to pick the activewindow.name and it shows wnd[0] still. Here the issue is wnd[1] is not getting opened.

Does somebody know why the 2nd "button press" doesn't work?


回答1:


You should be able to replace all mouse clicks with keyboard strokes.

Replace:

session.findbyid("wnd[0]/XX/btnXX").press

With:

session.findById("wnd[0]").sendVKey(N)

Where N is the linked hot-key ID.

To get the exact command, use SAP script recording and only use the keyboard to transition between views and windows. The easiest way to determine how is to hover your mouse over the buttons you would normally click to learn the hot-key then record the hot-key.

Note 1) So far I have found that btn[XX] always maps to sendVKey(XX), but I can't be certain this is always the case.

Note 2) sendVKey always appears to be referenced off the window (wnd[Y]) even if a button is another layer down (/tbar, /usr, etc.).



来源:https://stackoverflow.com/questions/58116190/sap-gui-scripting-button-press-fails

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!