Can you control another program by using your own program? I'm not asking for specifics, just if it's possible or not?
Can you control another program by using your own program? I'm not asking for specifics, just if it's possible or not?
Depends on the program and depends on what you mean by control....
You can start/terminate programs easily, but if you want to be able to automate stull like opening documents, formatting output etc... (just like you can with M$ Office programs via VBA) then it will depend on what facilities that program provides for you.....
Most programs allow themselves to be controlled by exposing COM interfaces so they can be scripted by languages like VBScript and VBA
well like controlling a tetris piece for example, could i do that?
Depends on what automation interfaces are exposed.....for a game I doubt it.......
ok, thank you
Couldnt you do something like:
SendMessage(HWND of the window, WM_KEYDOWN, VK_LEFT, lParam);
?
"There are three kinds of people in the world...
Those that can count and those that can't."
Yes but simply sending mesages wont properly control a program....Originally posted by Okiesmokie
Couldnt you do something like:
SendMessage(HWND of the window, WM_KEYDOWN, VK_LEFT, lParam);
?
Can you imagine opening a word doc........then having it mail merge with an access database, save the document and then print it all just by sending messages?..
Sending messages would be how a person controls a program.
"Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C
>>> Sending messages would be how a person controls a program.
Of course, but how would you know what messages to send and when? Unless you had the command sequences of the target program, you would have to rely on a published API, (not for a game I suspect), or an interface, which brings us back to imbedding/COM, (also unlikely for a simple game).
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
depending on whats going on, there are a number of ways to send it messages, such as the timeout function often used in splash screens. Depending on how you want your program automated,: create a timer function, then when the timer finishes have it set a value to a bool. after that, in a new function
that will pretty much automate it...however if you're looking to create a program that just automates another (you don't seem to be looking for users to issue the commands) just use a DOS console, much easier to use because it is not event driven like windows programming, it pretty much runs through the code systematically. So, include windows.h and you can send messages to other windows via the normal commands.Code:if (bool whatever==1) { //send message }
so...
it will run through the code without waiting for user prompts...and if you're using it with a tetris game...you can use user events there to do shellExecute() your DOS program, which will run a bunch of commands to control your tetris game.Code:int main() { //send a command //send another //and so on //and so forth return 0; }
Of course I don't know exactly what you're doing, but that's as good of an example I can come up with from what you've typed on the board.
good luck.
Last edited by Waldo2k2; 06-16-2002 at 01:53 PM.
PHP and XML
Let's talk about SAX
But he was talking about a game, therefor if u send the WM_KEYDOWN message with VK_LEFT, you would move the character or whatever to the left, wouldnt u?
"There are three kinds of people in the world...
Those that can count and those that can't."
>>>
therefor if u send the WM_KEYDOWN message with VK_LEFT, you would move the character or whatever to the left, wouldnt u?
<<<
Thuis may work for a simple program, (unless the target is looking for WM_KEYUP of course - common strategy), but how would you start a more sophisticated program? How would you know what values he is expecting from his menu commands for example?
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
You wouldn't. You'd play like a human, move the mouse, and click.
"Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C
What if they are using Direct Input. It would not be as easy as "Sending Messages".
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
Exactly........Simply sending messages will not give you any real control....if you are happy simulating keystrokes and mouse messages and labeling it "control"...well fair enough...Originally posted by MrWizard
What if they are using Direct Input. It would not be as easy as "Sending Messages".
For me control is for stuff like Office Automation and the like