From 162fd2c4552318381b970cbc9375d650e4b6c3f7 Mon Sep 17 00:00:00 2001 From: SirDank <52797753+SirDank@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:58:07 +0530 Subject: [PATCH] 3.5.1 - added: minimise_window(). maximise_window(), restore_window() - code improvements --- dankware/__init__.py | 91 ++++++++++++++++++++++++++++++++++++++------ setup.py | 7 ++-- 2 files changed, 82 insertions(+), 16 deletions(-) diff --git a/dankware/__init__.py b/dankware/__init__.py index 439890a..812d449 100644 --- a/dankware/__init__.py +++ b/dankware/__init__.py @@ -18,6 +18,7 @@ init(autoreset=True) # colorama colours + reset = Style.RESET_ALL black = Fore.BLACK + Style.BRIGHT @@ -47,6 +48,20 @@ white_dim = Fore.WHITE + Style.DIM yellow_dim = Fore.YELLOW + Style.DIM +# --- + +symbols = ('[', ']', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '|', '\\', ';', ':', "'", '"', ',', '.', '<', '>', '/', '?', '`', '~') +words_green = ('true', 'True', 'TRUE', 'online', 'Online', 'ONLINE', 'successfully', 'Successfully', 'SUCCESSFULLY', 'successful', 'Successful', 'SUCCESSFUL', 'success', 'Success', 'SUCCESS') +words_red = ('falsely', 'Falsely', 'FALSELY', 'false', 'False', 'FALSE', 'offline', 'Offline', 'OFFLINE', 'failures', 'Failures', 'FAILURES', 'failure', 'Failure', 'FAILURE', 'failed', 'Failed', 'FAILED', 'fail', 'Fail', 'FAIL') +colours_to_replace = (Fore.BLACK, Fore.BLUE, Fore.CYAN, Fore.GREEN, Fore.MAGENTA, Fore.RED, Fore.WHITE, Fore.YELLOW, Style.BRIGHT, Style.RESET_ALL) +colours_alt = ("BBLACKK", "BBLUEE", "CCYANN", "GGREENN", "MMAGENTAA", "RREDD", "WWHITEE", "YYELLOWW", "BBRIGHTT", "RRESETT") + +# --- + +excluded_prefixes_one = {'22', '10', '205', '30', '11', '55', '215', '29', '7', '6', '26', '214', '33', '21', '28', '127', '136'} +excluded_prefixes_two = {'161.73', '141.163', '143.52', '149.155', '139.222', '137.253', '157.228', '140.97', '146.87', '198.18', '129.169', '50.117', '146.227', '144.32', '134.83', '139.153', '160.5', '194.66', '212.219', '146.191', '129.11', '149.170', '129.67', '138.253', '134.36', '205.164', '192.177', '134.225', '139.133', '152.71', '136.148', '158.223', '137.222', '130.209', '172.252', '143.210', '164.11', '128.41', '147.143', '158.94', '192.168', '138.250', '158.125', '81.87', '134.219', '143.234', '144.82', '152.78', '128.243', '100.64', '130.246', '137.195', '152.105', '150.204', '141.241', '143.167', '139.166', '144.39', '161.74', '147.197', '163.160', '161.112', '136.156', '137.44', '143.117', '129.12', '134.220', '166.88', '134.151', '131.231', '31.25', '129.215', '153.11', '128.40', '142.111', '23.27', '75.127', '144.173', '148.79', '74.115', '192.186', '163.1', '146.176', '193.60', '129.123', '212.121', '142.252', '165.160', '146.97', '148.197', '131.251', '137.108', '163.167', '129.31', '163.119', '194.80', '130.88', '137.73', '147.188', '137.50', '130.159', '131.111', '148.88', '129.234', '131.227', '155.245', '159.92', '146.179', '169.254', '138.40', '144.124', '155.198', '139.184', '128.232', '157.140', '128.240', '158.143', '161.76', '195.194', '138.38', '128.86', '160.9', '146.169', '128.16'} +excluded_prefixes_three = {'8.17.250', '194.36.2', '199.187.168', '192.173.1', '216.151.190', '193.32.22', '72.52.76', '50.93.194', '178.18.29', '74.82.43', '192.84.75', '199.255.208', '208.80.4', '198.12.120', '192.153.213', '8.14.146', '64.158.146', '69.176.80', '192.160.194', '68.68.96', '23.231.128', '173.245.194', '192.84.212', '193.107.116', '198.12.121', '192.41.112', '8.12.162', '216.172.128', '108.171.52', '192.84.76', '173.252.192', '74.122.100', '50.93.197', '141.170.100', '192.173.128', '74.115.2', '209.107.212', '192.195.118', '178.18.28', '192.133.244', '192.68.153', '192.108.120', '194.35.186', '209.107.192', '192.173.4', '194.35.241', '204.113.91', '192.35.172', '193.37.225', '199.33.120', '108.171.32', '209.54.48', '203.12.6', '50.93.196', '50.93.195', '199.48.147', '50.115.128', '192.84.5', '192.171.128', '8.14.84', '192.88.99', '216.218.233', '194.35.192', '192.76.16', '64.145.82', '185.83.168', '74.114.88', '193.37.240', '66.79.160', '69.46.64', '193.39.172', '204.74.208', '192.92.114', '192.84.80', '132.206.125', '194.60.218', '198.144.240', '63.141.222', '192.149.111', '208.123.223', '192.156.162', '192.155.160', '193.39.80', '192.195.105', '50.118.128', '38.72.200', '146.82.55.93', '192.94.235', '132.206.9', '8.14.147', '8.17.251', '192.190.201', '132.206.123', '192.250.240', '50.93.192', '74.115.4', '141.170.96', '192.107.168', '178.18.27', '193.138.86', '198.51.100', '192.100.154', '206.108.52', '74.82.160', '192.76.8', '192.76.32', '37.72.112', '192.88.10', '194.36.121', '205.159.189', '192.18.195', '149.54.152', '103.251.91', '192.195.42', '194.110.214', '199.33.124', '204.16.192', '192.100.78', '178.18.26', '194.35.93', '37.72.172', '208.77.40', '64.92.96', '212.121.192', '192.76.6', '192.249.64', '192.124.46', '211.156.110', '159.86.128', '192.173.2', '192.171.192', '85.12.64', '89.207.208', '199.188.238', '108.171.62', '64.62.253', '31.25.4', '72.13.80', '118.193.78', '8.12.164', '65.162.192', '65.49.24', '130.93.16', '205.209.128', '141.170.64', '50.93.193', '192.150.180', '192.190.202', '5.152.179', '192.150.184', '173.245.64', '209.107.210', '206.165.4', '192.41.128', '65.49.93', '183.182.22', '193.133.28', '199.68.196', '198.12.122', '192.88.9', '209.51.185', '192.12.72', '193.38.143', '149.54.136', '216.151.183', '216.224.112', '192.188.157', '194.36.152', '192.188.158', '31.25.2', '8.17.252', '108.171.42', '192.41.104', '199.127.240', '64.145.79', '193.39.212', '216.185.36', '194.187.32', '8.12.163', '178.18.16', '204.19.238', '173.245.220', '8.14.145', '92.245.224', '192.82.153', '4.53.201', '194.32.32', '192.195.116', '46.254.200', '194.36.1', '66.160.191', '204.13.64', '193.130.15'} + # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- def multithread(function: callable, threads: int = 1, *args, progress_bar: bool = True) -> None: @@ -230,10 +245,6 @@ def random_ip() -> str: - Follows: https://github.com/robertdavidgraham/masscan/blob/master/data/exclude.conf """ - excluded_prefixes_one = {'22', '10', '205', '30', '11', '55', '215', '29', '7', '6', '26', '214', '33', '21', '28', '127', '136'} - excluded_prefixes_two = {'161.73', '141.163', '143.52', '149.155', '139.222', '137.253', '157.228', '140.97', '146.87', '198.18', '129.169', '50.117', '146.227', '144.32', '134.83', '139.153', '160.5', '194.66', '212.219', '146.191', '129.11', '149.170', '129.67', '138.253', '134.36', '205.164', '192.177', '134.225', '139.133', '152.71', '136.148', '158.223', '137.222', '130.209', '172.252', '143.210', '164.11', '128.41', '147.143', '158.94', '192.168', '138.250', '158.125', '81.87', '134.219', '143.234', '144.82', '152.78', '128.243', '100.64', '130.246', '137.195', '152.105', '150.204', '141.241', '143.167', '139.166', '144.39', '161.74', '147.197', '163.160', '161.112', '136.156', '137.44', '143.117', '129.12', '134.220', '166.88', '134.151', '131.231', '31.25', '129.215', '153.11', '128.40', '142.111', '23.27', '75.127', '144.173', '148.79', '74.115', '192.186', '163.1', '146.176', '193.60', '129.123', '212.121', '142.252', '165.160', '146.97', '148.197', '131.251', '137.108', '163.167', '129.31', '163.119', '194.80', '130.88', '137.73', '147.188', '137.50', '130.159', '131.111', '148.88', '129.234', '131.227', '155.245', '159.92', '146.179', '169.254', '138.40', '144.124', '155.198', '139.184', '128.232', '157.140', '128.240', '158.143', '161.76', '195.194', '138.38', '128.86', '160.9', '146.169', '128.16'} - excluded_prefixes_three = {'8.17.250', '194.36.2', '199.187.168', '192.173.1', '216.151.190', '193.32.22', '72.52.76', '50.93.194', '178.18.29', '74.82.43', '192.84.75', '199.255.208', '208.80.4', '198.12.120', '192.153.213', '8.14.146', '64.158.146', '69.176.80', '192.160.194', '68.68.96', '23.231.128', '173.245.194', '192.84.212', '193.107.116', '198.12.121', '192.41.112', '8.12.162', '216.172.128', '108.171.52', '192.84.76', '173.252.192', '74.122.100', '50.93.197', '141.170.100', '192.173.128', '74.115.2', '209.107.212', '192.195.118', '178.18.28', '192.133.244', '192.68.153', '192.108.120', '194.35.186', '209.107.192', '192.173.4', '194.35.241', '204.113.91', '192.35.172', '193.37.225', '199.33.120', '108.171.32', '209.54.48', '203.12.6', '50.93.196', '50.93.195', '199.48.147', '50.115.128', '192.84.5', '192.171.128', '8.14.84', '192.88.99', '216.218.233', '194.35.192', '192.76.16', '64.145.82', '185.83.168', '74.114.88', '193.37.240', '66.79.160', '69.46.64', '193.39.172', '204.74.208', '192.92.114', '192.84.80', '132.206.125', '194.60.218', '198.144.240', '63.141.222', '192.149.111', '208.123.223', '192.156.162', '192.155.160', '193.39.80', '192.195.105', '50.118.128', '38.72.200', '146.82.55.93', '192.94.235', '132.206.9', '8.14.147', '8.17.251', '192.190.201', '132.206.123', '192.250.240', '50.93.192', '74.115.4', '141.170.96', '192.107.168', '178.18.27', '193.138.86', '198.51.100', '192.100.154', '206.108.52', '74.82.160', '192.76.8', '192.76.32', '37.72.112', '192.88.10', '194.36.121', '205.159.189', '192.18.195', '149.54.152', '103.251.91', '192.195.42', '194.110.214', '199.33.124', '204.16.192', '192.100.78', '178.18.26', '194.35.93', '37.72.172', '208.77.40', '64.92.96', '212.121.192', '192.76.6', '192.249.64', '192.124.46', '211.156.110', '159.86.128', '192.173.2', '192.171.192', '85.12.64', '89.207.208', '199.188.238', '108.171.62', '64.62.253', '31.25.4', '72.13.80', '118.193.78', '8.12.164', '65.162.192', '65.49.24', '130.93.16', '205.209.128', '141.170.64', '50.93.193', '192.150.180', '192.190.202', '5.152.179', '192.150.184', '173.245.64', '209.107.210', '206.165.4', '192.41.128', '65.49.93', '183.182.22', '193.133.28', '199.68.196', '198.12.122', '192.88.9', '209.51.185', '192.12.72', '193.38.143', '149.54.136', '216.151.183', '216.224.112', '192.188.157', '194.36.152', '192.188.158', '31.25.2', '8.17.252', '108.171.42', '192.41.104', '199.127.240', '64.145.79', '193.39.212', '216.185.36', '194.187.32', '8.12.163', '178.18.16', '204.19.238', '173.245.220', '8.14.145', '92.245.224', '192.82.153', '4.53.201', '194.32.32', '192.195.116', '46.254.200', '194.36.1', '66.160.191', '204.13.64', '193.130.15'} - while True: first_octet = random.randint(1, 223) @@ -389,14 +400,6 @@ def clr(text: str, preset: int = 1, colour_one: str = white, colour_two: str = r - text & spl = random (default) / colours inside input tuple """ - - symbols = ('[', ']', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '|', '\\', ';', ':', "'", '"', ',', '.', '<', '>', '/', '?', '`', '~') - - words_green = ('true', 'True', 'TRUE', 'online', 'Online', 'ONLINE', 'successfully', 'Successfully', 'SUCCESSFULLY', 'successful', 'Successful', 'SUCCESSFUL', 'success', 'Success', 'SUCCESS') - words_red = ('falsely', 'Falsely', 'FALSELY', 'false', 'False', 'FALSE', 'offline', 'Offline', 'OFFLINE', 'failures', 'Failures', 'FAILURES', 'failure', 'Failure', 'FAILURE', 'failed', 'Failed', 'FAILED', 'fail', 'Fail', 'FAIL') - - colours_to_replace = (Fore.BLACK, Fore.BLUE, Fore.CYAN, Fore.GREEN, Fore.MAGENTA, Fore.RED, Fore.WHITE, Fore.YELLOW, Style.BRIGHT, Style.RESET_ALL) - colours_alt = ("BBLACKK", "BBLUEE", "CCYANN", "GGREENN", "MMAGENTAA", "RREDD", "WWHITEE", "YYELLOWW", "BBRIGHTT", "RRESETT") #styles = (Style.BRIGHT, Style.DIM, Style.NORMAL) @@ -948,6 +951,9 @@ def hide_window() -> None: """ Hides console window + + Related to: + - show_window() """ if os.name == 'nt': @@ -962,6 +968,9 @@ def show_window() -> None: """ Shows console window + + Related to: + - hide_window() """ if os.name == 'nt': @@ -976,6 +985,10 @@ def hide_window_for(duration: int = 3) -> None: """ Hides console window for the given duration + + Related to: + - hide_window() + - show_window() """ from concurrent.futures import ThreadPoolExecutor @@ -987,6 +1000,60 @@ def tmp(): ThreadPoolExecutor(10).submit(tmp) +def minimise_window() -> None: + + """ + Minimises console window + + Related to: + - maximise_window() + - restore_window() + """ + + if os.name == 'nt': + from ctypes import WinDLL + user32 = WinDLL('user32') + user32.ShowWindow(user32.GetForegroundWindow(), 6) + else: + import subprocess + subprocess.call(["xdotool", "getactivewindow", "windowminimize"]) + +def maximise_window() -> None: + + """ + Maximises console window + + Related to: + - minimise_window() + - restore_window() + """ + + if os.name == 'nt': + from ctypes import WinDLL + user32 = WinDLL('user32') + user32.ShowWindow(user32.GetForegroundWindow(), 3) + else: + import subprocess + subprocess.call(["xdotool", "getactivewindow", "windowactivate", "windowmaximize"]) + +def restore_window() -> None: + + """ + Restores console window to its original size + + Related to: + - minimise_window() + - maximise_window() + """ + + if os.name == 'nt': + from ctypes import WinDLL + user32 = WinDLL('user32') + user32.ShowWindow(user32.GetForegroundWindow(), 9) + else: + import subprocess + subprocess.call(["xdotool", "getactivewindow", "windowactivate", "windowrestore"]) + # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- def file_selector(title: str = "Select File", icon_path: str = "") -> str: diff --git a/setup.py b/setup.py index 3562f3c..dc57fac 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ license = "MIT", name = "dankware", - version = "3.5", + version = "3.5.1", author = "SirDank", author_email = "SirDankenstein@protonmail.com", @@ -26,11 +26,10 @@ "fade", "registry key", "error traceback", - "random ip generator", + "random ip", "github scraper", "splash screen", - "hide window", - "file selector", + "windows tools", ], classifiers = [