Results 1 to 5 of 5

Thread: How do you send and capture keystrokes?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2014
    Posts
    19

    How do you send and capture keystrokes?

    Hi, Im trying to figure out how to use the USB thermometer here:
    http://pcsensor.com/index.php?_a=product&product_id=41

    It installs itself as a keyboard to the system and if you press the Capslock key for 2 seconds, it will "type" data like this:
    CAPS LOCK:ON/OFF/++ FW:1.4
    NUM LOCK:OFF/ON/-- UNIT:C
    23.25 1S
    23.25 1S
    23.25 1S
    23.25 1S
    23.25 1S
    23.25 1S
    23.25 1S
    23.25 1s

    Until you hold down Capslock key again for 2 seconds.

    So Im trying to determine how I would get my program to "Hold down" the caps lock key then record the data that is being "typed" by this device. And, once its typed, it only pulls the numeric temperature data to output to a label or text box. Im stuck on the sendkeys part for holding down the key.

    Thanks

  2. #2
    Addicted Member thetimmer's Avatar
    Join Date
    Jan 2014
    Location
    Plano, Texas
    Posts
    243

    Re: How do you send and capture keystrokes?

    It doesn't look like programmatically you can Hold a key down. Look at this post
    _____________
    Tim

    If anyone's answer has helped you, please show your appreciation by rating that answer.
    When you get a solution to your issue remember to mark the thread Resolved.


    reference links

  3. #3
    Member
    Join Date
    Jun 2013
    Location
    KiwiLand
    Posts
    44

    Re: How do you send and capture keystrokes?

    http://www.devepic.com/grabme.php?fi...l%20Basic.docx

    The Above is to explain one way of using sendkeys and numpad, however it should have enough information for you to adapt it to your needs.
    Perhaps one way of doing it would be to setup a timer or a loop that "spams" the capslock key very quickly?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How do you send and capture keystrokes?

    You can send Windows messages that correspond to a key being depressed and a key being released. If you were to send those two messages over two seconds apart then that may well correspond to holding down the specified key for two seconds. The thing is though, you have to send a message to a specific window. Maybe if you were to specify the desktop window it would work.

    You should look into using FindWindow to get the handle of the desktop and then using SendMessage to send it the WM_KEYDOWN and WM_KEYUP messages with a greater than two-second delay in between. I'm not 100% sure that it would work but it's my first instinct.

  5. #5
    Addicted Member
    Join Date
    Oct 2008
    Location
    USA
    Posts
    150

    Re: How do you send and capture keystrokes?

    I had a quick look at the link and on the packaging of the device written in bad English it says
    "Supply API function for dll win OS".
    That suggests there is a dll you could use to interface with the device. Something to investigate.
    Last edited by 2ndmessiah; Mar 26th, 2014 at 03:35 PM.
    Think.... Question.....

Posting Permissions

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



Click Here to Expand Forum to Full Width