Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
14 years ago

Inconstent behavior on ClickR

I have an object on my screen called CommandBars. (This is a VB6 app with Xtreme Suite controls. CommandBars is one of the XTreme Suite controls.) I wrote some script



  grdStatus.Row = STATUS_1MAN_INDEX   ' put the cursor on the right row

  set cb=frmStatus.WaitVBObject("CommandBars", 4000)                       

  grdStatus.ClickR

  set mnu = cb.FocusedCommandBar  ' trying to get the popup menu for the grid row right clicked upon.





So I was fiddling with this. It worked. The grid would receive a click where it was. Over the course of the evening, the VM I was working on ... died a horrible fiery death. So I put my code on a different VM.



I start debugging some stuff, and come up with an error here. Turns out that the right click is now moving the cursor to another row in the grid. Help for OnscreenObject.ClickR (since it does not seem to be one of the other object). The help file indicates that in the absence of coordinates, the click will be simulated in the center of the object.



Well whoa there nelly. The position of the row I want right clicked upon has not changed. It certainly was never in the center of the grid object.



Note that the grid in question is a Janus GridEX.



I really need a way to click and right click at the current cursor position since most of my objects are not supported by Test Complete! I can usually get the cursor where I need it using native object properties and methods. But I need to be able to issue clicks and right clicks there for the underlying click handlers to fire.



Help please!



n.b test Complete 7.




14 Replies

  • It seems to me that it would be really handy if Test Complete had a feature by which you could issue a click or right click at the current cursor position.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    ACTUALLY...



    You can find the current position of the cursor using Sys.Desktop.MouseX and Sys.DeskTop.MouseY.  That will return the co-ordinates of the cursor based upon the desktop size.



    Then, probably, using the position properties of your grid and the size properties of your grid in conjunction with that, you could probably mash together how to translate those two values into the relative positioning on your component and then call the appropriate Click call.



    An intriguing problem, one that I MIGHT have to undertake for my own sanity...


  • If I can find the current cursor position from the desktop, I can just issue a click to that position of the desktop, can I not?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    You are correct, actually.  That would be the Sys.Desktop.MouseDown method.



    so, what you would do is get your MouseY and MouseX and call the following:



    Sys.Desktop.MouseDown(2, Sys.Desktop.MouseX, Sys.Desktop.MouseY)

    Sys.Desktop.MouseUp(2, Sys.Desktop.MouseX, Sys.Desktop.MouseY)




    You need the MouseUp call so that it actually releases the mouse button after the right click.  A quick test verifies that this two line piece of code will right click wherever the cursor happens to be.  so, if you can move the cursor where you want it and then call these two lines, it should do what you want.