none
how can i make the system press some keys? RRS feed

  • Question

  • hello

    how can i let the system to press some keys?  for eg:  i want the software to press letter ( L) by it self

    for eg:

     TextBox3.Text = (TextBox1.Text & ControlChars.Tab & TextBox2.Text)

    ( above i know that between textbox1 and textbox2 the system will press tab key )

    what i want is instate of tab key i want the system to press letter L which is on my keyboard 

    i tried to find letter L in control chars but i didnt find this command 

    so what should i do if i want this to happen?

    Friday, May 4, 2018 2:14 AM

All replies

  • The system is not pressing the Tab Key on the keyboard. You are inserting the control character tab in a string which is quite different.

    What is the outcome you expect from making the keyboard press an L key? That an L will be typed into TextBox3? If that is the case you can focus TextBox3 and use SendKeys (https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1) which will send keystrokes to the focused window of the top level app in the z order. In this case TextBox3 should be focused and your app should be the top level window on the desktop with TextBox3 focused.

    If you have some other idea then please provide what exactly you want to do by making the keyboard select letters.

    Note that if you ran SendKeys in a Timer and you opened Notepad and it was the top level app on the desktop before the timer fired the Notepad text window would receive the input from SendKeys if that was the focused window in Notepad.


    La vida loca

    Friday, May 4, 2018 2:39 AM
  • hello

    how can i let the system to press some keys?  for eg:  i want the software to press letter ( L) by it self

    for eg:

     TextBox3.Text = (TextBox1.Text & ControlChars.Tab & TextBox2.Text)

    ( above i know that between textbox1 and textbox2 the system will press tab key )

    what i want is instate of tab key i want the system to press letter L which is on my keyboard 

    i tried to find letter L in control chars but i didnt find this command 

    so what should i do if i want this to happen?

    In an analogy:

    You live in NY but you want before you eat a big mac go to LA, buy it there, fly back and eat it your big mac in NY

    You can simply concatenate the character "L" in your problem. 

    By the way, I've no experience between the differences of big mac's in LA and NY. 


    Success
    Cor

    Friday, May 4, 2018 10:31 AM
  • hello

    how can i let the system to press some keys?  for eg:  i want the software to press letter ( L) by it self

    for eg:

     TextBox3.Text = (TextBox1.Text & ControlChars.Tab & TextBox2.Text)

    ( above i know that between textbox1 and textbox2 the system will press tab key )

    what i want is instate of tab key i want the system to press letter L which is on my keyboard 

    i tried to find letter L in control chars but i didnt find this command 

    so what should i do if i want this to happen?

     TextBox3.Text = (TextBox1.Text & "L" & TextBox2.Text)

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Friday, May 4, 2018 11:19 AM
    Moderator
  • to be more clear

    i have my own software which will import some data from excel sheet.

    then i want my software to fill another software which needs some information like name, mobile,gender, and state

    i will create a barcode in my software so the user will use the barcode scanner to fill the other software which i attached it

    thats why i need program my software before create the barcode to press some letters.

    because when its reach to combobox it should press some letter to choose what inside the combobox.

    later on every thing will be programmed in the barcode

    i hope you understand meeg

    Friday, May 4, 2018 2:45 PM
  • The system is not pressing the Tab Key on the keyboard. You are inserting the control character tab in a string which is quite different.

    What is the outcome you expect from making the keyboard press an L key? That an L will be typed into TextBox3? If that is the case you can focus TextBox3 and use SendKeys (https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1) which will send keystrokes to the focused window of the top level app in the z order. In this case TextBox3 should be focused and your app should be the top level window on the desktop with TextBox3 focused.

    If you have some other idea then please provide what exactly you want to do by making the keyboard select letters.

    Note that if you ran SendKeys in a Timer and you opened Notepad and it was the top level app on the desktop before the timer fired the Notepad text window would receive the input from SendKeys if that was the focused window in Notepad.


    La vida loca

    thanks for your reply

    so what should i write if i want the system to press tab key ?

    Friday, May 4, 2018 2:46 PM
  • thanks for your reply

    so what should i write if i want the system to press tab key ?

    Well it's not that simple really. You actually need pinvokes for what you want to do so that you can send letters to various windows of the other software that you want to send keystrokes too.

    If the other software was written by you then you could use InterProcess Communications between the two apps. See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx.

    Other than that probably a guy named IronRazerz may need to assist you as he knows the pinvoke stuff inside and out. Although I will update this post in a little while with either a link to or code of an app I have that can send keystrokes to another application in this instance Notepad. It uses Pinvokes to find the actual window in Notepad to send the keystrokes to which is what you will need for finding the correct windows in the other app to send keystrokes to.

    Update: see this thread https://social.msdn.microsoft.com/Forums/en-US/6f9aea01-4d94-4632-aae4-c5f73096d95e/vbnet-how-can-i-make-my-program-enter-keys-do-key-input?forum=vbgeneral


    La vida loca

    Friday, May 4, 2018 4:45 PM
  • thanks for your reply

    so what should i write if i want the system to press tab key ?

    Well it's not that simple really. You actually need pinvokes for what you want to do so that you can send letters to various windows of the other software that you want to send keystrokes too.

    If the other software was written by you then you could use InterProcess Communications between the two apps. See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx.

    Other than that probably a guy named IronRazerz may need to assist you as he knows the pinvoke stuff inside and out. Although I will update this post in a little while with either a link to or code of an app I have that can send keystrokes to another application. In this instance Notepad but I don't believe it uses Pinvokes to find the actual window in Notepad to send the keystrokes too which is what you will need.

    Update: see this thread https://social.msdn.microsoft.com/Forums/en-US/6f9aea01-4d94-4632-aae4-c5f73096d95e/vbnet-how-can-i-make-my-program-enter-keys-do-key-input?forum=vbgeneral


    La vida loca

    thanks again for your replay

    actually the other program was written by unknown guy

    thats why i want to write letter order in my ( barcode)

    Friday, May 4, 2018 4:53 PM
  • You're welcome but it won't be super simple to do. Since you will always need to know what window in the other app to send keystrokes to and whether that window or windows support(s) receiving keystrokes.

    La vida loca

    Friday, May 4, 2018 4:55 PM