old version better
This commit is contained in:
@@ -3029,3 +3029,55 @@
|
||||
2023-11-20 19:31:56,622: Posted to Discord: Potion clicked.
|
||||
2023-11-20 19:31:56,623: Pressing 'Esc' key.
|
||||
2023-11-20 19:31:57,639: Holding 'D' key for a step.
|
||||
2023-11-20 19:47:02,216: Focusing Minecraft window...
|
||||
2023-11-20 19:47:02,216: Please click on the Minecraft window.
|
||||
2023-11-20 19:47:03,216: Starting in 3...
|
||||
2023-11-20 19:47:04,217: 2...
|
||||
2023-11-20 19:47:05,217: 1...
|
||||
2023-11-20 19:47:06,217: Script is now running.
|
||||
2023-11-20 19:47:08,229: Pressing Esc...
|
||||
2023-11-20 19:47:10,245: Minecraft window not detected. Stopping script.
|
||||
2023-11-20 19:53:03,402: Focusing Minecraft window...
|
||||
2023-11-20 19:53:03,402: Please click on the Minecraft window.
|
||||
2023-11-20 19:53:04,402: Starting in 3...
|
||||
2023-11-20 19:53:05,403: 2...
|
||||
2023-11-20 19:53:06,403: 1...
|
||||
2023-11-20 19:53:07,403: Script is now running.
|
||||
2023-11-20 19:53:09,416: Pressing Esc...
|
||||
2023-11-20 19:53:11,432: Minecraft window not detected. Stopping script.
|
||||
2023-11-20 19:56:15,262: Focusing Minecraft window...
|
||||
2023-11-20 19:56:17,272: Pressing Esc...
|
||||
2023-11-20 19:56:19,291: Performing right click.
|
||||
2023-11-20 19:56:20,394: Checking for trade window...
|
||||
2023-11-20 19:56:21,452: Trade window detected.
|
||||
2023-11-20 19:56:21,452: Dragging slider.
|
||||
2023-11-20 19:56:24,462: Taking a screenshot for color search...
|
||||
2023-11-20 19:56:29,666: Color not found on the screen. Using fallback coordinates.
|
||||
2023-11-20 19:56:29,670: Performing left click.
|
||||
2023-11-20 19:56:30,774: Color not found on the screen. Using fallback coordinates.
|
||||
2023-11-20 19:56:30,777: Performing left click.
|
||||
2023-11-20 19:56:31,883: Performing left click.
|
||||
2023-11-20 19:56:31,987: Performing shift click.
|
||||
2023-11-20 19:56:33,488: Posted to Discord: Potion clicked.
|
||||
2023-11-20 19:56:33,492: Performing left click.
|
||||
2023-11-20 19:56:33,595: Performing shift click.
|
||||
2023-11-20 19:56:35,219: Posted to Discord: Potion clicked.
|
||||
2023-11-20 19:56:35,219: Pressing 'Esc' key.
|
||||
2023-11-20 19:56:36,235: Holding 'D' key for a step.
|
||||
2023-11-20 19:56:37,719: Performing right click.
|
||||
2023-11-20 19:56:38,823: Checking for trade window...
|
||||
2023-11-20 19:56:39,868: Trade window detected.
|
||||
2023-11-20 19:56:39,868: Dragging slider.
|
||||
2023-11-20 19:56:42,883: Taking a screenshot for color search...
|
||||
2023-11-20 19:56:46,512: Color found at (2542, 1431). Clicking at this position.
|
||||
2023-11-20 19:56:46,516: Performing left click.
|
||||
2023-11-20 19:56:47,619: Color found at (2542, 1431). Clicking at this position.
|
||||
2023-11-20 19:56:47,623: Performing left click.
|
||||
2023-11-20 19:56:48,731: Performing left click.
|
||||
2023-11-20 19:56:48,835: Performing shift click.
|
||||
2023-11-20 19:56:50,294: Posted to Discord: Potion clicked.
|
||||
2023-11-20 19:56:50,298: Performing left click.
|
||||
2023-11-20 19:56:50,402: Performing shift click.
|
||||
2023-11-20 19:56:51,825: Posted to Discord: Potion clicked.
|
||||
2023-11-20 19:56:51,826: Pressing 'Esc' key.
|
||||
2023-11-20 19:56:52,842: Holding 'D' key for a step.
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import requests
|
||||
import subprocess
|
||||
import time
|
||||
import pyautogui
|
||||
from PIL import Image, ImageGrab
|
||||
import logging
|
||||
|
||||
# Setup logging
|
||||
# Setup logging
|
||||
logging.basicConfig(filename='minecraft_automation_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
|
||||
|
||||
def log_and_print(message):
|
||||
@@ -52,16 +51,12 @@ def find_color_in_image(target_color, image):
|
||||
return None, None
|
||||
|
||||
def focus_minecraft_window():
|
||||
log_and_print("Please click on the Minecraft window.")
|
||||
time.sleep(1)
|
||||
log_and_print("Starting in 3...")
|
||||
time.sleep(1)
|
||||
log_and_print("2...")
|
||||
time.sleep(1)
|
||||
log_and_print("1...")
|
||||
time.sleep(1)
|
||||
log_and_print("Script is now running.")
|
||||
return True
|
||||
log_and_print("Focusing Minecraft window...")
|
||||
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*1.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
|
||||
time.sleep(2)
|
||||
log_and_print("Pressing Esc...")
|
||||
subprocess.run(['xdotool', 'key', 'Escape'])
|
||||
time.sleep(2)
|
||||
|
||||
def check_trade_window():
|
||||
log_and_print("Checking for trade window...")
|
||||
@@ -74,7 +69,7 @@ def check_trade_window():
|
||||
else:
|
||||
log_and_print("Trade window not detected. Adjusting position.")
|
||||
adjustment_combinations = [('a', 0.1), ('d', 0.1), ('a', 0.2), ('d', 0.2)]
|
||||
for _ in range(5): # Try up to five times
|
||||
for _ in range(5): # Try up to three times
|
||||
for key, duration in adjustment_combinations:
|
||||
subprocess.run(['xdotool', 'keydown', key])
|
||||
time.sleep(duration)
|
||||
@@ -92,11 +87,9 @@ def check_trade_window():
|
||||
post_to_discord("Trade window not found.")
|
||||
return False
|
||||
|
||||
def trade_actions():
|
||||
log_and_print("Pressing 'Esc' key to ensure focus.")
|
||||
subprocess.run(['xdotool', 'key', 'Escape'])
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def trade_actions():
|
||||
right_click(2725, 1203)
|
||||
time.sleep(1)
|
||||
|
||||
@@ -139,11 +132,10 @@ def trade_actions():
|
||||
|
||||
return True # Indicate that the trade action was successful
|
||||
|
||||
# Main script execution
|
||||
if not focus_minecraft_window():
|
||||
log_and_print("Minecraft window not detected. Stopping script.")
|
||||
else:
|
||||
for _ in range(40): # Number of trades to perform
|
||||
result = trade_actions()
|
||||
if not result:
|
||||
break # Stop the script if trade window is not detected
|
||||
|
||||
focus_minecraft_window()
|
||||
|
||||
for _ in range(40): # Number of trades to perform
|
||||
result = trade_actions()
|
||||
if not result:
|
||||
break # Stop the script if trade window is not detected
|
||||
+16
-24
@@ -1,7 +1,6 @@
|
||||
import requests
|
||||
import subprocess
|
||||
import time
|
||||
import pyautogui
|
||||
from PIL import Image, ImageGrab
|
||||
import logging
|
||||
|
||||
@@ -52,16 +51,12 @@ def find_color_in_image(target_color, image):
|
||||
return None, None
|
||||
|
||||
def focus_minecraft_window():
|
||||
log_and_print("Please click on the Minecraft window.")
|
||||
time.sleep(1)
|
||||
log_and_print("Starting in 3...")
|
||||
time.sleep(1)
|
||||
log_and_print("2...")
|
||||
time.sleep(1)
|
||||
log_and_print("1...")
|
||||
time.sleep(1)
|
||||
log_and_print("Script is now running.")
|
||||
return True
|
||||
log_and_print("Focusing Minecraft window...")
|
||||
subprocess.run(['xdotool', 'search', '--name', 'Minecraft*1.20.2 - Multiplayer (3rd-party-Server)', 'windowactivate', '--sync'])
|
||||
time.sleep(2)
|
||||
log_and_print("Pressing Esc...")
|
||||
subprocess.run(['xdotool', 'key', 'Escape'])
|
||||
time.sleep(2)
|
||||
|
||||
def check_trade_window():
|
||||
log_and_print("Checking for trade window...")
|
||||
@@ -74,7 +69,7 @@ def check_trade_window():
|
||||
else:
|
||||
log_and_print("Trade window not detected. Adjusting position.")
|
||||
adjustment_combinations = [('a', 0.1), ('d', 0.1), ('a', 0.2), ('d', 0.2)]
|
||||
for _ in range(5): # Try up to five times
|
||||
for _ in range(5): # Try up to three times
|
||||
for key, duration in adjustment_combinations:
|
||||
subprocess.run(['xdotool', 'keydown', key])
|
||||
time.sleep(duration)
|
||||
@@ -92,11 +87,9 @@ def check_trade_window():
|
||||
post_to_discord("Trade window not found.")
|
||||
return False
|
||||
|
||||
def trade_actions():
|
||||
log_and_print("Pressing 'Esc' key to ensure focus.")
|
||||
subprocess.run(['xdotool', 'key', 'Escape'])
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def trade_actions():
|
||||
right_click(2725, 1203)
|
||||
time.sleep(1)
|
||||
|
||||
@@ -139,11 +132,10 @@ def trade_actions():
|
||||
|
||||
return True # Indicate that the trade action was successful
|
||||
|
||||
# Main script execution
|
||||
if not focus_minecraft_window():
|
||||
log_and_print("Minecraft window not detected. Stopping script.")
|
||||
else:
|
||||
for _ in range(40): # Number of trades to perform
|
||||
result = trade_actions()
|
||||
if not result:
|
||||
break # Stop the script if trade window is not detected
|
||||
|
||||
focus_minecraft_window()
|
||||
|
||||
for _ in range(40): # Number of trades to perform
|
||||
result = trade_actions()
|
||||
if not result:
|
||||
break # Stop the script if trade window is not detected
|
||||
Reference in New Issue
Block a user