I can't understand how to use SendMessage or PostMessage calls

前端 未结 5 807
南方客
南方客 2020-12-29 14:39

I need to simulate a keypress in a third party application. Let\'s say I have a C# application that needs to send an \"8\" to the Calculator application. I can\'t use the Se

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 15:00

    Not directly your question, but the difference between SendMessage and PostMessage is that Send is a blocking call, Post returns immediately (before the receiving application has processed it).

    MSDN explains the difference: http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx

    Also if you are on vista but not on .NET 3.0 that could also be a problem:

    The SendKeys class has been updated for the .NET Framework 3.0 to enable its use in applications that run on Windows Vista. The enhanced security of Windows Vista (known as User Account Control or UAC) prevents the previous implementation from working as expected.

提交回复
热议问题