Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
elm.ScrollTo
#1
I feel like I've been asking too many questions.  I have made a lot of progress and have figured out almost everything I need to be "feature-parity" with all the QM2 stuff I've created & re-used for automation on a daily basis..  One that is troubling me is scrolling to an element that happens to be hidden / off screen.

The ScrollTo method seems to be the ticket, but if I use Elm.Find to locate the item, it doesn't seem to work.  Adding the  EFFlags.UIA flag sometimes works, but causes collateral damage (invoke method doesn't work for example).  Other times adding the flag fails to find the element at all.

In QM2 I had a global function I created like this:
 
Code:
Copy      Help
 
act w
act a
int c = child(a)
SendMessage c LVM_ENSUREVISIBLE a.elem-1 0 

I'm wondering if there's an alternate approach to "scroll".  elm.Focus() sometimes works.  But in the case of SysListView32, I have mixed results with the Focus method.  Sometimes the element will get "selected" but the window doesn't scroll to that element.

Thoughts?  (and I think this is my last one for a while and I really hope my pain in figuring stuff out helps someone else when searching the forum).
#2
C# code:
var w = wnd.find(1, "QM - My Macros*", "#32770").Activate();
var e = w.Elm["LISTITEM", "browser_back", "id=1023"/*, EFFlags.UIA*/].Find(3);
//e.Focus(true); //works but does not scroll
//e.ScrollTo(); //works with flag UIA, else exception

e.WndContainer.Send(0x1013, e.Item-1); //LVM_ENSUREVISIBLE

I appreciate any questions about QM3. It helps to make the program better.

In next program version ScrollTo will work with standard listview, treeview and listbox controls without flag UIA. Also Navigate("down") etc.
#3
I was in the right ballpark.  I found the "Send" method.  I could have looked up the hex code for LVM_ENSUREVISIBLE from the MS Docs.  And now that I see your syntax the window flags of e.Item-1 makes sense too.  Anyway, thanks for the reply.  That works perfect and will result in fewer exceptions Smile
#4
Quote:I could have looked up the hex code for LVM_ENSUREVISIBLE from the MS Docs.
Look in menu Code -> Windows API. Or use nativeApiSnippet, it's in the completions list.


Forum Jump:


Users browsing this thread: 1 Guest(s)