|
Answer» I don't think it's possible but I'll ask, just in case.
I have an EXE program which does only one thing when you hit its single button. Is there a way to launch this program and pass it an instruction equivalent to hitting the button from a command line or a batch file ?
*crossing fingers*When in the program, can you press a key to "hit the button" or do you have to use the mouse? If so, what is the key?
Unfortunately, I need to use the mouse. Enter doesn't work and there is no keyboard shortcut.Have you tried alt enter, ctrl enter and shift enter ? ?Yes. And nothing happens (except ALT ENTER that gives a bip).
I know it's the WRONG place to ask but... ...I started learning C++ two weeks ago (just reached the CLASS chapter). So it's much too fresh for me to know if you can control a program through ANOTHER one in C++. But if it's possible, I can change my priorities until I learn how and give up the DOS option.If you understand the Windows API lots of things become possible.
(Don't ask me anything about this, I just copied it)
This code [allegedly] will click a command button in another program using standard Windows API calls. This example clicks the "Open" button that appears in Internet Explorer when you try to open and executable, script, batch file, etc.
Quote #include <windows.h>
int MAIN() {
//create two structures to hold our Main Window handle //and the Button's handle HWND WindowHandle; HWND ButtonHandle;
//this window's caption is "File Download", so we search for it's handle using the FindWindow API WindowHandle = FindWindow(NULL, "File Download");
//the Button's Caption is "Open" and it is a "Button". SPYXX.exe that comes with Microsoft Visual Studio will reveal this information to you ButtonHandle = FindWindowEx(WindowHandle, 0, "Button", "&Open");
//send a message to the button that you are "clicking" it. Surprisingly C++ understands what BM_CLICK is without having to set it. Different than VB SendMessage (ButtonHandle, BM_CLICK, 0 , 0);
return 0; }
The above was found on this page:-
http://www.vbforums.com/showthread.php?t=345259
It is in the VBForums section: VBForums > VBForums CodeBank > CodeBank - C++
Where there is a discussion about
QuoteUse API to programmatically click button of another app There is much more out there about this sort of thing. Google is your friend.
Contrex, you're the man! I needed to be pointed to the right direction and you did just that.
As I said, I just started learning about C++ classes. There's no way I could implement something like that right now. I'm working on a rather complex personal project and there's one essential bridging step which consists of the transfer of data between two different programs, the first being unable to export and the second unable to import. So far, the only way to do it was by using manually a small EXE utility. So either I can control it through my own code or I can write some code that does the same job. I also have restrictions about the C++ compiler I can use (g++, part of the gnu GCC). There is a windows.h header file in the GCC library in which I'll have to dig. Later.
Thanks for shedding some light on my problem. Now I have a better understanding of it. And I know it's feasible.
QuoteGoogle is your friend. Yep, the Google button in my browser is starting to show WEARING marks...
Thanks again, Contrex. I'll see you around, probably in the programming section. Have a nice day.
|