Control multiple instances of the program at the same time

Tenick

Thread Starter
Joined
Jun 4, 2019
Messages
3
I'm trying to make a bot for a game.
I can open multiple instances of the game client.

My progress of the bot:
Right now I can only run the bot on 1 game window at a time (because I can only focus 1 window at a time), then after the bot finishes doing its task in that 1 game instance, it will move onto the next game instance and do its task and repeat.
(the game instances are stacked on top of each other, and I have a list of each specific instances (processes) in my bot so the bot can just focus on which specific instance it needs to control next)
(I use the user32.dll to do mousemove to that 1 mouse cursor, and windowsinput library to do clicks and keyboard presses)


Problem:
I want the bot to control all the game instances at the same time.
But the problem is it needs to be focused first before it receives mouse/keyboard inputs.

Ideas / What I've done:

  • I tried using the multiple desktop feature of windows 10, opening 1 game instance for every desktop. But I tried running the bot and it doesn't click when I'm not focused on that particular desktop. Also the bot has OCR and it doesn't do OCR correctly if I'm not on that specific desktop that the specific game instance is on.
    (Is there a way to still be able to OCR, say Desktop2's screen even if I'm in Desktop1?, also be able to do mouse click Desktop2's screen even if I'm in Desktop 1?)
  • I'm thinking maybe to use virtual machine, but I don't have much knowledge with it.
    (Is there someway I can use virtual machine to solve my problem?)
  • Maybe multiple mouse cursors and keyboards? Not sure if it's possible.
    (But still the problem of focusing on the game instance is present, so multiple mouse/keyboard might not help)
Again, main point is that I need some way for the bot to be able to control multiple game instances at the same time.

Is this possible?
(if all else fails, I guess I have no choice but to run each instance on different PCs...)
 
Joined
May 27, 2020
Messages
42
Hey Tenick, before I begin, let me just say that I am not completely familiar with programming. I am only about a year in to my self-studies. However, I believe you would be limited to the number of mouse command inputs per computer.
With that said, I would like to say that using virual machines to run your games might be a viable solution depending on how graphic intensive and resource demanding the game is since you will have to designate a set amount of resources (RAM, Cores, etc) to those VMs.
A better solution IMHO would be to find the command sent to the server for the action you are attempting and set your script to complete those commands for each instance.
 

Tenick

Thread Starter
Joined
Jun 4, 2019
Messages
3
Hey Tenick, before I begin, let me just say that I am not completely familiar with programming. I am only about a year in to my self-studies. However, I believe you would be limited to the number of mouse command inputs per computer.
With that said, I would like to say that using virual machines to run your games might be a viable solution depending on how graphic intensive and resource demanding the game is since you will have to designate a set amount of resources (RAM, Cores, etc) to those VMs.
A better solution IMHO would be to find the command sent to the server for the action you are attempting and set your script to complete those commands for each instance.
Hi thanks for replying. I guess I'll give virtual machines a try. I'll come back to share results.
For your 2nd suggestion, It's my first time hearing that kind of approach for automating online software. Do you have any resources that I can read more about that kind of approach?
 
Joined
May 27, 2020
Messages
42
My reply was more based on speculation than on techniques I have read about. However, I would assume you could use a packet sniffer and work your way backwards.
 

Cookiegal

Karen
Administrator
Malware Specialist Coordinator
Joined
Aug 27, 2003
Messages
118,093
I don't know much about games but is this a way of cheating or gaining an advantage over others?
 
Joined
Aug 8, 2008
Messages
3,250
Game bots have nothing to do with cheating in a game. A lot of MMO's and FPS games have bots....and these bots are there just to help the player in a single person game setting, to make it more realistic and fun. Best example is L4D/L4D2....my all time favorite FPS. Which BTW has released a new campaign to the franchise called "The Last Stand".

That said, I think the OP is creating a game and trying to figure out how to code the bots to perform multiple tasks in a certain sequence of events at specific times when the user performs a certain task while at a certain point in the game. This is why the Gaming industry is so lucrative and those guys/gals get paid the big bucks to do such coding.
 

Cookiegal

Karen
Administrator
Malware Specialist Coordinator
Joined
Aug 27, 2003
Messages
118,093
Thanks for the clarification bassfisher6522.
 
