こんにちは。
WinFormsと仮定します。
エラー文言から推測するに、以下のA,Bどちらかに定義してしまっているのでしょう。
lang
1using System.Runtime.InteropServices;
2using System.Windows.Forms;
3
4//A
5[DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
6static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
7
8namespace WindowsFormsApplication9
9{
10 //B
11 [DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
12 static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
13 public partial class Form1 : Form
14 {
15 public Form1()
16 {
17 InitializeComponent();
18 }
19 }
20}
以下のようにクラス内部に定義する必要があります。
また、呼び出しはメソッドから呼び出す必要があります。
その際にはhtsignさんが仰っているように定数の定義が必要です。
lang
1using System.Runtime.InteropServices;
2using System.Windows.Forms;
3
4namespace WindowsFormsApplication9
5{
6 public partial class Form1 : Form
7 {
8 [DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
9 static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
10
11 public const int MOUSEEVENTF_MOVE = 0x1;
12 public const int MOUSEEVENTF_ABSOLUTE = 0x8000;
13 public const int MOUSEEVENTF_LEFTDOWN = 0x2;
14 public const int MOUSEEVENTF_LEFTUP = 0x4;
15
16 public Form1()
17 {
18 InitializeComponent();
19 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
20 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
21 }
22 }
23}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/04/19 07:47