Skip to content

Instantly share code, notes, and snippets.

@tropicbliss
Created January 3, 2022 14:16
Show Gist options
  • Save tropicbliss/6b5b60ff0cf26e69eee8fea0942fef4e to your computer and use it in GitHub Desktop.
Save tropicbliss/6b5b60ff0cf26e69eee8fea0942fef4e to your computer and use it in GitHub Desktop.
Hypixel Skyblock Melody Harp Macro
import sys
import time
import pyautogui
mapping = {"1": (1, 2), "2": (1, 2), "3": (1, 2), "4": (
1, 2), "5": (1, 2), "6": (1, 2), "7": (1, 2)}
pause_delay = 1
with open("sheet.txt", 'r') as file:
text = file.read().rstrip()
dialog = pyautogui.confirm("Shall we start?")
if dialog == "Cancel":
sys.exit()
for char in text:
if char in mapping:
position = mapping[char]
pyautogui.moveTo(position)
pyautogui.typewrite("q")
elif not char == '.':
print("Unexpected character found, exiting...")
sys.exit(1)
time.sleep(pause_delay)
@tophat08
Copy link

how do use this

@Streissand
Copy link

Any clue on what you put as sheet.txt? I've tried using the script but without the sheet.txt it won't work as it needs to read the text file first.

@parkerhemming
Copy link

parkerhemming commented Apr 24, 2024

I DID NOT USE THIS, ONLY FIXED THE CODE

I didn't want to macro melody but after countless hours of actually the worst ping in human history I had to (not use this macro). Please do not abuse macros as you will probably get banned. If it doesn't work first try, just keep going till it works. If its glitched or something just use chatGPT lol.

I don't know python so I'm sure my syntax is cringe.

Create the 3 files below in the same directory:
You'll select the macro, then quickly start the song, you can change the initial delay if its too fast.. Use "=" key to stop the macro

GUI Scale: Normal
Fullscreen: Off (But maximized tab)

