Skip to content

Instantly share code, notes, and snippets.

@satoru-naruko
Last active April 1, 2018 11:41
Show Gist options
  • Save satoru-naruko/ee0afb334348785aa2d237a18db433a0 to your computer and use it in GitHub Desktop.
Save satoru-naruko/ee0afb334348785aa2d237a18db433a0 to your computer and use it in GitHub Desktop.
マウス座標の制御
[DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
static extern void SetCursorPos(int X, int Y);
[DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
// マウス(左)ダウン
private const int MOUSEEVENTF_LEFTDOWN = 0x2;
// マウス(左)アップ
private const int MOUSEEVENTF_LEFTUP = 0x4;
public void SetMouseCursorPos(int x, int y)
{
SetCursorPos(x, y);
}
public void ClickMouse(int x, int y)
{
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment