skatos
asked on
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
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
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
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
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
This would depend on what operating system you are developing for.
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...
Coming to think of it actually he could do it on Windows probably as easy using Java as MFC...
>> ...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
Funny, I was under the impression that Java couldn't interact with the system on that level without using JNI.
Exceter
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
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
>> 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
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
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.
>> JNI Would probably be a poor choice for this application
No argument there. :-)
Exceter
No argument there. :-)
Exceter
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.