Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keybd_event superseded #135

Open
ls5302 opened this issue Mar 24, 2022 · 1 comment
Open

keybd_event superseded #135

ls5302 opened this issue Mar 24, 2022 · 1 comment

Comments

@ls5302
Copy link

ls5302 commented Mar 24, 2022

I note from https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-keybd_event that the keybd_event function, which is used to implement send_key functionality, has been superseded by SendInput.

I have monkey patched the Win32::Windows class to test, and the change appears straight forward:

def kb_input(wVk, flag)
  input = Array.new(7, 0)
  input[0] = 0x1
  input[1] = wVk
  input[2] = flag
  input.pack "L*"
end

def send_input(*inputs)
  Functions.send_input inputs.size, inputs.join, inputs[0].size
end

def press_key(key)
  send_input kb_input(key, 0)
  key
end

def release_key(key)
  send_input kb_input(key, Constants::KEYEVENTF_KEYUP)
  key
end

Is this of any use to you?

@jarmo
Copy link
Owner

jarmo commented Mar 25, 2022

Hello! Thanks for the information.

Can you say if that solves any problem with RAutomation? I can imagine that it might create a problem where RAutomation might stop working on older Windows versions due to this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants