locked
Hiding Cursor for Coded UI Tests RRS feed

  • Question

  • Hi,

     I simply want to hide the Cursor during some Coded Ui Tests.

    I tried the ‘Cursor.Hide();’ but it seems to have no effect.

    I also Tried ‘SetCursor( IntPtr hCursor);’ but again noting.

    Is it not allowed form Coded UI to hide the cursor?


    Thursday, July 10, 2014 11:46 AM

Answers

  • Hi,

    Cursor.Hide method is used to hide the Arrow of the mouse. It is particularly for Windows Forms controls, reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.hide(v=vs.110).aspx

    We can use HideCaret(IntPtr hWnd)described by Kral06 in this thread: http://stackoverflow.com/questions/601255/prevent-blinking-cursor-in-textbox  to hide the cursor when entering text in a textbox.

    But these methods can’t be used to hide cursor/mouse arrow in Coded UI test, they are not valid in Coded UI Test. But you can use it to hide the mouse Arrow when the mouse pointer enters the control's client area for a control in your Windows Forms app, then when you record actions on this control and playback actions, the mouse cursor will be hidden. For detailed information about Cursor.Hide method, you can consult on Windows Forms forum: http://social.msdn.microsoft.com/Forums/windows/en-US/home?category=windowsforms for better support.

    Anyway, sorry to say that there is no way to hide cursor in Coded UI test.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, July 21, 2014 1:57 AM
    • Marked as answer by Amanda Zhu Monday, July 28, 2014 1:34 AM
    Thursday, July 17, 2014 7:00 AM

All replies

  • Hi Eric,

    This link describes the same problem (no solution I'm afraid): http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3888247-during-visual-studio-coded-ui-test-execution-abil.

    This suggests that you would have to add Cursor.Hide() to the beginning of every recorded method (which doesn't sound great!)

    You could always create your own code snippet to quickly add the Cursor.Hide() (and Cursor.Show() for balance) to in-focus methods but this doesn't save much time really.

    Sorry I couldn't give you a better solution,

    Thursday, July 10, 2014 12:00 PM
  • Hi Eric

    I think the problem is no mouse action can really be performed whilst the mouse is hidden therefore everytime you do something with the mouse it has to unhide it.

    HTH

    Thursday, July 10, 2014 12:35 PM
  • Hi Eric

    I think the problem is no mouse action can really be performed whilst the mouse is hidden therefore everytime you do something with the mouse it has to unhide it.

    Kidding?

    I see that it is possible on touch screens. 

    I could use the ELO software to hide the cursor on the screen (usually used on ELO Touch screens).
    Even when cursor is hidden, I manually or even automaticaly can interact. why it shouldn't?

    Thursday, July 10, 2014 9:00 PM
  • Sorry never I haven't done anything with a touch screen (Other than poke fun at Iphone users :)).  I can't seen an alternate class finger.poke() but maybe if you can get the hwnd of the control you can fire the buttonclick event or some other click event.

    HTH

    Friday, July 11, 2014 8:13 AM
  • Hi Eric,

    Coded UI test does not expose a method to hide cursor. Maybe you can hide the cursor during playback through writing an external method, which is complex. Actually you know that Coded UI accesses control actions through driving the mouse click or keyboard input, so we don’t recommend you to hide the cursor in order to see how the actions are played back better.

     If you really want to hide it in Coded UI test, you could submit this feature request:

    http://visualstudio.uservoice.com/forums/121579-visual-studio

    The Visual Studio product team is listening to user voice there. You can send your ideas/suggestions there and people can vote.

    Thanks for your understanding.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Amanda Zhu Wednesday, July 16, 2014 1:38 AM edit
    • Proposed as answer by Amanda Zhu Wednesday, July 16, 2014 1:38 AM
    • Marked as answer by Amanda Zhu Wednesday, July 16, 2014 9:41 AM
    • Unmarked as answer by Live Eric Wednesday, July 16, 2014 11:33 PM
    Friday, July 11, 2014 9:29 AM
  • There is still the generall question:

    The method Cursor.Hide(); ... what is it for?

    I thought it should hide the cursor ... isn't it?

    Wednesday, July 16, 2014 11:33 PM
  • Hi,

    Cursor.Hide method is used to hide the Arrow of the mouse. It is particularly for Windows Forms controls, reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.hide(v=vs.110).aspx

    We can use HideCaret(IntPtr hWnd)described by Kral06 in this thread: http://stackoverflow.com/questions/601255/prevent-blinking-cursor-in-textbox  to hide the cursor when entering text in a textbox.

    But these methods can’t be used to hide cursor/mouse arrow in Coded UI test, they are not valid in Coded UI Test. But you can use it to hide the mouse Arrow when the mouse pointer enters the control's client area for a control in your Windows Forms app, then when you record actions on this control and playback actions, the mouse cursor will be hidden. For detailed information about Cursor.Hide method, you can consult on Windows Forms forum: http://social.msdn.microsoft.com/Forums/windows/en-US/home?category=windowsforms for better support.

    Anyway, sorry to say that there is no way to hide cursor in Coded UI test.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, July 21, 2014 1:57 AM
    • Marked as answer by Amanda Zhu Monday, July 28, 2014 1:34 AM
    Thursday, July 17, 2014 7:00 AM
  • >> Cursor.Hide method is used to hide the Arrow of the mouse.

    Absolutelly what I want!

    >> But these methods can’t be used to hide cursor/mouse arrow in Coded UI test, they are not valid in Coded UI Test.

    Why not? What is the difference? What changes on the cursor when using the Coded Ui?

    Thursday, July 17, 2014 10:35 AM
  • Hi,

    What is the difference? What changes on the cursor when using the Coded Ui?

    There is not something different between the mouse in application button and the mouse in coded UI test. But Cursor.Hide() is only for windows forms controls and need to be written in control event method in order to hide mouse. It does not apply in Coded UI test method. It does not control the mouse during Coded UI test playback, actually it controls the mouse behavior on the control itself. It is by default. If you don’t hide the mouse using Cursor .Hide during application, then the mouse won’t hide when you operate on the app, the same result when you run coded UI test.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 18, 2014 9:25 AM
  • Ok.

    As I understand, the Coded Ui Tests can do anything what can be done in C' or what can be done from a .Net Application.

    So is there any other why tho hiede the Arrow of the cursor?

    I think ther must be because I see there are different programms doing so, even without an active WinForms Window. (Only during the "set cursor hidden" process)

    Monday, July 21, 2014 4:28 PM
  • Hi Live,

    Coded UI does not provide some such APIs to hide the arrow of the cursor. I don’t doubt that we are able to hide arrow of the cursor in other processes programmatically, but it does not belong to the support range of Test Tools in Visual Studio 2010 and 2012 forum, it is more related to programming, you can consult on some development forums to get how to hide the arrow of the cursor programmatically and then apply the solution to Coded UI test so that you can hide the arrow of the cursor when you run coded UI test. Maybe Visual Studio Language Forums can help you: http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=vslanguages

    Thank you for your understanding.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, July 23, 2014 7:24 AM