Program to launch and mirror another program
Hi everyone. I was hoping to get a few pointers in the right direction.. not necessarily any specific code. I'm trying to create a program that would basically launch one and that would also create two more instances of that program, without their GUI preferably, but that would mirror my keyboard commands and and mouse click commands from the primary instance to each of the non-shown instances. So basically, if I were to do something in my main program, the exact same thing would be done in two separate instances of the same program.
I'm kind of lost on how to make that happen. Thanks for any help you can offer.
Re: Program to launch and mirror another program
Why do you need to invoke the two hidden instances of the application?
Re: Program to launch and mirror another program
They don't necessarily have to be hidden instances, but because the purpose of the program will be to make them do the same as the visible instance, there shouldn't be any need for them to be visible.
Re: Program to launch and mirror another program
...why do you need to do this? There might be a better way to accomplish your end goal.
Re: Program to launch and mirror another program
You didn't tell, what exactly do you want to achieve. May be there are many other solutions of your problem.
Re: Program to launch and mirror another program
I'm playing an asteroids mining game and I want to run 3 of them at the same time.. That way I can have 3 guys mining an asteroid while only having to control one of them.
The game launches and you load a character and then move your guy around and mine asteroids and collect objects and sell them.
I used to have a program a friend wrote for me in Delphi that did the same thing, but I've since lost it, and now that I am a CS student studying java I want to learn how to actually write one myself.
Re: Program to launch and mirror another program
As far as i understood as per your description, you need to let three players lie mines while controlling one and other two will be random, right?
Re: Program to launch and mirror another program
Not exactly, but kind of. So it should work something like this.
Three players: Char A, Char B, Char C.
The way the game works is you launch the application, select your character and play. All characters can share the same space and mine the same asteroid. The idea of having all three of them do it is to speed the process up. Three doing the same thing instead of one. But I can't have the other two be random, I need to have them do whatever the first one is. Under normal circumstances, I could just launch three instances of the program, manually select each character and go about doing the same thing, but then I'd have to manually control all three characters.
What I'd like to do, and the way the other program I had worked is like this:
Launch multitasking app (the one I'm trying to write) and then select which character will be Char A. Then select which characters will be B and C.
Launch active game application with Char A and play normally. Simultaneously, launch two additional hidden instances of the same application AS Char B and Char C.
Now all three characters are in the game at the same point. What I want to have happen is have all of Char B and Char C's actions match what is actively done in the GUI as Char A. So if Char A moves left, so do B & C. If Char A mines an Asteroid, B & C do also. If A sells mined ore, so do B & C, etc.
The game is tile based, so you move by clicking which tile to move to.. So theoretically, all movements should be the same .
Re: Program to launch and mirror another program
Take a look at the Robot class.
Re: Program to launch and mirror another program
My understanding of the robot class was that it actively controls your mouse or keyboard, but doesn't just mimic your movements right? Like, I could have a robot class click a button at position x,y, but I couldn't simultaneously click that button in another location on a different instance? Robots are pre-programmed right? So it would only handle pre-programmed movements? Like robot.keypressed(VK_SPACE) or something like that.
What I'm trying to do is kind of like multiboxing / dualboxing.
Is there some way to launch the application and "listen" for commands it sends? For instance.. when I want to shoot an asteroid, I click that asteroid, and it is selected or targeted. Then I click the command to shoot it. So is there any way to "listen" for some command like "asteroid13.isSelected" or something like that, and then use a generic form of that in my program? Probably not.. I think I'm getting ahead of myself. I don't really know enough about it I think. I mean, I know that the client program sends some sort of command to the server application that says I have targeted a specific asteroid, or that I have engaged it, but I don't know if there is anyway to figure out what that specific command is, and emulate it with a separate program.
Re: Program to launch and mirror another program
Okay, I finally see what you're saying. Depending on what exactly the actions are, you could pull this off using the Robot class, but it's going to get complicated if you're doing any non-trvial actions (Just clicking? Dragging? Keyboard commands? Combinations?).
Are you trying to do this with an existing game/program? Or are you trying to create a game from scratch that would contain this behavior?
If the former, you might be out of luck. This is exactly the kind of thing that most game designers make difficult, for valid reasons.
If the latter, you have access to the code, so you'd simply implement some kind of communication interface where one game told the other instances of the game what was happening.
Re: Program to launch and mirror another program
This is for an existing game. I know that it is possible, I'm just not sure how. As I mentioned, a friend of mine made a program a few years ago that did the same thing, but I have since lost that program, and don't know how it worked. I'm not sure how the robot class would work.
I launch and control Instance A of the program normally. What I'm trying to do is to simultaneously launch Instance B and Instance C of the same program (hidden or otherwise) and simply repeat each action I perform in Instance A. So I imagine (although I'm sure I'm wrong) it works something like this in pseudo-code..
Launch Instance A of program and login as Character A. GUI opens normally and operates normally.
At the same time, launch Instance B to log in as Character B and Instance C to log into Character C. Now all three characters are logged in in separate instances, and in game at the same location.
Now Instance B and C just 'listen' for actions performed by me manually in Instance A, and repeat them. So if I make Char A move to Node 25, B and C move to Node 25. If I make Char A target Asteroid 13, B and C also target Asteroid 13.
This of course assumes that at some point my client program sends certain actions that can be 'repeated' for B and C. When I click a specific node or tile in game, it sends a command to the server to 'update my location' to that specific node. I just don't know what that command is. Not sure if there is anyway to find it either.
Re: Program to launch and mirror another program
Ok, after talking to said friend who wrote the original program, I've learned how he did it (although not how to do it again, which is what I'm after).
Basically, he created a new socket connections to the server for the cloned characters, and logged in Chars B and C in through those sockets. Then he just copied all traffic from the socket that corresponds to the main user-controlled program to sockets B and C. So it doesn't really matter what command is sent, if A sends it, B and C send it.
Re: Program to launch and mirror another program