473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Program that press a key every X time (HELP)

I've some real problems finding info or creating a program that works like this:

Every 5 minute the program will use key F2 (for example)
Every 10 minute it will use arrow down and later arrow up.

Any ideas, examples or guides on how the code should look like?


Hope someone is able to solve this!
(starfox-one@hotmail.com)
May 18 '10 #1
4 3942
donbock
2,426 Expert 2GB
Do you mean that every few minutes the program can expect the operator to press those keys? Or do you mean that every few minutes the program will simulate depression of those keys in order to affect some other program?
May 18 '10 #2
I would like to make a program that will simulate depression of some keys in order to affect an other program of mine. To give exact information, I would like to have codes so I can make a program which will:

Use F1 every 2 minute.
Use F2 every 4 minute.
Use left arrow once and right arrow once every 10min.

Hope you understand me better.
May 18 '10 #3
jkmyoung
2,057 Expert 2GB
Are you having problems with:
1. The timing?
2. The pressing of the key?

Do you have any other conditions on the running of the program? If not, you could just use sleep() or usleep() functions to get the program to sleep until it needs to 'press a key'
If you need the program to be active, you will have to spawn a seperate thread to initiate the keystrokes.
May 18 '10 #4
Would this works for example?


#include <iostream>
#include <windows.h>
using namespace std;

int main()

{
for(;;){
int t=60;
Sleep(1000);
keybd_event(VK_F12, 0, 0, 0);
Sleep(1000);
VK_F12, 0, KEYEVENTF_KEYUP,
cout << "F12 pressed, Eating";
Sleep(t*1000);

}
return 0;
}

I haven't touched C++ or any kind of language/code for three years. I'm making this program for my brother who will use it while playing a game called Tibia. F12 ingame is eating food.

EDIT: I've problem to get it work ingame
May 18 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: los | last post by:
Hi, I'm trying to create a program similar to that of Google's desktop that will crawl through the hard drive and index files. I have written the program and as of now I just put the thread to...
0
by: Chad | last post by:
I have COM component embedded on html page. It has version 1.0.0.1 (by default). I have converted it in cab file. Code of html is something like: <HTML><HEAD></HEAD><BODY><OBJECT...
2
by: Gary Jackson | last post by:
Hi All Hop u can help me with my problem, I am new to c++ and have started an application, on my form I have a number of edit boxes and each one is incremented by 1 each time a specific key is...
7
by: yonatnl | last post by:
why In every time I pressing Ctrl + Shift + B, Visual Studio Compiles The solution? I Did not changed a thing in the Code. It was Ok 2 days a Go... and After getting Latest Version from the...
3
by: palepimp | last post by:
Hello all, I have searched far and wide for a solution to my issue. In short, here is the problem: 1. 3 PC's enter data into an Access 2003 database (PC's are running Vista w/ Office 2007...
1
by: yuva | last post by:
"Thank you for this amazing program. Within a weekend, my team increased with 50 new people joining. Every time I logged on there was a new affiliate. Absolutely amazing. " S. Horvath SOUTH AFRICA...
26
by: Ravindra.B | last post by:
I have declared a global variable which is array of pointers and allocated memory for each array variable by using malloc. Some thing similar to below... static char *arr; main() { int i;
9
by: Joergen Bech | last post by:
I have an app that needs to run with elevated privileges on Windows Vista (Registry operations - don't ask). I have added a manifest file that looks like this: ---snip--- <?xml version="1.0"...
1
by: OBAFGKM_RNS | last post by:
In my html, I have an embedded sound wav. I access that sound from my javascript using Play() and Stop(). However, once stopped, the sound will aways resume from where it left off, (making Stop...
0
by: John Kotuby | last post by:
Hi all, I am trying to add some advanced search tools to a standard HTML website by using an Iframe whose SRC attribute points to a remote ASP.NET site which contains the advanced search tool...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.