I'm trying to write a program that holds button for a few seconds and releases it to specific HWND that don't have focus.
I found this (link):
public static void pressKey(String window, long wparam, long lparam) {
WinDef.HWND hWindowHandle = User32.INSTANCE.FindWindow(null, window);
WinDef.HWND editClass = User32.INSTANCE.FindWindowEx(hWindowHandle, null, "Edit", null);
User32.INSTANCE.SendMessage(editClass, WM_KEYDOWN, new WPARAM(wparam), new LPARAM(lparam));
User32.INSTANCE.SendMessage(editClass, WM_CHAR, new WPARAM(wparam), new LPARAM(lparam));
User32.INSTANCE.SendMessage(editClass, WM_KEYUP, new WPARAM(wparam), new LPARAM(lparam));
}
But that method types key, not presses and releases it after a few seconds. I tried removing line that contains WM_CHAR and WM_KEYUP, but it didn't work.