Wrote this to help transition my hotkeys over to Button Master format, thought others might be able to use it to.
What does this script do?
The script will read the Toon_server.ini file specified and spit out your hotkeys in the formatting that ButtonMaster.ini will be looking for. It will start with "[Button_1]" and continue until there are no more hotkeys found in the specified file. So if you have a ButtonMaster.ini file already, I would back it up and start with a blank one.
Things you will still need to do after running this:
Example of Output:
Things I used for this are:
VS Code
Python 3.9.x
Lua ButtonMaster
[CODE lang="python" title="hotkey_converter.py"]import re
# Edit the next line with the path to your hotkey file
path = 'C:\Games\Everquest\Server\Toon_server.ini'
results = []
def read_hotkeys(file_path):
with open(file_path, 'r') as data:
for line in data:
line = line.strip()
match = re.search(rf"(^Page\dButton\d+(Name|Line\d+).*)", line)
if match:
yield match.group(1).replace('Name', ' Label').replace('Line', ' Cmd')
def sort_hotkeys(hotkeys):
return sorted(hotkeys)
def append_hotkeys(hotkeys):
for hotkey in hotkeys:
hotkey = hotkey.strip()
match = re.search(r"(^Page\dButton\d+\s((Cmd\d+|Label).*))", hotkey)
if match:
results.append(f"{match.group(2)}")
def format_hotkeys(results):
button_count = 1
previous_cmd = 0
for x in results:
label_match = re.search(r"(Label=.*)", x)
cmd_match = re.search(r"(Cmd\d.*)", x)
if cmd_match:
if previous_cmd == 0:
print(f"[Button_{button_count}]")
print(cmd_match.group(0))
previous_cmd += 1
elif label_match:
print(f"{label_match.group(0)}\n")
button_count += 1
previous_cmd = 0
if __name__ == '__main__':
hotkeys = read_hotkeys(path)
hotkeys = sort_hotkeys(hotkeys)
append_hotkeys(hotkeys)
format_hotkeys(results)[/CODE]
While this has worked well for me, you will still want to review your hotkey output before going into battle. Hopefully this will save you some time.
-Taz
What does this script do?
The script will read the Toon_server.ini file specified and spit out your hotkeys in the formatting that ButtonMaster.ini will be looking for. It will start with "[Button_1]" and continue until there are no more hotkeys found in the specified file. So if you have a ButtonMaster.ini file already, I would back it up and start with a blank one.
Things you will still need to do after running this:
- Copy and paste your results from this script into a vanilla ButtonMaster.ini file
- Start Button Master and assign your hotkeys to your buttons
- Add your button colors
Example of Output:
Code:
----
[Button_2]
Cmd1=/shd resetcamp
Label=Reset CAMP
[Button_3]
Cmd1=/boxr Pause
Label=Pause ME
[Button_4]
Cmd1=/dgga /target clear
Cmd2=/dgga /attack off
Cmd3=/dgga /pet back off
Cmd4=/dgga /alt act 1215
Label=CLEAR
[Button_5]
Cmd1=/dgga /boxr Manual
Label=Camp OFF
[Button_6]
Cmd1=/dgga /boxr Pause
Label=P GRP
----
Things I used for this are:
VS Code
Python 3.9.x
Lua ButtonMaster
[CODE lang="python" title="hotkey_converter.py"]import re
# Edit the next line with the path to your hotkey file
path = 'C:\Games\Everquest\Server\Toon_server.ini'
results = []
def read_hotkeys(file_path):
with open(file_path, 'r') as data:
for line in data:
line = line.strip()
match = re.search(rf"(^Page\dButton\d+(Name|Line\d+).*)", line)
if match:
yield match.group(1).replace('Name', ' Label').replace('Line', ' Cmd')
def sort_hotkeys(hotkeys):
return sorted(hotkeys)
def append_hotkeys(hotkeys):
for hotkey in hotkeys:
hotkey = hotkey.strip()
match = re.search(r"(^Page\dButton\d+\s((Cmd\d+|Label).*))", hotkey)
if match:
results.append(f"{match.group(2)}")
def format_hotkeys(results):
button_count = 1
previous_cmd = 0
for x in results:
label_match = re.search(r"(Label=.*)", x)
cmd_match = re.search(r"(Cmd\d.*)", x)
if cmd_match:
if previous_cmd == 0:
print(f"[Button_{button_count}]")
print(cmd_match.group(0))
previous_cmd += 1
elif label_match:
print(f"{label_match.group(0)}\n")
button_count += 1
previous_cmd = 0
if __name__ == '__main__':
hotkeys = read_hotkeys(path)
hotkeys = sort_hotkeys(hotkeys)
append_hotkeys(hotkeys)
format_hotkeys(results)[/CODE]
While this has worked well for me, you will still want to review your hotkey output before going into battle. Hopefully this will save you some time.
-Taz

