cancel
Showing results for 
Search instead for 
Did you mean: 

SAP GUI Scripting - Parse GuiUserArea, scrollbar limits

Former Member
0 Kudos

Hi, Gurus:

I'm trying to automate certain changes in RZ20 configuration.

The idea is to parse the monitoring tree area (a GuiUserArea consiting of an array of labels and two scrollbars) and perform a series of actions wen some text is found.

The problem is that we have to scroll to access the whole area and I do not know any references to stop the scrolling. GuiScrollbar Object refers only to the movible part of the scrollbar: Maximum refers to the limit of the mobile part and PageSize refers to the amount of lines scrolled.

I would need some property such as "MaxPosition" but, according to the API documentation, there is no such property:


For $i = 0 To $session.findById("wnd[0]/usr" ).VerticalScrollbar.MaxPosition Step $step_v
	For $j = 0 To $session.findById("wnd[0]/usr" ).HorizontalScrollbar.MaxPosition Step $step_h
		$session.findById("wnd[0]/usr" ).VerticalScrollbar.Position = $i
		$session.findById("wnd[0]/usr" ).HorizontalScrollbar.Position = $j
		For $k = 0 To $session.findById("wnd[0]/usr" ).Children.Count - 1
			If StringInStr($session.findById("wnd[0]/usr" ).Children.ElementAt($k).Text, $search, 1) > 0 Then
				$session.findById($session.findById("wnd[0]/usr" ).Children.ElementAt($k).Id).SetFocus
				_Processing()
				$session.findById("wnd[0]/tbar[1]/btn[5]" ).press
			EndIf
		Next
	Next
Next

Has anyone faced this issue?

My SAPGUI version is 7200.3.7.1066 (7.20 SP7) and the SAP system is a Solution Manager 7.0

Thanks in advance.

Best regards,

José Enrique

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Sorry I cannot offer a simple idea with this but if I read your note right you are looking to know when you have reached the maximum position of the scrollbar. If there were not a simple property as you have explored then these are the 2 approaches I would take.

1) replace the For loops with do loops

Increment the scrollbars and perform your checks

use a try catch clause or on error goto to catch when the scroll has been exceded

Perform a check to see if the solution has finished if not reset and move on.

2)

uses the same approach but performs it upfront recording the position integer until it reaches the end

Then use these integers to control your For loops.

Hope this gives you some avenues to explore

Former Member
0 Kudos

Thank you, drache. Although your approach cannot be used because the setting of the scrollbar positiion beyond its limits does not trigger any exception, it does set the position in the limit, so the code will be:


$session.findById("wnd[0]/usr" ).VerticalScrollbar.Position=10000  ; value beyond scrollbar position limit
$v_limit=$session.findById("wnd[0]/usr" ).VerticalScrollbar.Position
$session.findById("wnd[0]/usr" ).HorizontalScrollbar.Position=10000 ; value beyond scrollbar position limit
$h_limit=$session.findById("wnd[0]/usr" ).HorizontalScrollbar.Position


For $i = 0 To $v_limit Step $step_v
	For $j = 0 To $h_limit Step $step_h
		$session.findById("wnd[0]/usr" ).VerticalScrollbar.Position = $i
		$session.findById("wnd[0]/usr" ).HorizontalScrollbar.Position = $j
		For $k = 0 To $session.findById("wnd[0]/usr" ).Children.Count - 1
			If StringInStr($session.findById("wnd[0]/usr" ).Children.ElementAt($k).Text, $busqueda, 1) > 0 Then
				$session.findById($session.findById("wnd[0]/usr" ).Children.ElementAt($k).Id).SetFocus
				_Process()
				$session.findById("wnd[0]/tbar[1]/btn[5]" ).press
			EndIf
		Next
	Next
Next

But is far neater (when working with small pages) to get the stop positions beforehand and store then in an array:

Dim $v_stops = StringSplit("0,41,82", ",")
Dim $h_stops = StringSplit("0,35", ",")

For $i = 1 To $v_stops[0]
	For $j = 1 To $h_stops[0]
		$session.findById("wnd[0]/usr" ).VerticalScrollbar.Position = $v_stops[$i]
		$session.findById("wnd[0]/usr" ).HorizontalScrollbar.Position = $h_stops[$j]
		For $k = 0 To $session.findById("wnd[0]/usr" ).Children.Count - 1
			If StringInStr($session.findById("wnd[0]/usr" ).Children.ElementAt($k).Text, $busqueda, 1) > 0 Then
				$session.findById($session.findById("wnd[0]/usr" ).Children.ElementAt($k).Id).SetFocus
				_Process()
				$session.findById("wnd[0]/tbar[1]/btn[5]" ).press
			EndIf
		Next
	Next
Next

Regards,

José Enrique