Announcement

Collapse
No announcement yet.

DTR and Keyboard buffer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DTR and Keyboard buffer

    Allright... This will be my first PB/DLL program!!! I got the compiler about a year ago. And have yet have had time to mess around with it!

    I am needeing a program that will monitor the serial port for the DTR signal and then stuff the keyboard buffer with a key!

    Coulld someone point me in the direction to look for some code that will allow me to do this. If it's in the help files then under what commnad or what should I search for.

    This hold Windows program is all new to me I'm so use to DOS programming!

    Thanks for any help you can all give
    Bobby

    ------------------
    Bobby Gage II

  • #2
    Bobby --

    Well, the whole idea of stuffing the keyboard buffer is something that should be avoided in Windows programming, wherever possible. The problem is that Windows has a single keyboard buffer that all programs share. If you stuff a key into it (which can be done with an API function) then whichever program currently has the "keyboard focus" will see the keystroke. In other words, the key will be received by whichever program currently has a dark-blue title bar. If any!

    And it's very difficult, especially with more recent versions of Windows, to force any given window or program into the foreground. Even if you manage to do it, there is no guarantee that the user or another program won't change the focus again, in the split-second between the "set foreground" operation and the "stuff keyboard" operation.

    So first I would recommend that you reconsider your goal, based on that information. If you decide that you really do want to stuff the keyboard buffer, we'll point you toward some sample code. Searching the BBS for KEYBD_EVENT would be a good place to start, and that is likely to lead you to other APIs as well.

    Learning the differences between DOS and Windows can be a slow process, but it's well worth the effort. You will find lots of help on this BBS, from people who have gone through exactly the same thing.

    -- Eric

    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>
    "Not my circus, not my monkeys."

    Comment


    • #3
      Well see I'm trying to make an external box that will simply send out a DTR single and imulate an Enter key. So yes ANY program that is currently in forground would take the enter key. This is what i'm trying to do. Basically the customer's system will not have a keyboard.

      There is alot more to it then this. But this is simply put.

      So thanks for you help and I will search the help files not I got a starting place.

      thanks thanks again,
      Bobby

      ------------------
      Bobby Gage II

      Comment


      • #4
        Er... Windows does not employ a single keyboard buffer for all apps, except under unusual circumstances. I suppose looking at it that way makes it easy to see the "focus issue", though.

        Bobby, is your program actually handling the serial port itself? Or is it hoping to spy on what another program is doing? And what version(s) of Windows do you need to support?

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


        • #5
          > Windows does not employ a single keyboard buffer for all apps

          True, it would be more accurate to say that Windows routes keystrokes to only one application's keyboard buffer at a time. Bobby, if you press a key and the app with the focus does not process it, that does not mean that the next app to get the focus will receive the keystroke.

          -- Eric


          ------------------
          Perfect Sync Development Tools
          Perfect Sync Web Site
          Contact Us: mailto:[email protected][email protected]</A>
          "Not my circus, not my monkeys."

          Comment


          • #6
            ok... this is the deal.. I would like to make a simple little box that will conenct to the computer and a simple switch in the box and connect to a serial line. I'm thinking DTR or something along this line.

            And then when this line is set (button is down) then the computer will simulate an enter key being pressed. If another button is pressed it will simulate a backspace key. I'm hopeing this could be used to controll power point presentations and stuff. But I would like it to interface with anything.

            Basically what I would like is to stuff the keyboard just as if the user pressed a key on it.

            To me this would be easy in DOS but it looks like it's not in Windows. Because I'm already confused with what everyone is saying.



            ------------------
            Bobby Gage II

            Comment


            • #7
              To me, it sounds like modifying a keyboard would be easier... just "extend" the wiring to the ENTER and BACKSPACE keys to the remote keypad.

              There are various presentation software packaages around that can control PowerPoint. I have a good friend who does this kind of thing for a living - if you would like, I'll find out what kind of control software they use and let you know.

              ------------------
              Lance
              PowerBASIC Support
              mailto:[email protected][email protected]</A>
              Lance
              mailto:[email protected]

              Comment


              • #8
                What would probably be easiest would be to interface to the game port (joystick),
                if possible. That's already designed to handle on/off buttons. If you check out
                the COMM function, though, it looks like you could check the DTR status with that.
                Given that you expect to have complete control of the customer's machine (?), I
                don't think there will be any problem with the approach of stuffing the keyboard
                buffer.

                If you do a Forum search for "stuff key", you'll find assorted discussions and
                source code for keyboard stuffing routines.

                ------------------
                Tom Hanlin
                PowerBASIC Staff

                Comment

                Working...
                X