Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
8 years ago

Synchronize / validate tests based on mouse cursor type

What would be the best approach if you want to validate and/or synchronize test execution based on the mouse cursor?

 

Examples (in pseudo code):

if mouse cursor type = arrow;

do this;

validate mouse cursor type = busy;

while mouse cursor type = busy

 wait 1 second

 

if mouse cursor type = hand;

log message = ready to start drag and drop!

execute function (drag and drop);

 

 

Any advice would be appreciated.

 

8 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Mathijs,

     

    Not sure what to advice as for your pseudo code, but here is a code that I used somewhere in time (which mean that it might not work on latest OSes) to get cursor state...

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

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

     

    • mgroen2's avatar
      mgroen2
      Super Contributor

      Actually, I am looking for something to embed in Keyword tests. 

      E.g. in the Checkpoint section: Check if the mouse cursor is changed into a specific shape (hand, pointer, hourglass,etc),

      or to be able implement mouse cursor shapes in the Find Object, Wait until mouse cursor has a specific shape.

      So, no code to capture the mouse cursor, but more to be able to steer my Keyword tests based on the shape of the mouse cursor, with steering meaning both validation and synchronization.

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        An interesting idea... I'm assuming that this goes beyond just making sure that the cursor is not an hourglass but actually to synchronize some stuff that may be happening behind the scenes asynchronously for which there is no onscreen visible property to check?

         

        A cool idea... and making it into a Keyword Operation Script extension I'm assuming, so it can show up in that list of operations/Checkpoints, yes?