private static bool PostMessageMouseClickMiddle(int x, int y) { var lParam = ConvertPositionToLparam(x, y); var success = User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_MBUTTONDOWN, User32.MK_MBUTTON, lParam); User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_MBUTTONUP, 0, lParam); return(success); }
public static bool PostMessageKeyDown(Keys vkcode) { if (!IsMouseKey(vkcode)) { return(User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_KEYDOWN, (int)vkcode, 0)); } switch (vkcode) { case Keys.LButton: { var currentCursorPositionInGame = GetCurrentCursorPositionInGame(); PostMessageKeyDown(Settings.Keybinds[(int)ActionKey.Unknown]); var success = User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_LBUTTONDOWN, User32.MK_LBUTTON, ConvertPositionToLparam(currentCursorPositionInGame.X, currentCursorPositionInGame.Y)); PostMessageKeyUp(Settings.Keybinds[(int)ActionKey.Unknown]); return(success); } case Keys.RButton: { var currentCursorPositionInGame2 = GetCurrentCursorPositionInGame(); return(User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_RBUTTONDOWN, User32.MK_RBUTTON, ConvertPositionToLparam(currentCursorPositionInGame2.X, currentCursorPositionInGame2.Y))); } case Keys.MButton: { var currentCursorPositionInGame3 = GetCurrentCursorPositionInGame(); return(User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_MBUTTONDOWN, User32.MK_MBUTTON, ConvertPositionToLparam(currentCursorPositionInGame3.X, currentCursorPositionInGame3.Y))); } case Keys.XButton1: { var currentCursorPositionInGame3 = GetCurrentCursorPositionInGame(); return(User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_XBUTTONDOWN, User32.MK_XBUTTON1, ConvertPositionToLparam(currentCursorPositionInGame3.X, currentCursorPositionInGame3.Y))); } case Keys.XButton2: { var currentCursorPositionInGame3 = GetCurrentCursorPositionInGame(); return(User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_XBUTTONDOWN, User32.MK_XBUTTON2, ConvertPositionToLparam(currentCursorPositionInGame3.X, currentCursorPositionInGame3.Y))); } } return(false); }
public static bool PostMessageKeyboard(Keys vkcode, int x, int y) { var lParam = ConvertPositionToLparam(x, y); User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_MOUSEMOVE, 0, lParam); var success = User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_KEYDOWN, (int)vkcode, lParam); User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_KEYUP, (int)vkcode, lParam); return(success); }
public static void PostMessageKeyUp(Keys vkcode) { if (!IsMouseKey(vkcode)) { User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_KEYUP, (int)vkcode, 0); return; } switch (vkcode) { case Keys.LButton: { var currentCursorPositionInGame = GetCurrentCursorPositionInGame(); User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_LBUTTONUP, 0, ConvertPositionToLparam(currentCursorPositionInGame.X, currentCursorPositionInGame.Y)); return; } case Keys.RButton: { var currentCursorPositionInGame2 = GetCurrentCursorPositionInGame(); User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_RBUTTONUP, 0, ConvertPositionToLparam(currentCursorPositionInGame2.X, currentCursorPositionInGame2.Y)); return; } case Keys.MButton: { var currentCursorPositionInGame3 = GetCurrentCursorPositionInGame(); User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_MBUTTONUP, 0, ConvertPositionToLparam(currentCursorPositionInGame3.X, currentCursorPositionInGame3.Y)); return; } case Keys.XButton1: case Keys.XButton2: { var currentCursorPositionInGame3 = GetCurrentCursorPositionInGame(); User32.PostMessage(D3Client.GetHandle().MainWindowHandle, WM_XBUTTONUP, 0, ConvertPositionToLparam(currentCursorPositionInGame3.X, currentCursorPositionInGame3.Y)); return; } } }