0

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.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.