Feel like you are trying to find a descendant MenuItem element of the Notepad window element, with either the name "Edit" or "View", and starting the search from the root element.
The FindFirstWithOptions function should work as expected with the root argument. Here are a few things to check:
- Make sure that the root element is a descendant of the Notepad window element.
- Make sure that the root element is a MenuItem element.
- Make sure that the condition argument correctly specifies the criteria for the elements you want to find.
- Make sure that the TreeScope argument correctly specifies the scope of the search.
It's also a good idea to check the return value of the FindFirstWithOptions function to see if it's Nothing, which indicates that no element was found that matched the specified criteria.
If RLWA32-6355 comment is also your case or similar issue, You are correct that the TreeTraversalOptions argument determines the order in which the search is performed. The TreeTraversalOptions_Default value specifies a default traversal order, which is generally from the root element to its descendants in a depth-first order. The TreeTraversalOptions_LastToFirstOrder value specifies that the search should be performed in reverse order, from the last element to the first.
If you are using the TreeTraversalOptions_Default value and the search is not respecting the root element, it could be because the root element does not match the specified condition. In this case, the search would continue to the next element in the default traversal order until it finds an element that matches the condition.
On the other hand, if you are using the TreeTraversalOptions_LastToFirstOrder value and the search is not respecting the root element, it could be because the root element is not the last element in the traversal order. In this case, the search would continue to the previous element in the reverse traversal order until it finds an element that matches the condition.
It's also important to note that the FindFirstWithOptions function only searches the immediate children of the root element if the TreeScope argument is set to TreeScope_Children. If the TreeScope argument is set to TreeScope_Descendants, the function will search all descendants of the root element, regardless of the TreeTraversalOptions value.
I hope this helps clarify the behavior of the FindFirstWithOptions function.
--If the reply is helpful, please Upvote and Accept it as an answer–