sendkeys issue in a formless application

Denaes

Senior Contributor
Joined
Jun 10, 2003
Messages
956
I need to use sendkeys in a formless application and heres my code:

Visual Basic:
Imports System.Windows.Forms

Public Class Main
    Inherits System.Windows.Forms.Form


    Shared Sub Main()

        System.Windows.Forms.SendKeys.Send("mooo")

    End Sub
    End Class

I know you have to inherit from the forms class to get this to work, but its giving me this error and asking me to use SendKeys.SendWait or change my application

An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll

Additional information: SendKeys cannot run inside this application because the application is not handling Windows messages. Either change the application to handle messages, or use the SendKeys.SendWait method.

Sendkeys.Send is what I want. I really don't know if Sendkeys.SendWait is what I want.

Is there a solution or a way to enable a formless app to "handle messages"?
 
Back
Top