Results 1 to 4 of 4

Thread: Need some idea help

  1. #1
    Senior Member crazyfool's Avatar
    Join Date
    Jan 2008
    Posts
    761
    Thanks
    77
    Thanked
    38 times in 38 posts
    • crazyfool's system
      • Motherboard:
      • Striker Extreme
      • CPU:
      • Q6600
      • Memory:
      • OCZ 6400 2 x 2GB
      • Storage:
      • Samsung Spinpoint 500GB
      • Graphics card(s):
      • BFG 8800 GT OC 512MB
      • PSU:
      • Coolermaster Real Power Pro 850w
      • Case:
      • Coolermaster CM-690
      • Operating System:
      • XP, Vista, Windows 7 & Ubuntu
      • Monitor(s):
      • Samsung 2232BW

    Need some idea help

    hey guys,
    I'm trying to write a tray app in c++ for my htpc to take input from my mce remote and translate it into text, like sms on your phone, 1 = abc etc...
    I know pretty much how to do it except for one thing. I want to use hotkeys which can be toggled on or off depending when i want to use the sms input. So if i press 1 it will run the abc() function which will use a timer to count the keypresses within a couple of seconds and translate that into the correct letter/number. However what I can't figure out is what happens when I press 1 which calls abc() and then immediately press 2 which calls def() and then immediately after I press 1 again.
    abc() will still be running when I press 2 and then when I press 1 again it will just increment the count of 1 so instead of getting an output of ada I would get bd.
    I need some way of telling abc() that it needs to finish when another key is pressed and then when it is finished run def().
    I hope this makes sense. If you have any idea, doesn't need to be code, I would appreciate it.
    Thanks.

    EDIT: As a side note, how can I get the program to do nothing indefinately until one of the hotkeys are pressed? Atm I'm using a loop which is using 100% cpu usage:O
    Last edited by crazyfool; 27-09-2010 at 07:23 PM.

  2. #2
    Registered User
    Join Date
    Oct 2010
    Posts
    7
    Thanks
    0
    Thanked
    2 times in 2 posts

    Re: Need some idea help

    Are you saying you have a function called abc() which is invoked when 1 is press and a function def() when 2 press and so on? If that is the case I think this all would be better if they where condensed into one function. Basically you would need one capture function with a threaded timer and a static reference to the last key pressed with a static counter of number times a key has been pressed. If the key pressed is not the same as the last key press the timer can be reset and the letter applied. I could knock up some code if need be.

    To get the program to do nothing other then loop you need to thread it so that you can sleep the program.

  3. Received thanks from:

    crazyfool (31-10-2010)

  4. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    7
    Thanks
    0
    Thanked
    2 times in 2 posts

    Re: Need some idea help

    crazyfool, how did you fair with this problem?

  5. #4
    Senior Member crazyfool's Avatar
    Join Date
    Jan 2008
    Posts
    761
    Thanks
    77
    Thanked
    38 times in 38 posts
    • crazyfool's system
      • Motherboard:
      • Striker Extreme
      • CPU:
      • Q6600
      • Memory:
      • OCZ 6400 2 x 2GB
      • Storage:
      • Samsung Spinpoint 500GB
      • Graphics card(s):
      • BFG 8800 GT OC 512MB
      • PSU:
      • Coolermaster Real Power Pro 850w
      • Case:
      • Coolermaster CM-690
      • Operating System:
      • XP, Vista, Windows 7 & Ubuntu
      • Monitor(s):
      • Samsung 2232BW

    Re: Need some idea help

    Well actually I haven't got around to writing the program as I've been busy with work. Soon as I get a minute though I'll give it another shot. Thanks for the help though.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Crazy Idea
    By Purple in forum Gaming
    Replies: 5
    Last Post: 10-08-2010, 07:08 PM
  2. Game Idea: Racing / Property / Tycoon
    By clutchclutchgas in forum Gaming
    Replies: 6
    Last Post: 09-08-2010, 11:23 AM
  3. Now heres an idea
    By handscombmp in forum General Discussion
    Replies: 14
    Last Post: 06-12-2009, 11:27 AM
  4. Had an idea for a lan rig last night
    By Knoxville in forum Chassis and Mods
    Replies: 13
    Last Post: 01-03-2005, 02:11 PM
  5. deep fried omelette..BAD idea..+more
    By Spud1 in forum Kitchen and Cooking
    Replies: 13
    Last Post: 08-10-2004, 07:53 PM

Posting Permissions

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