From e640f42eeff7eba237289afefd3fab7fbb66d4ad Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 19 Nov 2023 23:09:35 +0100 Subject: [PATCH] mousescript updated, and autocrafting for kelp --- autocraft9x9.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ mousexy | 20 ---------------- mousexy.py | 28 +++++++++++++++++++++++ 3 files changed, 89 insertions(+), 20 deletions(-) create mode 100644 autocraft9x9.py delete mode 100644 mousexy create mode 100644 mousexy.py diff --git a/autocraft9x9.py b/autocraft9x9.py new file mode 100644 index 0000000..aea0bce --- /dev/null +++ b/autocraft9x9.py @@ -0,0 +1,61 @@ +import subprocess +import time +import pyautogui +import requests + +def log_and_print(message): + print(message) + # Add logging here if needed + +def post_to_discord(message): + webhook_url = 'https://discord.com/api/webhooks/1171735460729606145/Fyls4_uD7it29TNo7LktQFynb3k1K-BHLx9Y4WqzDK806o1_bVTNz94JNc996kDi-jE6' + data = {"content": message} + response = requests.post(webhook_url, json=data) + log_and_print(f"Posted to Discord: {message}") + +def focus_minecraft_window(): + log_and_print("Focusing Minecraft window...") + # Replace with the exact window title of your Minecraft game + subprocess.run(['xdotool', 'search', '--name', 'Minecraft*1.20.2 - Multiplayer (3rd-party Server)', 'windowactivate', '--sync']) + time.sleep(1) + log_and_print("Minecraft window focused.") + pyautogui.click() # Left-click to capture the game window + + +def shift_click(x, y): + log_and_print(f"Performing shift click at ({x}, {y}).") + pyautogui.moveTo(x, y, duration=0.1) + pyautogui.keyDown('shift') + pyautogui.click() + pyautogui.keyUp('shift') + +# Coordinates for the inventory slots +inventory_coords = [ + (2511, 1243), (2561, 1247), (2619, 1246), (2668, 1246), (2721, 1247), + (2776, 1248), (2832, 1248), (2887, 1248), (2943, 1246), + (2940, 1294), (2886, 1299), (2833, 1303), (2775, 1302), (2720, 1305), + (2666, 1309), (2617, 1304), (2553, 1304), (2506, 1305), + (2503, 1350), (2556, 1350), (2620, 1350), (2673, 1352), (2734, 1354), + (2772, 1354), (2830, 1353), (2885, 1351), (2939, 1353), + (2942, 1422), (2886, 1422), (2833, 1423), (2771, 1419), (2717, 1421), + (2663, 1421), (2608, 1421), (2557, 1422), (2503, 1419) ] + +# Coordinate for the crafting window +crafting_window_coord = (2855, 1099) + +def shift_click_inventory_slots(): + for i in range(0, len(inventory_coords), 9): + for coord in inventory_coords[i:i+9]: + shift_click(*coord) + time.sleep(0.25) + + shift_click(*crafting_window_coord) + time.sleep(0.25) + +# Main execution +crafted_item = input("Enter the item being crafted: ") +focus_minecraft_window() +shift_click_inventory_slots() +final_message = f"Crafted 256 {crafted_item}(s)." +log_and_print(final_message) +post_to_discord(final_message) \ No newline at end of file diff --git a/mousexy b/mousexy deleted file mode 100644 index f72642e..0000000 --- a/mousexy +++ /dev/null @@ -1,20 +0,0 @@ -import pyautogui -import keyboard - -print("Press 'c' to capture the mouse position. Press 'Esc' to exit.") - -while True: - try: - if keyboard.is_pressed('c'): - x, y = pyautogui.position() - print(f"Position captured: {x}, {y}") - elif keyboard.is_pressed('æ'): - print("Exiting.") - break - except RuntimeError: - continue -#right click: 2725, 1203 -#drag click: 2600, 1399 -#left click: 2450, 1408 -#shift click: 2994, 1105 -# key D D \ No newline at end of file diff --git a/mousexy.py b/mousexy.py new file mode 100644 index 0000000..96f19a0 --- /dev/null +++ b/mousexy.py @@ -0,0 +1,28 @@ +import pyautogui +import keyboard + +print("Press 'c' to capture the mouse position. Press 'Esc' to exit.") + +captured_positions = [] +key_pressed = False + +while True: + try: + if keyboard.is_pressed('c'): + if not key_pressed: + x, y = pyautogui.position() + captured_positions.append((x, y)) + print(f"Position captured: {x}, {y}") + key_pressed = True + else: + key_pressed = False + + if keyboard.is_pressed('Esc'): + print("Exiting.") + break + except RuntimeError: + continue + +print("\nAll captured positions:") +for position in captured_positions: + print(position)