Virtual Keyboard-VBForums
Results 1 to 15 of 15

Thread: Virtual Keyboard

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Question Virtual Keyboard

    Good morning everyone.

    I'm trying to make a custom virtual keyboard in VB.NET. I know what your thinking, Windows already has one right? Difference is, this one is to replicate an Epos Keyboard. So the built in one isn't really any good.
    The only use for this keyboard is training. When we train a group of new staff we put the Epos software on a projector, so this keyboard would make life a lot easier (I think)

    What I need to know is, how can I make they keyboard send the inputs to our Epos software.
    Would the program have to send it to a textbox in the app then send it to the program?

    For example,
    On button pressed, textbox.text ="Buttoninput"
    Then, on textbox1.text changed send to ????????
    Textbox1.text = "" (To clear the textbox for next input)

    I can make the keys generate the relevant function but that's as far as I have got with it.

    Please Help

    Name:  Capture.jpg
Views: 877
Size:  50.9 KB
    Last edited by stephen.s13; Jan 27th, 2015 at 03:42 AM. Reason: Missed a piece of text

  2. #2
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,173

    Re: Virtual Keyboard

    Quote Originally Posted by stephen.s13 View Post
    Good morning everyone.

    I'm trying to make a custom virtual keyboard in VB.NET. I know what your thinking, Windows already has one right? Difference is, this one is to replicate an Epos Keyboard. So the built in one isn't really any good.
    The only use for this keyboard is training. When we train a group of new staff we put the Epos software on a projector, so this keyboard would make life a lot easier (I think)

    What I need to know is, how can I make they keyboard send the inputs to our Epos software.
    Would the program have to send it to a textbox in the app then send it to the program?

    For example,
    On button pressed, textbox.text ="Buttoninput"
    Then, on textbox1.text changed send to ????????
    Textbox1.text = "" (To clear the textbox for next input)

    I can make the keys generate the relevant function but that's as far as I have got with it.

    Please Help

    Name:  Capture.jpg
