shanescribner's avatar
shanescribner
New Contributor
2 years ago
Status:
New Idea

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.   

 

 

  • 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?

     

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    shanescribnerMarsha_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
    '------------------------------------------------------------------------------