Joined
May 27, 2020
Messages
42
I see! Had not even thought of that! That is WAY beyond my understanding of programming so this is where I part. Whatever you do come up with I would love to read about it
 

Couriant

James
Trusted Advisor
Spam Fighter
Joined
Mar 26, 2002
Messages
37,261
Hmm I guess it depends on the game that the bot is used for? like if it's a war game and you are controlling 5 different players to fight 1... so a 5v1 would be unfair... ;)
 
Joined
Aug 8, 2008
Messages
3,250
I see! Had not even thought of that! That is WAY beyond my understanding of programming so this is where I part. Whatever you do come up with I would love to read about it
Beyond my programming knowledge as well but I have a very good understanding of how/why things tend to work.

Yes...me to, I would love to see what the OP ends up with.
 
Joined
Aug 8, 2008
Messages
3,250
Hmm I guess it depends on the game that the bot is used for? like if it's a war game and you are controlling 5 different players to fight 1... so a 5v1 would be unfair... ;)
True but I've not seen a game like that. Then again I'm a co-op/FPS gamer....primarily.
 

Couriant

James
Trusted Advisor
Spam Fighter
Joined
Mar 26, 2002
Messages
37,261
True but I've not seen a game like that. Then again I'm a co-op/FPS gamer....primarily.
I can't say for sure for Windows but for mobile apps, including those that use an emulator like bluestacks to play the MMOs online I can see that happening.. but nowadays it's typically people that have too much (of someones?) money to burn and just going from 1 to 25 in a week that kills the games...
 
Joined
Mar 2, 2019
Messages
1,284
Problem:
I want the bot to control all the game instances at the same time.
But the problem is it needs to be focused first before it receives mouse/keyboard inputs.
I suppose you do not own the game? have no control over game?
You can broadcast mouse messages (or any other messages) to all top level windows in the system:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendnotifymessagew

Important not to forget is to specify HWND_BROADCAST as target window, the rest of parameters specify mouse message.
 

Xsage

Dave
Joined
Jan 8, 2016
Messages
303
That said, I think the OP is creating a game and trying to figure out how to code the bots to perform multiple tasks in a certain sequence of events at specific times when the user performs a certain task while at a certain point in the game. This is why the Gaming industry is so lucrative and those guys/gals get paid the big bucks to do such coding.
I don't think this is the case based on a few things the OP mentioned:

the game instances are stacked on top of each other, and I have a list of each specific instances (processes) in my bot so the bot can just focus on which specific instance it needs to control next
If he was creating in game NPC bots he would not need multiple instances of a process open. There is no effective way to create co-op NPC bots to assist the player fairly without access to the source code, injecting into the process and altering the code itself or developer build modding tools.

I use the user32.dll to do mousemove to that 1 mouse cursor, and windowsinput library to do clicks and keyboard presses
As he is using user32.dll he is trying to simulate mouse clicks through the windows API itself and not through the game's own code. This only works on not very complex games, think puzzle pirates where botting was a major issue, by sending mouseclicks throught he windows API, there is now way for the game to detect that the user is botting using conventional anti-cheat methods.

Also the bot has OCR
OCR is a technique to take a picture of a portion of the screen and use a neural network to convert that image into a string of character as if it was typed by a keyboard. This is used in things like Adobe PDF to convert scanned documents into word documents.

Again, main point is that I need some way for the bot to be able to control multiple game instances at the same time.
He ends on mentioning about his program needing to control multiple game isntances at the same time, which strongly leads me to believe he is refering to a technique called "multi-boxing", there are two versions of multi-boxing:
  1. One where a human sits there and manually controls all players in multiple windows themselves which is acceptable in some game under certain circumstances,.
  2. One where you get a "bot" to control all or most of the windows to automate tasks in the game and farm things like currency and experience without the user needing to be present or control the game, which can be considered cheating and is against the rules in nearly every online game. The OP seems to be going for the latter as he refers to it as a bot. However, this could be consider acceptable in a single play game.

I don't know much about games but is this a way of cheating or gaining an advantage over others?
So without further clarification from the OP, I would agree with this statement ^
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top