?
Solved

Automatic keypress ?

Posted on 2003-02-28
11
Medium Priority
?
948 Views
Last Modified: 2007-12-19
Hi,
I have a little problem here...
as soloution i thought of a little "helper"
that could press a predefined follow of keys...
preferably like 20 times a seccond...
can anyone help me out ? i hope im in the right language with c.
thx
0
Comment
Question by:skatos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +3
11 Comments
 

Expert Comment

by:skeid21
ID: 8050493
I may be the only person, but i'm not sure what your question is or if you are trying to push over some strange joke that i don't get. anyway keep it cool
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 8051476
I think what is required is a small program that sends the same Window messages to the main application window as when the user actually presses a key.

I cannot see off the top of my head how to do this but I am fairly confident that you could do this with MFC by just sending the appropriate message to be picked up in the applications' MESSAGE_MAP, something along the lines of PostMessage(MSG).

You would prob be better off asking this in the MFC section.

- DJ
0
 
LVL 1

Expert Comment

by:jcaldwel
ID: 8057873
This would depend on what operating system you are developing for.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:mrwad99
ID: 8057918
Yeah that is bang on jcaldwel.  If skatos is using Windows then he could use MFC, otherwise it is more likely he would have to use Java.  

Coming to think of it actually he could do it on Windows probably as easy using Java as MFC...

0
 
LVL 8

Expert Comment

by:Exceter
ID: 8058280
>> ...likely he would have to use Java.  

Funny, I was under the impression that Java couldn't interact with the system on that level without using JNI.

Exceter
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 8058327
You may be right Exceter, in fact you probably are; I just assumed that Java could do everything MFC could.

With MFC you need the appropriate handler for the WM_KEY_PRESSED windows message to do whatever is required, then it is simply a case of putting

PostMessage(WM_KEY_PRESSED)

inside some sort of thread or Sleep() controlled loop.

- DJ 16:46GMT
0
 
LVL 8

Expert Comment

by:Exceter
ID: 8058458
>> I just assumed that Java could do everything MFC could.

Never assume. Java cannot do everything MFC can and vise versa. They serve different purposes. Java is used to easily create platform independant applications. It is truly, compile once, run anywhere. That is because Java is an interpreted language. The native machine code intructions to carry out a given task are stored in the JVM(Java Virtual Machine) not the Java class file. The JVM follows the instructions in the class file and executes the appropriate machine instructions to carry out the task. This of course means that each platform must have a different JVM to interpret the class file but that is of little consequence.

By contrast, MFC(Microsoft Foundation Classes) is compiled directly to native machine code and is therefore platform dependant. MFC is simply a collection of C++ libraries that are used to create Windows applications.

If Java wants to interact with the OS on the level skatos desires it would have to resort to JNI(Java Native Interface). This allows native code to be called by the Java application. Of course, this defeats the purpose of writing a program in Java in the first place beacause it turns platfrom independant code into platform dependant code but the interface is there if you need it. It is also possible that by doing this you would end up calling MFC code from Java. :-)

Exceter
0
 
LVL 1

Expert Comment

by:jcaldwel
ID: 8058541
JNI Would probably be a poor choice for this application, The way OSs deal with this is drastically different. It would be difficult to abstract stdio pipes (for Lin/UNIX) and Windows event driven programming into a common interface for Java.

0
 
LVL 8

Expert Comment

by:Exceter
ID: 8058569
>> JNI Would probably be a poor choice for this application

No argument there. :-)

Exceter
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10024369
Nothing has happened on this question in over 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
PAQ, refund points (some interesting comments, but no solution).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0
 

Accepted Solution

by:
SpazMODic earned 0 total points
ID: 10059996
PAQed, with points refunded (50)

SpazMODic
EE Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question