If anyone wants to add their own song (Ex. La Vie en Rose etc.. its the same as the dude who made the og post, "." for pauses, "1"-"7" for the notes. But yeah if you make txt files for the other songs, reply with them for others to use.

ThroughTheCampfire.txt
23423453645345432342345364534543234234536453454323423453645345432342345364534543234234536453457656545434323213.13.1313313.1316.36.3636636.3635.25.2525525.2432321.3.13.1313313.1316.36.3636736.3635.25.2525525.2432321.27

Pachelbel.txt
6...4...5...2...3...1...3...4...4.3.4.1.1...3..4..5..6..6.7.6.5.4.7.6.5.4.3.2.1.3.3.432..6.456.45612345676.234.23454346563.654.32321234564.656.32345676.456.54534565434.234.4567656.5453.543.32321234564.656.32345674

Melody.py

import sys
import time
import pyautogui
import keyboard

# In the case that your mouse doesnt click the right coords (you may jsut be using a diff gui scale in mc)...
# but you can use a tool like MPos-v.0.5.0 that displays your live mouse coords to get better coords for the following
mapping = {"1": (848, 500), "2": (887, 501), "3": (922, 499), "4": (961, 502), "5": (996, 498), "6": (1036, 501), "7": (1068, 500)}
# this delay is in between all actions, if needed, change it in 0.0002 increments
pause_delay = 0.0484

# Prompt the user to choose the song
sheet_choice = pyautogui.confirm("Choose a song:", buttons=["ThroughTheCampfire", "Pachelbel", "Cancel"])
if sheet_choice == "Cancel":
    sys.exit()
elif sheet_choice == "ThroughTheCampfire":
    sheet_filename = "ThroughTheCampfire.txt"
elif sheet_choice == "Pachelbel":
    sheet_filename = "Pachelbel.txt"

with open(sheet_filename, 'r') as file:
    text = file.read().rstrip()

# Flag to indicate if the script should be terminated
terminate_flag = False

# Function to terminate the script
def terminate_script():
    global terminate_flag
    print("Script terminated by user.")
    terminate_flag = True

# Register the '=' key to terminate the script (you can change this)
keyboard.add_hotkey('=', terminate_script)

# change this to add more time between macro start and song start
time.sleep(3.4)

for char in text:
    if terminate_flag:
        print("Script terminated.")
        break
    
    if char in mapping:
        position = mapping[char]
        pyautogui.moveTo(position)
        pyautogui.typewrite("q")
    elif char == '.':
        time.sleep(0.2)
    elif not char == '.':
        print("Unexpected character found, exiting...")
        sys.exit(1)
    time.sleep(pause_delay)

@AstriB0t
Copy link

I added the other songs and added a calibration/hotkey configuration.
Please note that the files must be in a 'songs/' folder, and have the .txt extension

01HymnToTheJoy.txt

3.3.4.5.5.4.3.2.1.1.2.3.3..22..3.3.4.5.5.4.3.2.1.1.2.3.2..11
0.1484

02FrereJacques.txt

2..3..4..2..2..3..4..2...4..5..6....4..5..6....6.7.6.5.4...2...6.7.6.5.4..2..2..1..2...2..1..2
0.0484

03AmazingGrace.txt

1..3..3...5.4.3.5...4..3...2..1...1..3..3...5.4.3.5...4..6..6....4..6..6...5.4.3.5....4..3...2.1....1..3..3...5.4.3.5...4..3
0.0484

04BrahmsLullaby.txt

1.1.3...1.1.3...1.3.6..5..4.4..3...1.2.3..1..1.2.3...1.3.6.5.4..6..7
0.0484

05HappyBirthdayToYou.txt

1.12..1..3..2....1.12..1..4..3....1..1.6..5..4..3.2....5.54..2..3..2
0.0484

06Greensleeves.txt

3.4..5.6..76.5..4.3..23.4..3.3.23.4..2.1..3.4..5.6..76.5..4.2..34.5..43.2..12.3
0.0484

07Geometry.txt

3.5.3.1.3.5.3...3.5.3.5.765432.2.5.3.1.3.5.3..7.65.43.2.1
0.0984

08Minuet.txt

6.23456.2.2.7.34567.2.2.5.65434.54323.43212
0.0484

09JoyToTheWorld.txt

7.6.54..4.3.21..45..56..67..77654.44321357
0.0484

10GodlyImagination.txt

3.7.2.3.7.2.3.7.2.3.7.2..1.3.5..1.2.5..1.3.6.767676.5.2.3.4..6.7.5..4.3.2.323232.1
0.0484

11LaVieEnRose.txt

6..54.32.65..43.21.54..32.12.54..3...7..65.43.65..43.21.54..32.12.54...3...6..54.32.65..43.21.54..32..1.55...6.6..56.6..56.6..52...6.6..56.6..56.6..57.4..6.1..5654.32.65.1..43.21.54.34.56
0.0484

12ThroughTheCampfire.txt

23423453645345432342345364534543234234536453454323423453645345432342345364534543234234536453457656545434323213.13.1313313.1316.36.3636636.3635.25.2525525.2432321.3.13.1313313.1316.36.3636736.3635.25.2525525.2432321.27
0.0484

13Pachelbel.txt

6...4...5...2...3...1...3...4...4.3.4.1.1...3..4..5..6..6.7.6.5.4.7.6.5.4.3.2.1.3.3.432..6.456.45612345676.234.23454346563.654.32321234564.656.32345676.456.54534565434.234.4567656.5453.543.32321234564.656.32345674
0.0484
import sys
import os
import time
import pyautogui
import keyboard

# change this string depending on your 'drop item' hotkey
DROP_KEY = "a"

# In the case that your mouse doesnt click the right coords (you may jsut be using a diff gui scale in mc)...
# but you can use a tool like MPos-v.0.5.0 that displays your live mouse coords to get better coords for the following
mapping = {"1": (848, 500), "2": (887, 501), "3": (922, 499), "4": (961, 502), "5": (996, 498), "6": (1036, 501), "7": (1068, 500)}
# this delay is in between all actions, if needed, change it in 0.0002 increments
# pause_delay = 0.0484

def calibrate():
    pyautogui.alert("using the incoming tool, get the location of the first and last notes, the program is then going to ask for them.")
    pyautogui.mouseInfo()
    y = int(pyautogui.prompt('y coord ?'))
    x1 = int(pyautogui.prompt('x1 coord ?'))
    x2 = int(pyautogui.prompt('x2 coord ?'))
    step = (x2-x1)//6
    global mapping
    mapping = {str(i+1): (x1+i*step, y) for i in range(0,7)}

def drop_key():
    global DROP_KEY
    DROP_KEY = pyautogui.prompt("what is your drop hotkey?")

# Function to terminate the script
def terminate_script():
    global terminate_flag
    print("Script terminated by user.")
    terminate_flag = True

# Register the '=' key to terminate the script (you can change this)
keyboard.add_hotkey('=', terminate_script)

while True:
    # Prompt the user to choose the song   
    sheet_choice = pyautogui.confirm("Choose a song:", buttons=[file[:-4] for file in os.listdir("./songs/")] + ["❌ Cancel", "🔍 Calibrate", "🔤 Drop Key"])
    if sheet_choice == "❌ Cancel" or sheet_choice == None:
        sys.exit()
    if sheet_choice == "🔍 Calibrate":
        calibrate()
        continue
    if sheet_choice == "🔤 Drop Key":
        drop_key()
        continue
    
    sheet_filename = f"songs/{sheet_choice}.txt"

    with open(sheet_filename, 'r') as file:
        text, pause_delay = map(str.strip, file.read().splitlines())
        pause_delay = float(pause_delay)

    # Flag to indicate if the script should be terminated
    terminate_flag = False

    # change this to add more time between macro start and song start
    time.sleep(3.4)

    for char in text:
        if terminate_flag:
            print("Script terminated.")
            break
        
        if char in mapping:
            position = mapping[char]
            pyautogui.moveTo(position)
            pyautogui.typewrite(DROP_KEY)
        elif char == '.':
            time.sleep(0.2)
        else:
            print(f"Unexpected character found: {char}, exiting...")
            sys.exit(1)
        time.sleep(pause_delay)

@AlextrazaaV1
Copy link

Palu + ratio

@parkerhemming
Copy link

@AstriB0t☝🏻☝🏻👏🏻

@parkerhemming
Copy link

If you’re reading this hypixel devs, fix your game, we don’t want to macro.

@WaffleMaker784
Copy link

How am I supposed to use this? The code flashes a cmd window and just stops. am I missing something?

@tropicbliss
Copy link
Author

Okay if anyone is reading this, you need good ping to use this. I wouldn't recommend using this in the current state

@gercosta
Copy link

gercosta commented Feb 8, 2025

How should one use this without any code knowledge?

@CodeBySumant
Copy link

@AstriB0t
Man Do I have to put this code in main scr and make mod.jar or inject it ? like dll

@Potatoes9411
Copy link

bro you are slow its something called a python script bud

@Tamas162
Copy link

thank you so much i have all songs 100% niw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment