天道酬勤,厚德载物,自强不息,求真务实,动脑动手,孜孜以求

StudyDo

天道酬勤,厚德载物,自强不息,求真务实,动脑动手,孜孜以求

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

背景:使用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.

posted on 2014-12-28 22:51  三木人  阅读(441)  评论(0编辑  收藏  举报