Dim sapWin, tCols as long, tRows as long
set sapWin = session.FindbyId("wnd[1])
tColumns = sapWin.WorkingPaneWidth
tRows = sapWin.WorkingPaneHeight
sapWin = session.findbyid("wnd[0]")
tColumns = sapWin.WorkingPaneWidth
tRows = sapWin.WorkingPaneHeight
print('text', tRows, tColumns)
for i in range(0, tRows):
try:
status = session.findById(f"wnd[0]/usr/lbl[56,{i}]").text
job_name = session.findById(f"wnd[0]/usr/lbl[4,{i}]").text
print('status', status)
print('job_name', job_name)
except:
pass
参考
https://answers.sap.com/questions/10673834/how-to-count-the-rows-of-a-gui-label-object.html
另一种
layout = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")
row_count = layout.RowCount
print('row_count', row_count)
for i in range(0, row_count):
job_name = layout.GetCellValue(i, "JOBNAME")
status = layout.GetCellValue(i, "STATUSNAME")
start_date = layout.GetCellValue(i, "STRTDATE")
start_time = layout.GetCellValue(i, "STRTTIME")
print(i, job_name, status, start_date, start_time)