Quit if the application is already running

This commit is contained in:
DevilXD
2022-01-14 15:10:36 +01:00
parent b6229163bf
commit fd030e33f6
3 changed files with 19 additions and 5 deletions

12
main.py
View File

@@ -1,12 +1,13 @@
from __future__ import annotations
import ctypes
import logging
import argparse
from typing import Optional
from twitch import Twitch
from version import __version__
from constants import FORMATTER, LOG_PATH
from constants import FORMATTER, LOG_PATH, WINDOW_TITLE
class ParsedArgs(argparse.Namespace):
@@ -48,6 +49,15 @@ class ParsedArgs(argparse.Namespace):
return logging.NOTSET
# check if we're not already running
try:
exists = ctypes.windll.user32.FindWindowW(None, WINDOW_TITLE)
except AttributeError:
# we're not on Windows - continue
exists = False
if exists:
# already running - exit
quit()
# handle input parameters
parser = argparse.ArgumentParser(
"Twitch Drops Miner (by DevilXD).exe",