Skip to content

Commit

Permalink
implementing buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
None authored and None committed May 22, 2023
1 parent c076fda commit d9ef827
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 40 deletions.
103 changes: 97 additions & 6 deletions MiniPyFlyff.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
from tkinter import Tk, Button, Label, Entry, X, LEFT, RIGHT, Frame, Checkbutton, IntVar, Menu, END
import miscs
from tkinter import Button, Label, Entry, X, LEFT, RIGHT, Frame, Checkbutton, IntVar, Menu, END, tix

import keyboardListener
import miniFtool
import helpWindow
import os
import saveConfigs
import toolControl
import miscs
import bufferLoop


root = Tk()
def create_tooltip(widget, text):
balloon = tix.Balloon(widget)
balloon.bind_widget(widget, balloonmsg=text)


root = tix.Tk()

menu_bar = Menu(root)

Expand All @@ -22,7 +30,15 @@
checkbox_var.get(),
lambda:
toolControl.start_stop_mini_ftool(
button_mini_ftool_start_stop)))
button_mini_ftool_start_stop),
entry_buffer,
entry_buffs_hotbar,
entry_previous_hotbar,
entry_buffer_timer,
entry_buffer_shortcut,
lambda:
toolControl.enable_disable_buffer(
button_buffer_disable_enable)))

menu_bar.add_cascade(label="Menu", menu=menu)

Expand All @@ -37,7 +53,7 @@
x = (screen_width / 2) - (window_width / 2)
y = (screen_height / 2) - (window_height / 2)

root.geometry("250x265+" + str(int(x)) + "+" + str(int(y)))
root.geometry("250x400+" + str(int(x)) + "+" + str(int(y)))
root.title("Mini PyFlyff")
if os.path.isfile("icon/PyFlyff.ico"):
root.iconbitmap("icon/PyFlyff.ico")
Expand All @@ -46,6 +62,9 @@
validation_timers = root.register(miscs.validate_input_timers)
validation_keys = root.register(miscs.validate_input_keys)

validation_buffer_timer = root.register(miscs.validate_input_buffer_timer)
validation_buffer_key = root.register(miscs.validate_input_buffer_key)

checkbox_var = IntVar()

label_alt_control = Label(text="Alt Control Key(s):")
Expand All @@ -58,7 +77,7 @@
frame_alt_control_save_button.pack(fill=X, padx=1, pady=1)

button_alt_control_start_stop = Button(frame_alt_control_save_button, text="Enable", width=10)
button_alt_control_start_stop.pack(side=LEFT, padx=1, pady=1)
button_alt_control_start_stop.pack(side=RIGHT, padx=1, pady=1)
button_alt_control_start_stop.config(command=lambda: toolControl.start_stop_alt_control(button_alt_control_start_stop))

label_mini_ftool = Label(text="Mini Ftool Key(s):")
Expand Down Expand Up @@ -97,10 +116,66 @@
button_mini_ftool_enable_disable.config(
command=lambda: toolControl.enable_disable_mini_ftool(button_mini_ftool_enable_disable))

label_buffer = Label(text="Buffer Key(s):")
label_buffer.pack(fill=X, padx=1, pady=1)

entry_buffer = Entry(validate="none")
entry_buffer.pack(fill=X, padx=1, pady=1)

frame_buffer = Frame(root)
frame_buffer.pack(fill=X, padx=1, pady=1)

label_buffs_hotbar = Label(frame_buffer, text="B. Hotbar:")
label_buffs_hotbar.pack(side=LEFT, padx=1, pady=1)
create_tooltip(label_buffs_hotbar, "Buffs Hotbar: The hotkey for the hotbar where your buffs are.")

entry_buffs_hotbar = Entry(frame_buffer, width=2, validate="none")
entry_buffs_hotbar.pack(side=LEFT, padx=1, pady=1)
create_tooltip(entry_buffs_hotbar, "Buffs Hotbar: The hotkey for the hotbar where your buffs are.")

label_preview_hotbar = Label(frame_buffer, text="P. Hotbar:")
label_preview_hotbar.pack(side=LEFT, padx=1, pady=1)
create_tooltip(label_preview_hotbar, "Previous Hotbar: The hotkey to go back to the previous hotbar.")

entry_previous_hotbar = Entry(frame_buffer, width=2, validate="none")
entry_previous_hotbar.pack(side=LEFT, padx=1, pady=1)
create_tooltip(entry_previous_hotbar, "Previous Hotbar: The hotkey to go back to the previous hotbar.")

