使用PostMessage发送正确的ALT + C [英] Sending right ALT+C with PostMessage

查看:329
本文介绍了使用PostMessage发送正确的ALT + C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试发送我的应用程序 RIGHT ALT + C

I trying to send in my application RIGHT ALT + C.

我尝试执行以下操作:

I tried do it following:

PostMessage(hWindow, WM_KEYDOWN, (IntPtr)0x0043, (IntPtr)0x0012);
Delay(1000);
PostMessage(hWindow, WM_KEYUP, (IntPtr)0x0043, (IntPtr)0x0012);

PostMessage(hWindow, WM_KEYDOWN, (IntPtr)0x0043, (IntPtr)0x0001);
Delay(1000);
PostMessage(hWindow, WM_KEYUP, (IntPtr)0x0043, (IntPtr)0x0001);

,但操作不正确。我应该如何使用它?

but it doesn't correctly. How should I used it?

推荐答案

是的,可以使用PostMessage。我使用了Spy ++程序(它在Visual Studio中,或者您可以下载它 http://mdb-blog.blogspot.com/2010/11/microsoft-spy-or-spyxx-for-download.html )我运行notepad.exe和Spy ++,并使用了Function FindWindow处理此记事本。然后我使用了Spy-> LogMessages,在Tab Messages中清除了所有内容并保持为复选框,在Keyboard和输出中检查了Raw Message Parameters。

Yes, it's possible using PostMessage. I used program Spy++ (it's inside Visual Studio or you can download it http://mdb-blog.blogspot.com/2010/11/microsoft-spy-or-spyxx-for-download.html) I runed notepad.exe and Spy++, and used Function FindWindow to handle this notepad. Then I used Spy->LogMessages, in Tab Messages I cleared all and stay checkbox Keyboard and in output I checked Raw Message Parameters.

然后在记事本中按alt + 1我注意到了窗口消息中的值。我现在知道了,在哪里使用WM_KEYDOWN,WM_KEYUP,WM_SYSKEYUP等,值分别为lParam,wParam。

Then in notepad i pressed alt+1 and I noted values from Window Messages. I known now, where use WM_KEYDOWN, WM_KEYUP, WM_SYSKEYUP etc. and value lParam, wParam.

我的函数:

    public void PressKeyWithAlt(uint key, uint lParamDown, uint lParamUp)
    {
        PostMessage(hWindow, WM_KEYDOWN, VK_CONTROL, 0x001D0001);
        PostMessage(hWindow, WM_KEYDOWN, VK_MENU, 0x21380001);
        PostMessage(hWindow, WM_KEYDOWN, key, lParamDown);
        Delay(1000);
        PostMessage(hWindow, WM_KEYUP, key, lParamUp);
        PostMessage(hWindow, WM_SYSKEYUP, VK_CONTROL, 0xE01D0001);
        PostMessage(hWindow, WM_KEYUP, VK_MENU, 0xC1380001);
    }

例如alt + 1

PressKeyWithAlt(VK_1, 0x20020001, 0xE0020001);

感谢您的所有帮助。

这篇关于使用PostMessage发送正确的ALT + C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