Skip to content

Commit

Permalink
Fix autostarting
Browse files Browse the repository at this point in the history
  • Loading branch information
zachey01 committed Oct 24, 2024
1 parent 32b5a01 commit b1e0725
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
1 change: 0 additions & 1 deletion SmoothedScroll/models/easing_function.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import TypeVar

from easing_functions.easing import EasingBase

EasingFunction = TypeVar('EasingFunction', bound=EasingBase)
1 change: 0 additions & 1 deletion SmoothedScroll/models/mouse_hook.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ctypes.wintypes


class MSLLHOOKSTRUCT(ctypes.Structure):
_fields_ = [
('x', ctypes.c_long),
Expand Down
2 changes: 0 additions & 2 deletions SmoothedScroll/models/scroll_control.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import re
from time import perf_counter
from typing import Optional, Union, Type, Literal, Iterable

from win32con import VK_SHIFT, VK_CONTROL, VK_MENU

from . import EasingFunction

class ScrollConfig:
Expand Down
1 change: 0 additions & 1 deletion SmoothedScroll/models/timer_task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from time import perf_counter
from typing import Callable


class TimerTask:
def __init__(self, callback: Callable, timeout: int | float):
self.callback = callback
Expand Down
22 changes: 17 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from tkinter import ttk, messagebox
import json
import os
import shutil
import multiprocessing
import threading
from win32con import VK_SHIFT
Expand All @@ -18,6 +17,8 @@
import psutil
import sys
import webbrowser
import shutil
import win32com.client

APP_DATA_PATH = os.path.join(os.getenv('APPDATA'), 'SmoothedScroll')
CONFIG_FILE_PATH = os.path.join(APP_DATA_PATH, "config.json")
Expand Down Expand Up @@ -155,15 +156,26 @@ def toggle_autostart(self):

def manage_autostart(self):
startup_folder = os.path.join(os.getenv('APPDATA'), 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup')
exe_path = sys.executable
exe_path = os.path.abspath(sys.argv[0])
shortcut_path = os.path.join(startup_folder, "SmoothedScroll.lnk")

if self.config["autostart"]:
shutil.copyfile(exe_path, os.path.join(startup_folder, "SmoothedScroll.exe"))
self.create_shortcut(exe_path, shortcut_path)
else:
try:
os.remove(os.path.join(startup_folder, "SmoothedScroll.exe"))
os.remove(shortcut_path)
except FileNotFoundError:
pass

def create_shortcut(self, exe_path, shortcut_path):
import winshell
with winshell.shortcut(shortcut_path) as shortcut:
shortcut.path = exe_path
shortcut.working_directory = os.path.dirname(exe_path)
shortcut.description = "Smoothed Scroll Autostart"
shortcut.icon_location = (exe_path, 0)


def apply_theme(self):
theme = self.theme_var.get()
sv_ttk.set_theme(theme)
Expand Down Expand Up @@ -374,4 +386,4 @@ def start_taskbar_icon():
app = ScrollConfigApp()
start_taskbar_icon()
run_system_tray(app)
app.root.mainloop()
app.root.mainloop()
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pyproject_hooks
pystray
pywin32
sv-ttk
nuitka
nuitka
winshell

0 comments on commit b1e0725

Please sign in to comment.