label_buffer_timer = Label(frame_buffer, text="B. Timer:")
label_buffer_timer.pack(side=LEFT, padx=1, pady=1)
create_tooltip(label_buffer_timer, "Buffer Timer: Delay for the buffer to rebuff your character (Optional).")

entry_buffer_timer = Entry(frame_buffer, width=10, validate="none")
entry_buffer_timer.pack(side=LEFT, padx=1, pady=1)
create_tooltip(entry_buffer_timer, "Buffer Timer: Delay for the buffer to rebuff your character (Optional).")

frame_buffer_2 = Frame(root)
frame_buffer_2.pack(fill=X, padx=1, pady=1)

label_buffer_shortcut = Label(frame_buffer_2, text="Buffer Shortcut:")
label_buffer_shortcut.pack(side=LEFT, padx=1, pady=1)
create_tooltip(label_buffer_shortcut, "Buffer Shortcut: Shortcut to activate the Buffer.")

entry_buffer_shortcut = Entry(frame_buffer_2, validate="none")
entry_buffer_shortcut.pack(fill=X, padx=1, pady=1)
create_tooltip(entry_buffer_shortcut, "Buffer Shortcut: Shortcut to activate the Buffer.")

frame_buffer_3 = Frame(root)
frame_buffer_3.pack(fill=X, padx=1, pady=1)

button_buffer_disable_enable = Button(frame_buffer_3, text="Enable", width=10)
button_buffer_disable_enable.pack(side=RIGHT, padx=1, pady=1)
button_buffer_disable_enable.config(command=lambda: toolControl.enable_disable_buffer(button_buffer_disable_enable))

entry_alt_control_keys.insert(END, saveConfigs.open_json_config()[0])
entry_mini_ftool_key.insert(END, saveConfigs.open_json_config()[1])
entry_mini_ftool_timers.insert(END, saveConfigs.open_json_config()[2])
entry_mini_ftool_shortcut.insert(END, saveConfigs.open_json_config()[3])
entry_buffer.insert(END, saveConfigs.open_json_config()[5])
entry_buffs_hotbar.insert(END, saveConfigs.open_json_config()[6])
entry_previous_hotbar.insert(END, saveConfigs.open_json_config()[7])
entry_buffer_timer.insert(END, saveConfigs.open_json_config()[8])
entry_buffer_shortcut.insert(END, saveConfigs.open_json_config()[9])

entry_alt_control_keys.config(validate="key")
entry_alt_control_keys.config(validatecommand=(validation_keys, "%S"))
Expand All @@ -111,10 +186,26 @@
entry_mini_ftool_timers.config(validate="key")
entry_mini_ftool_timers.config(validatecommand=(validation_timers, "%S"))

entry_buffer.config(validate="key")
entry_buffer.config(validatecommand=(validation_keys, "%S"))

entry_buffs_hotbar.config(validate="key")
entry_buffs_hotbar.config(validatecommand=(validation_buffer_key, "%S"))

entry_previous_hotbar.config(validate="key")
entry_previous_hotbar.config(validatecommand=(validation_buffer_key, "%S"))

entry_buffer_timer.config(validate="key")
entry_buffer_timer.config(validatecommand=(validation_buffer_timer, "%S"))

checkbox_var.set(int(saveConfigs.open_json_config()[4]))

miscs.multithreading(keyboardListener.listener)

miscs.multithreading(lambda: miniFtool.mini_ftool(checkbox_var.get()))

miscs.multithreading(lambda: bufferLoop.buffer_loop(button_mini_ftool_enable_disable))

miscs.multithreading(lambda: bufferLoop.gt_buffer())

root.mainloop()
18 changes: 2 additions & 16 deletions browserControl.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import win32gui
import win32api
import win32con
import time
import virtualKeys
import globalVariables
import windowsAPI


def alt_control_send_keys(key):
if globalVariables.alt_control_on:
window = win32gui.FindWindow("MozillaWindowClass", None)
win32api.SendMessage(window, win32con.WM_KEYDOWN, virtualKeys.vk_code.get(key), 0)
time.sleep(0.1)
win32api.SendMessage(window, win32con.WM_KEYUP, virtualKeys.vk_code.get(key), 0)


def mini_ftool_send_keys(key):
window = win32gui.FindWindow("MozillaWindowClass", None)
win32api.SendMessage(window, win32con.WM_KEYDOWN, virtualKeys.vk_code.get(key), 0)
time.sleep(0.1)
win32api.SendMessage(window, win32con.WM_KEYUP, virtualKeys.vk_code.get(key), 0)
windowsAPI.windows_api(key)
51 changes: 51 additions & 0 deletions bufferLoop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import time
import windowsAPI
import globalVariables
import toolControl
from tkinter import messagebox

mini_ftool_check = False


def buffer_loop(button):
global mini_ftool_check

while True:
try:
if globalVariables.buffer_enable_disabled and globalVariables.buffer_timer:
for key in globalVariables.buffer_keys:

if globalVariables.buffer_enable_disabled and globalVariables.buffer_timer:

if globalVariables.mini_ftool_enable_disabled:
mini_ftool_check = True
toolControl.enable_disable_mini_ftool(button)

windowsAPI.windows_api(globalVariables.buffs_hotbar)
time.sleep(0.1)
windowsAPI.windows_api(key)
time.sleep(3)

windowsAPI.windows_api(globalVariables.previous_hotbar)

if mini_ftool_check:
toolControl.enable_disable_mini_ftool(button)

if globalVariables.buffer_timer and globalVariables.buffer_enable_disabled:
windowsAPI.windows_api(globalVariables.previous_hotbar)

time.sleep(float(globalVariables.buffer_timer))

except Exception as e:
messagebox.showerror("Error", str(e))
time.sleep(5)
continue

time.sleep(0.1)


def gt_buffer():
while True:
windowsAPI.windows_api("1")

time.sleep(10)
16 changes: 14 additions & 2 deletions globalVariables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@

mini_ftool_enable_disabled = False

buffer_enable_disabled = False

alt_control_on = False

mini_ftool_hotkey = None
mini_ftool_shortcut = None

alt_control_key_list = []

mini_ftool_keys = []

mini_ftool_key_timers = []
mini_ftool_key_timers = []

buffer_keys = []

buffs_hotbar = None

previous_hotbar = None

buffer_timer = None

buffer_shortcut = None
21 changes: 18 additions & 3 deletions keyboardListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,25 @@ def send_key(event):
def set_mini_ftool_shortcut(key_sequence, function):
try:
if key_sequence:
globalVariables.mini_ftool_hotkey = keyboard.add_hotkey(key_sequence, function)
globalVariables.mini_ftool_shortcut = keyboard.add_hotkey(key_sequence, function)
else:
if globalVariables.mini_ftool_hotkey:
keyboard.remove_hotkey(globalVariables.mini_ftool_hotkey)
if globalVariables.mini_ftool_shortcut:
keyboard.remove_hotkey(globalVariables.mini_ftool_shortcut)
globalVariables.mini_ftool_shortcut = None
except Exception as e:
messagebox.showerror("Error", "This is not a valid shortcut."
"\n\nError:"
"\n\n" + str(e))


def buffer_shortcut(key_sequence, function):
try:
if key_sequence:
globalVariables.buffer_shortcut = keyboard.add_hotkey(key_sequence, function)
else:
if globalVariables.buffer_shortcut:
keyboard.remove_hotkey(globalVariables.buffer_shortcut)
globalVariables.buffer_shortcut = None
except Exception as e:
messagebox.showerror("Error", "This is not a valid shortcut."
"\n\nError:"
Expand Down
13 changes: 7 additions & 6 deletions miniFtool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
import random
import browserControl
import windowsAPI
import globalVariables
from tkinter import messagebox

Expand All @@ -10,12 +10,13 @@ def mini_ftool(check):
try:
if globalVariables.mini_ftool_on and globalVariables.mini_ftool_enable_disabled:
for key, timer in zip(globalVariables.mini_ftool_keys, globalVariables.mini_ftool_key_timers):
browserControl.mini_ftool_send_keys(key)
if globalVariables.mini_ftool_on and globalVariables.mini_ftool_enable_disabled:
windowsAPI.windows_api(key)

if check == 1:
time.sleep(random.uniform(0, float(timer)))
else:
time.sleep(float(timer))
if check == 1:
time.sleep(random.uniform(0, float(timer)))
else:
time.sleep(float(timer))
except Exception as e:
messagebox.showerror("Error", "There is something wrong with the Mini Ftool Timers. "
"Stop the loop and fix it."
Expand Down
14 changes: 14 additions & 0 deletions miscs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ def validate_input_keys(char):
return True
else:
return False


def validate_input_buffer_key(char):
if char.isalnum():
return True
else:
return False


def validate_input_buffer_timer(char):
if char.isdigit():
return True
else:
return False
Loading

0 comments on commit d9ef827

Please sign in to comment.