Thread: Newbie Question

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    21

    Newbie Question

    Hi,
    Basically i need to write a program that will press space every 40 minutes, ive started learning c++ but there appears to be no mention on how to do this in the book i have

    Any help greatly appreciated.

    Thx in advance.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    hmm

    Ke-wha? Press space??? What do you mean? Output a " " (space) to the screen? Every FOURTY MINUTES????? I don't think that I understand what you mean...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    21
    Essentially, i want it to act as if im pressing space every 40 minutes. Surely its more than a case of

    cout << " ";

    Although i could be wrong.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    you need to use a timer of some sort. You can interupt your program flow for forty minutes and cout a space at that interval using an endless loop and any number of built in timers, like system("pause"), or sleep(), or delay(). If you don't want to interupt program flow then you need to get into multithreading, a topic I am aware of, but not competent in.

  5. #5
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    if you are using windows then
    Code:
    Sleep(1000*60*40); //One thousand Milliseconds(1 sec)times 60(one min)times 40(40 mins)
    cout << " ";
    include windows.h.

    if you are using anything else then
    Code:
    delay(1000*60*40);
    cout << " ";
    include dos.h.

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Lightbulb Hmm

    Hmm, you want to simulate a keyboard press every 40 min? So if you happen to be in notepad at that moment, an extra " " will be written..?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  7. #7
    Registered User
    Join Date
    Nov 2001
    Posts
    21
    yes, exactly like that

  8. #8
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    if this is a windows program you can use SendMessage().
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  9. #9
    Registered User
    Join Date
    Nov 2001
    Posts
    21
    its not a windows program, as i say, at this moment in time i know next to nothing, DOS only im afraid

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  2. C prog newbie question
    By Draginzuzu in forum C Programming
    Replies: 1
    Last Post: 02-03-2003, 06:45 PM
  3. a stupid question from a newbie
    By newcomer in forum C++ Programming
    Replies: 4
    Last Post: 01-11-2003, 04:38 PM
  4. confusion with integers (newbie question)
    By imortal in forum C Programming
    Replies: 7
    Last Post: 12-06-2002, 04:09 PM
  5. newbie class templates question
    By daysleeper in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2001, 09:50 AM