Skip to main content
GameDev.net gamedev.net
🔒 Locked

Timer Events

Started by shortguy465 Apr 22, 2003 at 1:55 PM 9 replies 600+ views
Original Post
shortguy465
shortguy465
Does anybody know how to do a certain event from the computer clock? As in, at 5:30, this happens and does this, or so on, so forth...
Sneftel
Sneftel
What operating system?

And by "doing something", do you mean the OS starts a program? or an already-running program that you wrote does something?


How appropriate. You fight like a cow.
shortguy465
shortguy465
sorry, Windows XP, and an already running program does something. ...although, i would preferably just have the OS start the program-i didn''t know that was possible.
Oluseyi
Oluseyi
at, cron.
shortguy465
shortguy465
AT is for the controlled part...I can already get that, but is there anything (that you know of) to get an event based on the time?
shortguy465
shortguy465
...anybody know how to do this???
rhouve
rhouve
First thing that comes to mind is the task scheduler...though i'm not sure if that's exactly what u had in mind.

If it is you just go to Start->Settings->Control Panel->Scheduled Tasks. Hope that helps if that is what you are after

[edited by - rhouve on April 23, 2003 1:34:29 AM]
shortguy465
shortguy465
well inside of a program's code. i've seen a bunch of 3rd party programs that have it, and i need it for one that i'm making right now, (it's the only thing left in the program) and i looked on the C++ docs and it looks like it's called a timer event, but they don't really show how to set it up.

-EDIT-

Thanks for the suggestion though, rhouve!

[edited by - shortguy465 on April 23, 2003 1:52:14 AM]
rhouve
rhouve
This is something else I thought of maybe it will help...


#include <time.h>

//The the following somewhere else

tm* Time;
time_t tempTime;


//Get current date and time
time(&tempTime);
Time = localtime(&tempTime);


So okay what this does (hopefully) is set "Time" equal to the current time everytime that the above two lines of code are executed. "Time" is a structure with things like hours, seconds, minutes, day, month, etc. So you could possibly just keep updating Time and check it against whatever time that you want and then put your code that you want to execute there. Maybe this is more along the lines you were looking for? Hope that helps.
flangazor
flangazor
You can also write a bot.

Find the current time and set a future time to do something. Then sleep for the appropriate number of milliseconds. Or poll the clock.

Look up Programming Bots, Spiders, and Intelligent Agents in Visual C++ from MicrosoftPress. It is entirely devoted to this subject.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.