==
проверяет равенство значений двух объектовis
проверяет идентичность самих объектов. Его используют, чтобы удостовериться, что переменные указывают на один и тот же объект в памяти>>> str1 = 'hello'
>>> str2 = 'hello'
>>> str1 == str2
True
>>> str1 is str2
True
>>>
>>> str1 = 'hello, my crazy world'
>>> str2 = 'hello, my crazy world'
>>> str1 == str2
True
>>> str1 is str2
False
catalog = f.read().splitlines()
for f in catalog:
try:
app=pywinauto.Application().connect(path=f)
except pywinauto.application.ProcessNotFoundError:
print(f, 'not found')
else:
print("...")
break
wizard=app['7-Zip 19.00 (x64) Setup']
wizard.Install.Click()
time.sleep(5)
wizard.CloseButton.Click()
time.sleep(2)
app=pywinauto.Application().start(r'C:\Program Files\7-Zip\7zFM.exe')
main=app['7-Zip']
main.MenuSelect('Сервис->Настройки...')
settings=app['Настройки']
settings.Button.Click()
settings.ОКButton.Click()
main.Close()
import pywinauto, datetime, threading, time
pid_list=[]; log_list=[]
with open("kill-notepad.log", "a") as log:
log.write(f"{datetime.datetime.now()} | service started, I'am kill all notepad appliction\n")
def logger():
global log_list
if len(log_list)>0:
log_copy=log_list.copy(); log_list=[]
with open("kill-notepad.log", "a") as log:
for i in range(len(log_copy)):
log.write(log_copy.pop(0))
def disabler(main,count):
for i in range(count-count//255):
main.set_transparency(alpha=255-i//(count//255))
def alarm(main):
for i in range(10):
main.Edit.send_keystrokes("НЕЛЬЗЯ ЗАПУСКАТЬ ЭТУ ПРОГРАММУ\n")
def killer():
global pid_list
try:
app=pywinauto.Application().connect(path=r"c:\windows\system32\notepad.exe")
main=app.top_window(); count=10000
if main.process_id() not in pid_list:
pid_list.append(main.process_id())
else:
return
main.set_transparency(alpha=255)
threading.Thread(target=alarm(main)).start()
threading.Thread(target=disabler(main,count)).start()
log_list.append(f'{datetime.datetime.now()} | destroy {main.element_info}\n')
app.kill()
except:
pass
count=0
while True:
if count==10:count=0
time.sleep(1); count+=1
shout=threading.Thread(target=killer)
shout.start()
if count==10:
report=threading.Thread(target=logger)
report.start()
from cx_Freeze import setup, Executable
packages = ['win32serviceutil','win32service','win32event','servicemanager','socket','win32timezone','pywinauto', 'sys', 'datetime', 'not-notepad-service']
build_exe_options = {"packages": packages}
executable = [Executable("not-notepad-service.py")]
setup(name = "StopNotepadService",
version = "1.0",
description = "Stop NotepadApp and Log",
options = {"build_exe": build_exe_options},
executables = executable)