Is it possible to send keystrokes or clicks to Diablo III. Every attempt I have tried has failed. Has anyone had any success with this?
Is it possible to send keystrokes or clicks to Diablo III. Every attempt I have tried has failed. Has anyone had any success with this?
Don't you use functions like as SendMessage/PostMessage? (or whatever it is called)
send keystroke to background window via WINAPI:
[DllImport("user32.dll", EntryPoint="PostMessageA")]
private static extern int PostMessage(IntPtr hwnd, int wMsg, int wParam, uint lParam);
private const int WM_KEYDOWN = 0x100;
private const int WM_KEYUP = 0x101;
// vkCode_0-9 = 0x30-39
// vkCode_A-Z = 0x41-5A
PostMessage(hwnd, WM_KEYDOWN, vkCode, 0); // key down
PostMessage(hwnd, WM_KEYUP, vkCode, 0xC0000000); // key up
make sure to include some delay 30ms+
thanks evil2. works perfectly
Last edited by zewt; 06-08-2012 at 05:17 AM.
I'm running a W7 64Bit, made a couple of changes to make it 64bit friendly..
But for some reason the Skill page will not show up, what am i doing wrong? how does one debug Postmessage?Code:[DllImport("user32.dll", EntryPoint = "PostMessageA", SetLastError = true)] private static extern int PostMessage(IntPtr hwnd, uint wMsg, IntPtr wParam, IntPtr lParam); private const int WM_KEYDOWN = 0x100; private const int WM_KEYUP = 0x101; private void button1_Click(object sender, EventArgs e) { PostMessage(proc.MainWindowHandle, (uint)Keys.S, (IntPtr)WM_KEYDOWN, (IntPtr)0x0); PostMessage(proc.MainWindowHandle, (uint)Keys.S, (IntPtr)WM_KEYUP, (IntPtr)0x0); }
Try having a delay
and to expand upon that in C++ see below.
just swap the L with R and you got yourself a right click!Code:void leftClick(HWND mwnd, int x, int y) { SetCursorPos(x,y); PostMessage(mwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x,y-22)); return; }
usage:
and to create a delay just throw this function between your keydowns and ups.Code:HWND hwnd = FindWindow(0, _T("Diablo III")); LeftClick(hwnd,50,50);
Code:#include <time.h> void sleep(unsigned int mseconds) { clock_t goal = mseconds + clock(); while(goal>clock()); }
now... the problem i am having with postmessage is... when i tell my character to click on the waypoint in game, he runs to waypoint but i dont get waypoint menu! he is just literally standing directly on top of it and the postmessage click cannot interact with it anyone know how i can do this so it works?
Last edited by zewt; 06-08-2012 at 05:49 AM.
edit, i'm tired. i read this entire thread wrong.
Last edited by kallellkryptonite; 06-08-2012 at 11:39 AM.
Evil2, You my good sir have a valid point.
Damnit!
I'm having the same problem, where clicking on the screen using Postmessage works, but not for entering doorways/checkpoints etc, it just moves to them instead.
I've tried emulating exactly what spy++ captures when I click it manually, but to no avail yet.
Anyone have a solution for this?
One method I've thought about and talked with someone would be to have a parent window absorb the D3 window so that it thinks that it always has focus, but you would be able to minimize the parent window.
Although his main point is to get slower cpu useage so we talked about the possibility of every time an action was called that needed the window to be up you could just give focus to the window in it's parent window for a split second and then re-minimize it.
I don't think you can send keystrokes to minimized windows well you probablly can but most games enter "sleep" mode when you minize it, like diable rendering and other shit like that to save resources.
Diablo does not... Atleast it reacts on WM_LBUTTONDOWN greatly.