Added load file button

This commit is contained in:
LE LOUER Lucas 2023-08-07 17:47:20 +02:00
parent a53d273c99
commit 4f55eac141
2 changed files with 2 additions and 107 deletions

View File

@ -19,7 +19,6 @@ macroEvents = {"events": []}
mouseControl = mouse.Controller()
keyboardControl = keyboard.Controller()
<<<<<<< HEAD
special_keys = {"Key.esc": Key.esc, "Key.shift": Key.shift, "Key.tab": Key.tab, "Key.caps_lock": Key.caps_lock,
"Key.ctrl": Key.ctrl, "Key.ctrl_l": Key.ctrl_l, "Key.alt": Key.alt, "Key.cmd": Key.cmd,
"Key.cmd_r": Key.cmd_r, "Key.alt_r": Key.alt_r, "Key.ctrl_r": Key.ctrl_r, "Key.shift_r": Key.shift_r,
@ -30,9 +29,6 @@ special_keys = {"Key.esc": Key.esc, "Key.shift": Key.shift, "Key.tab": Key.tab,
"Key.f6": Key.f6, "Key.f5": Key.f5, "Key.right": Key.right, "Key.down": Key.down, "Key.left": Key.left,
"Key.up": Key.up, "Key.page_up": Key.page_up, "Key.page_down": Key.page_down, "Key.home": Key.home,
"Key.end": Key.end, "Key.delete": Key.delete, "Key.space": Key.space}
=======
special_keys = {"Key.esc": Key.esc, "Key.shift": Key.shift, "Key.tab": Key.tab, "Key.caps_lock": Key.caps_lock, "Key.ctrl": Key.ctrl, "Key.ctrl_l": Key.ctrl_l, "Key.alt": Key.alt, "Key.cmd": Key.cmd, "Key.cmd_r": Key.cmd_r, "Key.alt_r": Key.alt_r, "Key.ctrl_r": Key.ctrl_r, "Key.shift_r": Key.shift_r, "Key.enter": Key.enter, "Key.backspace": Key.backspace, "Key.f19": Key.f19, "Key.f18": Key.f18, "Key.f17": Key.f17, "Key.f16": Key.f16, "Key.f15": Key.f15, "Key.f14": Key.f14, "Key.f13": Key.f13, "Key.media_volume_up": Key.media_volume_up, "Key.media_volume_down": Key.media_volume_down, "Key.media_volume_mute": Key.media_volume_mute, "Key.media_play_pause": Key.media_play_pause, "Key.f6": Key.f6, "Key.f5": Key.f5, "Key.right": Key.right, "Key.down": Key.down, "Key.left": Key.left, "Key.up": Key.up, "Key.page_up": Key.page_up, "Key.page_down": Key.page_down, "Key.home": Key.home, "Key.end": Key.end, "Key.delete": Key.delete, "Key.space": Key.space}
>>>>>>> 7043313f60759a798761a735a23a23dd99d0135b
record = False
playback = False
@ -53,18 +49,11 @@ def startRecord():
def stopRecord():
<<<<<<< HEAD
global macroEvents, record
mouse_listener.stop()
keyboard_listener.stop()
json_macroEvents = json.dumps(macroEvents, indent=4)
open(os.path.join(appdata_local+"/temprecord.json"), "w").write(json_macroEvents)
=======
global macroEvents
mouse_listener.stop()
keyboard_listener.stop()
macroEvents["events"].pop()
>>>>>>> 7043313f60759a798761a735a23a23dd99d0135b
print('record stopped')
@ -171,17 +160,6 @@ def playRec():
while True:
<<<<<<< HEAD
=======
if record == False:
if is_pressed('è'):
print("pressed 1")
startRecord()
if playback == False:
if is_pressed('à'):
playRec()
>>>>>>> 7043313f60759a798761a735a23a23dd99d0135b
if (record == False and playback == False):
if is_pressed('o'):
keyboardControl.release('o')
@ -214,7 +192,6 @@ while True:
saveFile = True
saveMacro()
<<<<<<< HEAD
if is_pressed('ctrl+n'):
if (record == False and playback == False and len(macroEvents['events']) != 0):
macroEvents = {"events": []}
@ -237,11 +214,5 @@ while True:
if (record == True and playback == False):
if is_pressed('escape'):
keyboardControl.release(Key.esc)
=======
if record == True:
if is_pressed('escape'):
print(read_key())
print("pressed 2")
>>>>>>> 7043313f60759a798761a735a23a23dd99d0135b
record = False
stopRecord()
stopRecord()

View File

@ -2,7 +2,6 @@ import threading
from tkinter import *
from tkinter.ttk import *
from pynput import keyboard
from keyboard import is_pressed
import subprocess
import atexit
import time
@ -47,41 +46,6 @@ def on_release(key):
file_menu.entryconfig('New', state=NORMAL, command=newMacro)
recordSet = True
keyboardControl = keyboard.Controller()
def on_release(key):
global record2, playback2, recordBtn, lengthOfRecord
try:
if key.char == 'è':
if record2 == False:
startRecordingAndChangeImg(False)
if key.char == 'à':
if (record2 == False and playback2 == False):
replay(False)
except AttributeError:
if key == keyboard.Key.esc:
if record2 == True:
stopRecordingAndChangeImg(False)
# def key_released(e):
# global record2, playback2
#
# if e.keysym == 'Escape':
# if record2 == True:
# stopRecordingAndChangeImg(False)
#
# if e.char == 'è':
# if (record2 == False and playback2 == False):
# startRecordingAndChangeImg(False)
# #
# if e.char == 'à':
# if (record2 == False and playback2 == False):
# replay(False)
>>>>>>> 7043313f60759a798761a735a23a23dd99d0135b
def cleanup():
if 'macro_process' in globals():
@ -103,7 +67,6 @@ window.config(menu=my_menu)
def startRecordingAndChangeImg(pressKey=True):
<<<<<<< HEAD
global stopBtn, record2, playback2
playBtn.configure(state=DISABLED)
if playback2 == False:
@ -140,44 +103,6 @@ def replay(pressKey=True):
keyboardControl.release('p')
recordBtn.configure(state=DISABLED)
=======
global stopBtn, lengthOfRecord, record2, playback2
if playback2 == False:
if pressKey:
keyboardControl.press('è')
keyboardControl.release('è')
lengthOfRecord = time.time()
recordBtn.configure(image=stopImg, command=stopRecordingAndChangeImg)
record2 = True
print('function start callled')
def stopRecordingAndChangeImg(pressKey=True):
global recordBtn, lengthOfRecord, record2
if pressKey:
keyboardControl.press(keyboard.Key.esc)
keyboardControl.release(keyboard.Key.esc)
print(time.time() - lengthOfRecord)
lengthOfRecord = (time.time() - lengthOfRecord) + 2
recordBtn.configure(image=recordImg, command=startRecordingAndChangeImg)
playBtn.configure(state=NORMAL)
print('record stoppé')
record2 = False
def replay(pressKey=True):
global playback2, recordBtn
playback2 = True
if pressKey:
keyboardControl.press('à')
keyboardControl.release('à')
recordBtn.configure(state=DISABLED)
threading.Thread(target=buttonDisabledToEnable).start()
def buttonDisabledToEnable():
global playback2, lengthOfRecord
time.sleep(lengthOfRecord)
recordBtn.configure(state=NORMAL)
playback2 = False
def saveMacro():
@ -231,9 +156,8 @@ recordBtn.pack(side=RIGHT, padx=50)
# Stop Button
stopImg = PhotoImage(file=r"assets/button/stop.png")
# window.bind('<KeyRelease>',key_released )
keyboardListener = keyboard.Listener(on_release=on_release)
keyboardListener.start()
window.mainloop()
window.mainloop()