Views: 877
Size:  50.9 KB
    The question is really how to send the messages to the POS program from your program. You do not need to use an intermediary like a textbox. I do not have any real-world experience with this so I may be off base, but could look at the SendMessage function. To use the function, you have to use Spy++ to get the button handle, and then send a message to it invoke the click. This is assuming your POS program is actually using buttons.

    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    Code:
    SendMessage(ButtonHandle, BM_CLICK, 0, 0);

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: Virtual Keyboard

    I'm not too sure I follow you...

    The program is a virtual replica of a physical keyboard we use on each Pos system.

  4. #4
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,173

    Re: Virtual Keyboard

    Oh, I see. I was assuming the POS keyboard was on an LCD screen and not physical. So what are you trying to do? Control a POS with a keyboard you have created in .NET rather than the actual physical one? How do you expect your virtual keyboard to talk to the app? Is the POS app running on a typical desktop?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: Virtual Keyboard

    That's exactly the Idea.

    It's mostly for training when we show it on a projector.

    The Pos Systems just run in Windows.

    The idea is when a button is pressed on the V.Keyboard it will send the function to the software. For example pressing "Refund" would send the keystrokes "Alt + R"

  6. #6
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,173

    Re: Virtual Keyboard

    Quote Originally Posted by stephen.s13 View Post
    That's exactly the Idea.

    It's mostly for training when we show it on a projector.

    The Pos Systems just run in Windows.

    The idea is when a button is pressed on the V.Keyboard it will send the function to the software. For example pressing "Refund" would send the keystrokes "Alt + R"
    So you will run the app directly on the POS system. It is my understanding that the virtual keyboard will send the command to the application that represents one of the buttons has been clicked. This is apparently what SendMessage function does. You are going to have to do some investigating and research into that.

    You could also reach out to the POS software vendor and see if they have any built-in support for virtual keyboards or an API or something.

    https://msdn.microsoft.com/en-us/library/dd460725.aspx

    There seems like a lot of places to get stuck on this. A non-digital alternative could be to use something like an Elmo projector (http://www.amazon.com/Elmo-TT-02Rx-T.../dp/B002TP8Y8Y) to capture and display the physical keyboard and then project the computer screen.
    Last edited by jayinthe813; Jan 28th, 2015 at 08:44 AM.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: Virtual Keyboard

    There must be an easier way. I'm sure I made one in the past. It had a drop down box showing all running apps. You select the one you want to type to, and it sent the inputs.

    Unless it was a dream..... :P

  8. #8
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,173

    Re: Virtual Keyboard

    Well we would have no idea what you did in the past, I imagine you could have used send keys, but what keystrokes do you send to this POS application to press the "Coupon" button? What does the application expect to happen in order to trigger the "Coupon" button to be clicked? How can you trigger this is the question.

    Can the windows QWERTY virtual keyboard control the application the same way that the physical one does? Or at least partially?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: Virtual Keyboard

    Think I may have answered my own question after weeks of searching lol

    http://www.cespage.com/vb/vb08tut21.html

  10. #10
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: Virtual Keyboard

    Just make a form that remains TopMost and set its extended style to NoActivate.
    Code:
    Public Class Form1
       Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          Me.TopMost = True
       End Sub
    
       Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
          Get
             Const WS_EX_NOACTIVATE As Int32 = &H8000000
             Dim cp As CreateParams = MyBase.CreateParams
             cp.ExStyle = cp.ExStyle Or WS_EX_NOACTIVATE
             Return cp
          End Get
       End Property
    
       Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnA.Click
          SendKeys.Send("A")
       End Sub
    
       Private Sub btnB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnB.Click
          SendKeys.Send("B")
       End Sub
    End Class
    Click on the target window (the one to receive the keystrokes) and then click on your keyboard keys.

  11. #11
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    1,834

    Re: Virtual Keyboard

    I used this thread to build my own onscreen keyboard.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: Virtual Keyboard

    Quote Originally Posted by TnTinMN View Post
    Just make a form that remains TopMost and set its extended style to NoActivate.
    Code:
    Public Class Form1
       Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          Me.TopMost = True
       End Sub
    
       Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
          Get
             Const WS_EX_NOACTIVATE As Int32 = &H8000000
             Dim cp As CreateParams = MyBase.CreateParams
             cp.ExStyle = cp.ExStyle Or WS_EX_NOACTIVATE
             Return cp
          End Get
       End Property
    
       Private Sub btnA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnA.Click
          SendKeys.Send("A")
       End Sub
    
       Private Sub btnB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnB.Click
          SendKeys.Send("B")
       End Sub
    End Class
    Click on the target window (the one to receive the keystrokes) and then click on your keyboard keys.
    Best solution yet, works briliantly thanks!!
    Next question :P
    How can I make the shift key stay on.
    Shift would be sendkeys.send("+") but obviously it only pressed it once, Soo as the button is released. It goes off

  13. #13
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    1,834

    Re: Virtual Keyboard

    This solution proposed by Tn may be simple, but it's functionality is unacceptable in my opinion, though it may work for your needs.
    Also, there is no way to have a shift key since you cant press two buttons simultaneously wth a mouse. You would need to implement a caps-lock button on your virtual keyboard that controls whether to send lower case or upper case when a button is clicked.
    Last edited by nbrege; Jan 28th, 2015 at 01:45 PM.

  14. #14
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,173

    Re: Virtual Keyboard

    When SHIFT is clicked on the screen, it should be enabled as a modifier to the next key being clicked. You could track a boolean value which is set on click of the SHIFT button, and then is interpreted on the next A-Z key being clicked, sends the keys, and sets the boolean back to false again.

    I agree with you about the functionality being unacceptable. The real problem which OP has not yet conceived is when the standard keys will not do what he needs it to. How do you send keys for "DEPARTMENT CODES", "COUPON", "CREDIT/DEBIT". Are they standard keys that can be emulated? If he can't get those to work, this is going to be a tacky solution, and he will need to figure out the right way to do this.

  15. #15
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    3,924

    Re: Virtual Keyboard

    Quote Originally Posted by jayinthe813 View Post
    ... The real problem which OP has not yet conceived is when the standard keys will not do what he needs it to. How do you send keys for "DEPARTMENT CODES", "COUPON", "CREDIT/DEBIT". Are they standard keys that can be emulated? ...
    I'm assuming they are key code sequences like he has already mentioned for "Refund".
    Quote Originally Posted by stephen.s13 View Post
    ... For example pressing "Refund" would send the keystrokes "Alt + R"

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.