Ask a Question

Need ability to detect Cursor State

0 Kudos

Need ability to detect Cursor State

Need ability to detect Cursor State.   So when I click on a button and the cursor state changes to an HourGlass... I'd like to be able to Wait until the cursor changes from an HourGlass back to a Pointer.    This way I'm testing and waiting on a visiable queue instead of just waiting for the next object/control to appear or the object that was clicked to disappear.   

 

 

4 Comments
Marsha_R
Champion Level 3
shanescribner
New Contributor

Thank you for the suggestion.

 

I attempted to implement the following:

 

// Where control is of type IButton

var cursor = control.GetProperty<IObject>("cursor");
var cursorShape = control.GetProperty<IObject>("cursor").CallMethod<int>("QCursor_shape");

 

But the value of cursorShape is always returned as Zero (0)... I would have expected it to be (-2) since the cursor's shape is a Pointer.  

 

Possibly this is not the correct technique to derive the cursor?

 

 

Marsha_R
Champion Level 3

@AlexKaras have you ever used this?

AlexKaras
Champion Level 3

@shanescribner@Marsha_R 

Hi,

 

Ages ago I used the code provided below. Sometimes it worked, sometimes not really (maybe, because of some context switching).

My personal preference, unless there is a requirement to check exactly the cursor state, is to rely not on cursor shape, but wait for the target object/control and continue with it.

 

'------------------------------------------------------------------------------

'From: http://www.sqaforums.com/showflat.php?Cat=0&Number=533710&an=0&page=0&gonew=1
Function GetMouseCursor()
  Dim nHandle
  Dim nProcessID
  Dim nThreadID
  Dim nCursor

 

  GetMouseCursor = -1

 

  nHandle = Win32API.GetForegroundWindow()
  nProcessID = Win32API.GetWindowThreadProcessId(nHandle, null)
  nThreadID = Win32API.GetCurrentThreadId()

 

  Call Win32API.AttachThreadInput(nProcessID, nThreadID, true)
  nCursor = Win32API.GetCursor()
  Call Win32API.AttachThreadInput(nProcessID, nThreadID, false)

 

  GetMouseCursor = nCursor
'  Call Log.Message(nCursor)
  ' Some of common mouse cursor types:
  'var c_nMouse_Pointer = 65555;var c_nMouse_Hourglass = 65559;var c_nMouse_Text = 65557;var c_nMouse_Hand = 65583;
End Function
'------------------------------------------------------------------------------

 

Announcements
Welcome to the TestComplete Feature Requests board!

Here you can review submitted feature requests and vote up the ones you like! If you can't find the feature you want - go ahead and suggest your own idea. Ideas with the highest rating can be implemented in the product.

Check out the Create a Feature Request guide for more information.
New Here?
Welcome to the Community
Sign Up Here