Last active
August 9, 2023 16:14
-
-
Save 0nelight/9ae3e36d1a97d9e6c3e434e197d4edbe to your computer and use it in GitHub Desktop.
Basic Automation of Chris Titus Winutil
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#Alpha-Version - no UAC handling, no Error-Handling, no checks | |
#pip uninstall -y pywinauto | |
#This is necessary beacuse of Bug with fetching a lot of elements in the current pywinauto-Release : | |
#pip install https://github.com/pywinauto/pywinauto/archive/atspi.zip | |
#Tested with winutil commit f83ffaf0a9acd343dc7470d03d640fceade7450b | |
import pywinauto | |
from pywinauto.application import Application | |
import subprocess | |
from time import sleep | |
def main(): | |
if "Chris Titus Tech's Windows Utility" not in str(pywinauto.findwindows.find_elements()): | |
subprocess.Popen(["powershell", "-Command", "iwr -useb https://christitus.com/win | iex"]) | |
while True: | |
utility = None | |
for el in pywinauto.findwindows.find_elements(): | |
if "Chris Titus Tech's Windows Utility" in str(el): | |
print(el) | |
utility = el | |
break | |
if utility: | |
break | |
sleep(1) | |
app = Application(backend="uia").connect(handle=utility.handle) | |
dlg = app.top_window() | |
dlg.by(name='Tweaks', class_name='Button', control_type='Button').click() | |
dlg.by(name='Desktop', class_name='Button', control_type='Button').click() | |
dlg.by(name='Tweaks', class_name='TabItem', control_type='TabItem').dump_tree(depth=2, max_width=100) | |
dlg.by(name='Run Tweaks ', class_name='Button', control_type='Button').click() | |
dlg.by(name='Tweaks are Finished').exists(timeout=10) | |
dlg.set_focus() | |
dlg.by(name='OK', class_name='Button', control_type='Button').click() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment