OP 22 February, 2023 - 04:56 AM
(This post was last modified: 22 February, 2023 - 04:56 AM by PhantomLiar.)
import os
import random
import string
import threading
import win32api
import win32gui
# install pywin32
try:
import win32api
except ImportError:
os.system('pip install pywin32')
# define a function to generate a random string of specified length
def get_random_string(length):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(length))
# define a function to fill a file with random data until its size is at least 1 MB
def fill_file(filename):
with open(filename, 'w') as f:
while os.path.getsize(filename) < 1000000:
f.write('troll' + get_random_string(20) + '\n')
# create a list of filenames for the random text files
filenames = ['file{}.txt'.format(i) for i in range(1, 11)]
# create a thread for each file and start filling them simultaneously
threads = []
for filename in filenames:
t = threading.Thread(target=fill_file, args=(filename,))
t.start()
threads.append(t)
# minimize the terminal window
win = win32gui.GetForegroundWindow()
win32gui.ShowWindow(win, win32con.SW_MINIMIZE)
# open and minimize each file
for filename in filenames:
os.startfile(filename)
handle = win32gui.FindWindow(None, filename)
win32gui.ShowWindow(handle, win32con.SW_MINIMIZE)
# minimize the terminal window again
win = win32gui.GetForegroundWindow()
win32gui.ShowWindow(win, win32con.SW_MINIMIZE)
# wait for all threads to complete before exiting
for t in threads:
t.join()
This is a bump
import random
import string
import threading
import win32api
import win32gui
# install pywin32
try:
import win32api
except ImportError:
os.system('pip install pywin32')
# define a function to generate a random string of specified length
def get_random_string(length):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(length))
# define a function to fill a file with random data until its size is at least 1 MB
def fill_file(filename):
with open(filename, 'w') as f:
while os.path.getsize(filename) < 1000000:
f.write('troll' + get_random_string(20) + '\n')
# create a list of filenames for the random text files
filenames = ['file{}.txt'.format(i) for i in range(1, 11)]
# create a thread for each file and start filling them simultaneously
threads = []
for filename in filenames:
t = threading.Thread(target=fill_file, args=(filename,))
t.start()
threads.append(t)
# minimize the terminal window
win = win32gui.GetForegroundWindow()
win32gui.ShowWindow(win, win32con.SW_MINIMIZE)
# open and minimize each file
for filename in filenames:
os.startfile(filename)
handle = win32gui.FindWindow(None, filename)
win32gui.ShowWindow(handle, win32con.SW_MINIMIZE)
# minimize the terminal window again
win = win32gui.GetForegroundWindow()
win32gui.ShowWindow(win, win32con.SW_MINIMIZE)
# wait for all threads to complete before exiting
for t in threads:
t.join()
This is a bump