none
SendKeys.SendWait not working? Exception Unhandled RRS feed

  • Question

  • Hello, here is my code:

    http://codebin.herokuapp.com?s=5dadc223b238c90004000001

    As you can see, all I want it to do is wait 5 seconds and then type: 'ok'

    But it gives me this error message: 

    System.TypeInitializationException: 'The type initializer for 'System.Windows.Forms.SendKeys' threw an exception.'

    I added the System.Windows.Reference but each time I check if I actually added it, the checkbox next to it is Unchecked? Is this normal?

    Anyway, I am stuck on this problem for like 25 minutes now, please help. :)

    Monday, October 21, 2019 2:37 PM

All replies

  • Hi EbenVranken,

    Thank you for posting here.

    For your question, the program throws an exception when using SendKeys.Send.

    First, SendKeys.Send cannot be used in the Console App, you could replace Send with SendWait like that:

    SendKeys.SendWait("{ENTER}");

    Second, the string ok is an invalid parameter for this method. 

    If you want to simulate some of the keys on the keyboard, you can refer to the technical documentation provided by Microsoft.

    Correct keys format

    Best regards,

    Timon



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 22, 2019 6:09 AM