Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4050778
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:06:44+00:00 2026-05-20T14:06:44+00:00

How do I make the form send keystrokes such as Tab, Enter, Left Arrow

  • 0

How do I make the form send keystrokes such as Tab, Enter, Left Arrow etc to itself without interfering with other programs? If I use the SendKeys.Send method, it would send it to whatever window is opened. Is there a way to only work with the form?

Very quick random example:

Let’s say I have 5 textBoxs and I click the ‘Tab’ button 5 times. What would happen ?

It would change the focus from one textbox to another right?

  • Can I make this happen automatically … like make it happen in the background and only to the form itself. So If I’m typing something on Notepad, I don’t want to receive those 5 tabs.

By the way I know I can use this code to change the fofucs, but remember its only an example.

TextBox1.Focus 

I was really hoping for someone to direct me to the right place, however I’m making a progress on my own, but I’m looking for more help. All I need is to click the tab button indirectly (without me being active on the form,) and without the sendkeys method. Is it possible?

Here is my attempt, which I think is wrong

Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer

Public Const WM_CHAR = &H102

 Dim hwnd As Integer = FindWindow(vbNullString, "Form1")
    Dim x As Integer = FindWindowEx(hwnd, 0, "WindowsForms10.EDIT.app.0.14fd2b5", vbNullString)
    Dim keys As Keys
    ' send some keys
    SendMessage(x, WM_CHAR, Keys.Tab, 0)

Why is it wrong?

Because instead of clicking ‘tab’ it sends tab to the textbox, so I’m still focused on the same textbox. It didn’t actually change focus to the next textbox.

Please if its possible help me, if not I will try more on my own.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:06:44+00:00Added an answer on May 20, 2026 at 2:06 pm

    Since this is inside your own app there is absolutely no reason to fake input, a notoriously delicate area.

    Simply call the methods you need directly.

    EDIT

    Since you seem very keen on faked input, I’ll try to explain what is hard about it. First of all input is not sent synchronously to windows, instead it it posted asynchronously to the message queue of the thread which owns the input focus. When that thread pumps its messages it delivers the input messages to the appropriate window.

    The main complication with input messages is that the system holds hidden keyboard state information with them that you cannot fake through PostMessage(). For example, read the documentation of GetKeyboardState(). If you want to fake a SHIFT+TAB key combination then you simply can’t do it with PostMessage() because that would not put the SHIFT in the keyboard state. It can only be done with SendInput().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a form in which the user fills in values.
I'm trying to make a form invisible for x amount of time in c#.
I am trying to make a form move (using the titlebar) from a button
I want to make a .NET Form as a TopMost Form for another external
I'd like to make a simple html form where a person can upvote or
I'm trying to make a pull down menu post a form when the user
In a Django form, how do I make a field read-only (or disabled)? When
I'll phrase this in the form of an example to make it more clear.
I cannot figure out how to make a C# Windows Form application write to
I am developing an ASP.NET Ajax form, and decided to make most of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.