背景:使用C#操纵鼠标进行重复性的工作
background: using Csharp to handle the keyboard or mouse to do the repetitive work.
问题:属性“DllImport”在该声明类型中无效。它只在“method”声明中有效。错误 1 属性“DllImport”在该声明类
Question:attribution “DllImport” is invalid in the declaration, it is just valid in the “method” declaration
解决方案:使用外部调用的方法
Solution:Use the external method
code example:
private static extern int mouse_event(
int dwFlags,// 下表中标志之一或它们的组合
int dx,
int dy, //指定x,y方向的绝对位置或相对位置
int cButtons,//没有使用
int dwExtraInfo//没有使用
);
extern is used to declare the method implemented externally, it is often used in the situation that interop (using System.Runtime.InteropServices) to call unmanaged code in and DllImport is used at the same time. At that time the method should declard as static.