This mechanism was tested exclusively on a pirate server, because its performance on official servers is not guaranteed.
All attempts at application are entirely at your own peril and risk.The implementation is for Windows desktops.
')
So, we will create a simple bot, the purpose of which will be:
1) enter the game;
2) log in to your account;
3) go to the game world;
4) open the mailbox;
5) form and send a letter to another player;
1) Enter the game
In order to enter the game, we need to actually have a pre-downloaded game client.
In our work, we use the exe file Wow.exe. We write his way as follows:
String WowPatch="D:/Wow/Wow.exe";
Here we recorded the path to the Wow executable. Your path will probably be different.
The path is nice, but not enough to start the game.
To run, we need the following code:
String WowPatch="D:/Wow/Wow.exe"; File file =new File(WowPatch); try { Desktop.getDesktop().open(file); } catch (IOException e1) { e1.printStackTrace(); }
As a result of applying the above code, WoW should start on your computer.
We launched WoW and immediately faced a new problem -
How to make the bot automatically enter the login and password of the account?2) Log in to your account
Now? we need to write two more text variables.
String Login="YourLogin"; String Password="YourPassword";
Here we recorded the login and password from the account that we are going to enter. However, if we use out right after that part of the code where we enter the game, there will be trouble. And all because our bot will execute the code, regardless of whether Warcraft is loaded, and the game needs some time to load, if you are working on a weak PC, then it will take even longer.
In order for the login and password not to be “entered” ahead of time, we will pause in our code:
String WowPatch="D:/Wow/Wow.exe"; File file =new File(WowPatch); try { Desktop.getDesktop().open(file); } catch (IOException e1) { e1.printStackTrace(); } Thread.sleep(20000); String Login="YourLogin"; String Password="YourPassword";
Here we paused for 20 seconds. I have more than enough time to load WoW. It is worth noting that right after WoW loading we already have the login field selected by default. All we need to do now is to copy the login from our variable to the clipboard and paste it into the login field:
Robot rb= new Robot(); StringSelection stringSelection = new StringSelection(Login); Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd.setContents(stringSelection, null); rb.keyPress(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_CONTROL);
Here we copied our login to the clipboard and simulated pressing the Ctrl + V combination, pasted the login into the appropriate window.
Now we need to switch to the window for entering the password. This can be done in two ways:
- We can simulate mouse movement and click on the second window.
- We can switch by simulating pressing the Tab button.
We will use the second option, as it is simpler:
rb.keyPress(KeyEvent.VK_TAB); rb.keyRelease(KeyEvent.VK_TAB);
Next, copy our password to the clipboard and paste it:
StringSelection stringSelection2 = new StringSelection(Password); Clipboard clpbrd2 = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd2.setContents(stringSelection2, null); rb.keyPress(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_CONTROL);
Hooray!!! We entered the character selection menu. Now you need to enter the game world.
3) Enter the game world
Now we see the character selection menu on the screen. We probably will not go over and go to the first character that comes across.
In order to enter, we can use two different options:
- Move the mouse cursor to the "Login" button and simulate a click;
- Simulate pressing the Enter button;
The second option is simpler, but if we add a click immediately after the login function, there will again be trouble, so we will pause again, letting the game quietly go to the character selection menu:
Thread.sleep(5000); rb.keyPress(KeyEvent.VK_ENTER); rb.keyRelease(KeyEvent.VK_ENTER);
I am 5 seconds. enough with his head.
Oh miracle, went loading the game world!
4) Open the mailbox
Here we will have to pause again so that WoW has time to load the game world. It is also desirable to pre-prepare the character:
- Close the camera;
- Become a forehead in the mailbox;
To open a mailbox, right-click on it. To do this, we will move the mouse cursor and simulate a click:
Thread.sleep(30000); rb.mouseMove(700, 350); rb.mousePress(InputEvent.BUTTON3_MASK); rb.mouseRelease(InputEvent.BUTTON3_MASK);
Note that the position of the mouse indicated by me, is designed for a screen resolution of 1366x768.
BUTTON3 is exactly the right mouse button.
Mailbox opened, now go to the tab "Send":
rb.mouseMove(200, 550); rb.mousePress(InputEvent.BUTTON1_MASK); rb.mouseRelease(InputEvent.BUTTON1_MASK);
Here we not only simulated the movement of the mouse around the screen, but also made a click with the left mouse button.
Now it's time to fill out and send a letter!
5) Generate and send a letter to another player.
Now we need to fill in the points:
- Receiver name;
- Message subject;
- Message text;
String Name="Name"; String Theme="Theme"; String Text="Text";
To begin with, we place in the clipboard the name of the character and paste it into the appropriate column:
StringSelection stringSelection3 = new StringSelection(Name); Clipboard clpbrd3 = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd3.setContents(stringSelection3, null); rb.keyPress(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_TAB); rb.keyRelease(KeyEvent.VK_TAB);
We inserted the recipient's name and switched to another column. Now you need to insert the subject of the message:
StringSelection stringSelection4 = new StringSelection(Theme); Clipboard clpbrd4 = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd4.setContents(stringSelection4, null); rb.keyPress(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_TAB); rb.keyRelease(KeyEvent.VK_TAB);
They inserted the subject of the message and switched to the third column - the text of the message:
StringSelection stringSelection5 = new StringSelection(Text); Clipboard clpbrd5 = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd5.setContents(stringSelection5, null); rb.keyPress(KeyEvent.VK_CONTROL); rb.keyPress(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_V); rb.keyRelease(KeyEvent.VK_CONTROL);
Pasted the message text. Now it only remains to click on the "Send" button:
rb.mouseMove(200, 520); rb.mousePress(InputEvent.BUTTON1_MASK); rb.mouseRelease(InputEvent.BUTTON1_MASK);
Moved the cursor and left-clicking on "Send."
That's all. Hope this was helpful to anyone. I also very much hope that this article was not perceived as a guide to action and will not lead to an increase in the amount of spam in the game.