slagfag
This commit is contained in:
@@ -1,52 +1,44 @@
|
||||
#autoclick 2.0
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from pynput.mouse import Button, Controller as MouseController
|
||||
from pynput.keyboard import Listener, KeyCode
|
||||
import time
|
||||
# Function to execute a command using ydotool
|
||||
def execute_ydotool_command(command):
|
||||
try:
|
||||
subprocess.run(command, check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error executing {' '.join(command)}: {e}", file=sys.stderr)
|
||||
|
||||
mouse = MouseController()
|
||||
# Function to simulate mouse click
|
||||
def ydotool_click(x, y, button='left', repeat=1):
|
||||
# Move the mouse to the specified coordinates
|
||||
execute_ydotool_command(['ydotool', 'mousemove', str(x), str(y)])
|
||||
button_arg = '1' if button == 'left' else '2'
|
||||
for _ in range(repeat):
|
||||
execute_ydotool_command(['ydotool', 'click', button_arg])
|
||||
|
||||
coordinates = []
|
||||
click_type = input("Enter click type (left or shift+left): ").strip().lower()
|
||||
def main():
|
||||
coordinates = []
|
||||
click_type = 'left'
|
||||
repeat = 1
|
||||
|
||||
def on_press(key):
|
||||
if key == KeyCode(char='x'):
|
||||
# Record the current mouse position
|
||||
coordinates.append(mouse.position)
|
||||
print(f"Coordinate {len(coordinates)} recorded at {mouse.position}")
|
||||
if len(coordinates) >= max_coordinates:
|
||||
# Stop listener if max coordinates reached
|
||||
return False
|
||||
elif key == KeyCode(char='4'):
|
||||
# Execute clicks
|
||||
for pos in coordinates:
|
||||
mouse.position = pos
|
||||
if click_type == "left":
|
||||
mouse.click(Button.left, 1)
|
||||
elif click_type == "shift+left":
|
||||
# Hold shift and click
|
||||
with keyboard.pressed(Key.shift):
|
||||
mouse.click(Button.left, 1)
|
||||
time.sleep(1) # Adjust timing as needed
|
||||
# Ask for repetitions
|
||||
reps = input("How many times to repeat? (default 1): ") or 1
|
||||
try:
|
||||
reps = int(reps)
|
||||
except ValueError:
|
||||
reps = 1
|
||||
print(f"Repeating {reps} times")
|
||||
# Repeat the clicks as per user input
|
||||
for _ in range(reps):
|
||||
for pos in coordinates:
|
||||
mouse.position = pos
|
||||
if click_type == "left":
|
||||
mouse.click(Button.left, 1)
|
||||
elif click_type == "shift+left":
|
||||
with keyboard.pressed(Key.shift):
|
||||
mouse.click(Button.left, 1)
|
||||
time.sleep(1)
|
||||
num_coordinates = int(input("Enter the number of coordinates to record: "))
|
||||
|
||||
for i in range(num_coordinates):
|
||||
while True:
|
||||
coords = input(f"Enter coordinates {i+1} (format x,y): ")
|
||||
try:
|
||||
x, y = map(int, coords.split(','))
|
||||
coordinates.append((x, y))
|
||||
break # Exit the loop if coordinates are valid
|
||||
except ValueError:
|
||||
print("Invalid format. Please enter coordinates in the format x,y.")
|
||||
|
||||
click_type = input("Enter click type (left or right, default left): ") or click_type
|
||||
repeat = int(input("How many times to repeat each click (default 1): ") or repeat)
|
||||
|
||||
for x, y in coordinates:
|
||||
ydotool_click(x, y, button=click_type, repeat=repeat)
|
||||
print(f"Clicked at {x},{y} with {click_type} button, repeated {repeat} times.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
max_coordinates = int(input("How many coordinates? (1-10): "))
|
||||
with Listener(on_press=on_press) as listener:
|
||||
listener.join()
|
||||
main()
|
||||
|
||||
141
craft1.py
Normal file
141
craft1.py
Normal file
@@ -0,0 +1,141 @@
|
||||
import pyautogui
|
||||
import keyboard
|
||||
|
||||
centerX = 0
|
||||
centerY = 0
|
||||
deluje = False
|
||||
gledam = 0
|
||||
premik = 150
|
||||
delay = 100
|
||||
|
||||
class Point:
|
||||
def __init__(self, x, y):
|
||||
self.X = x
|
||||
self.Y = y
|
||||
|
||||
guiPoss = {}
|
||||
guiBarva = {}
|
||||
|
||||
def obrniSeNa(pozicija):
|
||||
global gledam, centerX, centerY, premik
|
||||
if pozicija != gledam:
|
||||
posX = centerX + (pozicija - gledam) * premik
|
||||
posY = centerY
|
||||
pyautogui.moveTo(posX, posY, duration=0.05)
|
||||
gledam = pozicija
|
||||
|
||||
def cakajNaGui(kateri, mode):
|
||||
global guiPoss, guiBarva
|
||||
while True:
|
||||
pixel = pyautogui.pixel(guiPoss[kateri - 1].X, guiPoss[kateri - 1].Y)
|
||||
if (mode == 1 and pixel == guiBarva[kateri - 1]) or (mode == 2 and pixel != guiBarva[kateri - 1]):
|
||||
return
|
||||
|
||||
def cakajNaItem(mode, posX, posY, auto=True):
|
||||
global guiBarvaOzadjaItema, guiBarvaOzadjaItemaHighlight
|
||||
isOk = False
|
||||
while not isOk:
|
||||
y = -2
|
||||
while y < 3:
|
||||
x = -2
|
||||
while x < 3:
|
||||
if auto:
|
||||
preveriAliKonca()
|
||||
pixel = pyautogui.pixel(posX + x, posY + y)
|
||||
if mode == 1: # cakaj da pride na slot
|
||||
if pixel != guiBarvaOzadjaItema and pixel != guiBarvaOzadjaItemaHighlight:
|
||||
return
|
||||
elif mode == 2: # cakaj da gre stran
|
||||
if pixel == guiBarvaOzadjaItema or pixel == guiBarvaOzadjaItemaHighlight:
|
||||
isOk = True
|
||||
if isOk >= 9:
|
||||
return
|
||||
x += 2
|
||||
y += 2
|
||||
isOk = False
|
||||
|
||||
def preveriAliKonca():
|
||||
if not keyboard.is_pressed('Minecraft'):
|
||||
prekini()
|
||||
if not deluje:
|
||||
keyboard.release('Shift')
|
||||
exit()
|
||||
|
||||
def craft(pozicija):
|
||||
global guiPoss, guiBarva, centerX, centerY
|
||||
if not pozicija:
|
||||
pozicija = 10
|
||||
C_recepti = {}
|
||||
I_recepti = {}
|
||||
if pozicija < 6:
|
||||
y = 0
|
||||
x = 0
|
||||
while y < 3:
|
||||
while x < 5:
|
||||
C_recepti[(y, x)] = Point(guiPoss[0].X + x * C_korakX, guiPoss[0].Y + y * C_korakY)
|
||||
I_recepti[(y, x)] = Point(guiPoss[4].X + x * I_korakX, guiPoss[4].Y + y * I_korakY)
|
||||
x += 1
|
||||
y += 1
|
||||
pixelCraftingTable = pyautogui.pixel(guiPoss[0].X, guiPoss[0].Y)
|
||||
pixelReceptiCraftingT = pyautogui.pixel(guiPoss[2].X, guiPoss[2].Y)
|
||||
pixelReceptiInventory = pyautogui.pixel(guiPoss[3].X, guiPoss[3].Y)
|
||||
pixelInventory = pyautogui.pixel(guiPoss[4].X, guiPoss[4].Y)
|
||||
if pixelCraftingTable == guiBarva[0] and pixelReceptiCraftingT == guiBarva[2]: # odprt crafting tabla in recepti
|
||||
y = 0
|
||||
x = 0
|
||||
while y < 3:
|
||||
while x < 5:
|
||||
# Perform the desired crafting action...
|
||||
x += 1
|
||||
y += 1
|
||||
|
||||
def prekini():
|
||||
global deluje
|
||||
deluje = False
|
||||
|
||||
def hotkey_start():
|
||||
global deluje, gledam, centerX, centerY
|
||||
deluje = True
|
||||
gledam = 0
|
||||
centerX, centerY = pyautogui.position()
|
||||
while deluje:
|
||||
preveriAliKonca()
|
||||
zanka()
|
||||
|
||||
def hotkey_stop():
|
||||
global deluje
|
||||
deluje = False
|
||||
|
||||
keyboard.add_hotkey('windows+j', hotkey_start, suppress=False)
|
||||
keyboard.add_hotkey('windows-j', hotkey_stop, suppress=False)
|
||||
keyboard.add_hotkey('e', prekini)
|
||||
keyboard.add_hotkey('esc', prekini)
|
||||
|
||||
# Register hotkeys for crafting
|
||||
for i in range(10):
|
||||
keyboard.add_hotkey('shift+'+str(i), lambda x=i: craft(x))
|
||||
|
||||
|
||||
# Define GUI positions and colors
|
||||
guiPoss[0] = Point(956, 403)
|
||||
guiPoss[1] = Point(802, 402)
|
||||
guiPoss[2] = Point(658, 402)
|
||||
guiPoss[3] = Point(657, 403)
|
||||
guiPoss[4] = Point(954, 403)
|
||||
|
||||
guiBarva[0] = 0xC3C3C3
|
||||
guiBarva[1] = 0xC4C4C4
|
||||
guiBarva[2] = 0xC5C5C5
|
||||
guiBarva[3] = 0xC5C5C5
|
||||
guiBarva[4] = 0xC2C2C2
|
||||
|
||||
# Other variables for crafting logic
|
||||
C_korakX = (1094 - 1023) / 4
|
||||
C_korakY = (516 - 443) / 3
|
||||
I_korakX = (897 - 692) / 4
|
||||
I_korakY = (631 - 478) / 3
|
||||
guiBarvaOzadjaItema = 0x8B8B8B
|
||||
guiBarvaOzadjaItemaHighlight = 0xC5C5C5
|
||||
|
||||
# Start the keyboard listener
|
||||
keyboard.wait()
|
||||
53
craft_gold_bar.py
Normal file
53
craft_gold_bar.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import pyautogui
|
||||
import time
|
||||
from PIL import ImageGrab
|
||||
import logging
|
||||
|
||||
# Setup logging
|
||||
logging.basicConfig(filename='gold_bar_crafting_log.txt', level=logging.INFO, format='%(asctime)s: %(message)s')
|
||||
|
||||
def log_and_print(message):
|
||||
print(message)
|
||||
logging.info(message)
|
||||
|
||||
def click(x, y):
|
||||
pyautogui.moveTo(x, y, duration=0.2)
|
||||
log_and_print(f"Performing left click at ({x}, {y}).")
|
||||
pyautogui.click()
|
||||
|
||||
def find_color_in_image(target_color, search_area):
|
||||
screenshot = ImageGrab.grab(search_area)
|
||||
width, height = screenshot.size
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
if screenshot.getpixel((x, y))[:3] == target_color:
|
||||
# Adjusting coordinates relative to the whole screen
|
||||
return x + search_area[0], y + search_area[1]
|
||||
return None, None
|
||||
|
||||
def craft_gold_bars():
|
||||
log_and_print("Looking for yellow gold bars to craft...")
|
||||
gold_bar_color = (255, 204, 0) # This color might need adjustment
|
||||
crafting_area = (100, 100, 800, 600) # Define your game's crafting area
|
||||
|
||||
gold_bar_x, gold_bar_y = find_color_in_image(gold_bar_color, crafting_area)
|
||||
if gold_bar_x is not None and gold_bar_y is not None:
|
||||
log_and_print(f"Gold bar found at ({gold_bar_x}, {gold_bar_y}). Initiating crafting sequence.")
|
||||
click(gold_bar_x, gold_bar_y) # Click on the gold bar
|
||||
# Add more actions here to perform the crafting, such as clicking on a crafting tool or station
|
||||
else:
|
||||
log_and_print("Gold bar not found within the specified area.")
|
||||
|
||||
def countdown(seconds):
|
||||
for i in range(seconds, 0, -1):
|
||||
print(f"Starting in {i} seconds...", end="\r")
|
||||
time.sleep(1)
|
||||
print("Starting now!")
|
||||
|
||||
# 5-second countdown before the script starts
|
||||
countdown(5)
|
||||
|
||||
# Define the number of attempts or use a condition to keep crafting
|
||||
for _ in range(10): # Adjust based on how many times you want to attempt crafting
|
||||
craft_gold_bars()
|
||||
time.sleep(5) # Wait time between crafting attempts
|
||||
27
import pyautogui.py
Normal file
27
import pyautogui.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pyautogui
|
||||
import keyboard
|
||||
import time
|
||||
|
||||
print("Hover over a position and press 'x' to capture the mouse coordinates. Press 'Esc' to exit.")
|
||||
|
||||
captured_positions = []
|
||||
|
||||
while True:
|
||||
try:
|
||||
if keyboard.is_pressed('x'):
|
||||
x, y = pyautogui.position()
|
||||
if (x, y) not in captured_positions: # Prevent capturing the same position if the key is held down
|
||||
captured_positions.append((x, y))
|
||||
print(f"Position captured: {x}, {y}")
|
||||
time.sleep(0.2) # Add a slight delay to prevent multiple captures for a single press
|
||||
|
||||
if keyboard.is_pressed('esc'):
|
||||
print("Exiting.")
|
||||
break
|
||||
except RuntimeError as e:
|
||||
print(e)
|
||||
continue
|
||||
|
||||
print("\nAll captured positions:")
|
||||
for position in captured_positions:
|
||||
print(position)
|
||||
Reference in New Issue
Block a user