Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 950
  • Last Modified:

Automatic keypress ?

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
skatos
Asked:
skatos
  • 3
  • 3
  • 2
  • +3
1 Solution
 
skeid21Commented:
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
 
mrwad99Commented:
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
 
jcaldwelCommented:
This would depend on what operating system you are developing for.
0
Independent Software Vendors: 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!

 
mrwad99Commented:
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
 
ExceterCommented:
>> ...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
 
mrwad99Commented:
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
 
ExceterCommented:
>> 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
 
jcaldwelCommented:
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
 
ExceterCommented:
>> JNI Would probably be a poor choice for this application

No argument there. :-)

Exceter
0
 
jmcgOwnerCommented:
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
 
SpazMODicCommented:
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.

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now