0

I am trying to send keystrokes (TAB) a couple of times within an external window from a vb.net program.

  • How can I select/activate the window (for example, how would I do it if it's a Word document/ I am actually looking into something a tad more difficult i.e. from SAP, but I will extrapolate from a simpler approach)?
  • How do I send the TAB key to (or any other key, like an ENTER)?
  • Extending the first question, how can I select a window that just opened (like a pop-up)?

I have tried using HWND processes but I am getting confused as to which id or parameter to use, etc.

  • If the window is not part of your app, I would think HWND would be the way to go. Perhaps update your question with your best attempt and a clear explanation of were exactly you're getting stuck. Of course, if this window you're trying to send keys too is part of your app, better way would be to have references to the instance you want to control – Hursey Jul 12 '22 at 20:07
  • [How to use SendInput to simulate the UP arrow key press (or other extended keys)](https://stackoverflow.com/a/71589883/7444103) <- To send any key combination (extended or not) to Windows that belong to another Process -- [Capture Button Click event inside a MessageBox in another application](https://stackoverflow.com/a/58233065/7444103) <- Get a notification when a Window that belongs to a specified Process (found by Process name or main Window Title - or whatever you know about the other Process) is opened. – Jimi Jul 13 '22 at 05:30
  • I have almost made the code work using https://stackoverflow.com/a/71589883/7444103, thanks. However I need to work this with vb.net (not c#) so I have translated it but keep on getting error Message=PInvoke restriction: cannot return variants. Specifically the line that is causing the trouble is uint sent = SendInput((uint)inputs.Count(), inputs.ToArray(), Marshal.SizeOf()); which I translated as Dim sent = SendInput(inputs.Count, inputs.ToArray, Marshal.SizeOf(Of INPUT)) any advice? – Cevillasenor Aug 15 '22 at 18:17

0 Answers0