How to write a message to Minecraft chat in the twisted mode, python
It is necessary on the server, on behalf of the player, a certain line was written.
previously wrote through Keyboard
But it is wildly uncomfortable, because Chat opens and due to the fact that the character in motion is written incorrectly, for example wwwwwing the world!
You can simply clamp the Ctrl key before printing the text. And after printing. When the Ctrl is swapped, the text from the keyboard is not printed. And with python continues.
Try using pyautogui – https://pypi.org/project/pyutogui/
import pyautogui Pyautogui.Write ('Hello World!', Interval = 0.25) pyautogui.write (['left', 'left', 'left', 'left', 'left', 'left'])
If you want to open chat, use the mouse (find the chat coordinates on the screen):
pyautogui.moveto (100, 150) # moves the mouse to the x, y - 100, 150 coordinates. Pyautogui.Click () # Press on the left mouse button in current coordinates. Pyautogui.Click (200, 220) # clicks on the left mouse button in X, Y - 200, 220 coordinates.
If you are already in the program, try to open the chat keyboard:
pyautogui.press ('Enter') # simulates the physical press of the Enter key