Last active
April 1, 2018 11:41
-
-
Save satoru-naruko/ee0afb334348785aa2d237a18db433a0 to your computer and use it in GitHub Desktop.
マウス座標の制御
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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