如何加载user32dll并使用keybd_event命令 [英] how to load user32dll and use keybd_event command

查看:346
本文介绍了如何加载user32dll并使用keybd_event命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <winuser32.mqh>
#import "user32.dll"
   
int OnInit()
   {
         keybd_event( VK_NUMLOCK,
                      0x45,
                      KEYEVENTF_EXTENDEDKEY | 0,
                      0 );
   }







'VK_NUMLOCK' - undeclared identifier	testing.mq4	6	23







为什么这不起作用?




why this doesnt work ?

推荐答案

对于初学者来说这是C ++而不是C# - 正确标记你的问题。



错误很明显 - 编译器不知道 VK_NUMLOCK 是。

使用
Well for starters this is C++ not C# - tag your questions properly.

The error is quite clear - the compiler does not know what VK_NUMLOCK is.
Either use
#include <windows.h>

或包含一行

Const VK_NUMLOCK = &H90;

如果你做了后者你还需要

If you do the latter you'll also need

Const KEYEVENTF_EXTENDEDKEY = &H1;


首先,t他不是一个命令。此函数已被 SendInput 取代:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx [ ^ ]。



您不需要编写P / Invoke代码并声明您需要的所有类型;它已经为您完成了: http://www.pinvoke.net/default.aspx/user32.sendinput [ ^ ]。



使用这个功能很简单;我从未遇到任何问题。



< d> -SA
First of all, this is not a "command". This function have been superseded by SendInput:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^].

You don't need to write P/Invoke code and declare all types you need; it's already done for you: http://www.pinvoke.net/default.aspx/user32.sendinput[^].

The use of this function is simple enough; I never faced any problems.

<d>—SA


这篇关于如何加载user32dll并使用keybd_event命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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