-
Notifications
You must be signed in to change notification settings - Fork 3
/
main-2.3.py
1661 lines (1597 loc) · 83.3 KB
/
main-2.3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Version: 2.3
# Release date: 04.11.2022 (dd/mm/yyyy)
version = 2.3
from wmi import WMI
from time import sleep
from requests import get
from ctypes import windll
from pytz import timezone
from subprocess import run
from hashlib import sha256
from pythonping import ping
from itertools import cycle
from getpass import getpass
from winshell import startup
from threading import Thread
from datetime import datetime
from pyuac import isUserAdmin
from termcolor import colored
from cursor import hide, show
from platform import win32_ver
from messagebox import askyesno
from tempfile import gettempdir
from speedtest import Speedtest
from colorama import Fore, Style
from urllib.parse import urlparse
from dns.resolver import Resolver
from webbrowser import open as web_open
from sys import argv, executable, stdout
from win32api import GetLogicalDriveStrings
from powerplan import get_current_scheme_guid
from shutil import copyfile, rmtree, get_terminal_size
from discord_webhook import DiscordWebhook, DiscordEmbed
from logging import info, debug, error, basicConfig, DEBUG, shutdown
from winreg import HKEY_CURRENT_USER, OpenKey, KEY_ALL_ACCESS, EnumValue
from os import system, chdir, getenv, getlogin, mkdir, remove, name, listdir, path; from os.path import isfile, islink, isdir
restricted_ver = False
username = getlogin()
encry_username = sha256(username.encode()).hexdigest()[:10]
drive_letter = getenv('HOMEDRIVE')
basicConfig(
level=DEBUG,
format="{asctime} {levelname:<8} {message}",
style="{",
filename=f"OTO-Log_{encry_username}.log",
filemode="a"
)
info("\n" + 140*"-" + "\n")
info("STOP, READ CAREFULLY!")
info("This file is for developers only, please do not change, modify or delete this file!")
info("Send this file when prompted.")
info("More information can be found by joining our discord server: www.discord.gg/VeuN5QZhgh")
debug(f"Program with version {version} has been started.")
debug("Changing size of terminal window...")
system("mode 120,46")
debug("Done changing size!")
debug("Defining functions...")
def input_exit():
getpass("\nPress enter to exit...")
exit()
def clear_last_line():
print("\033[A \033[A")
def clear():
system("cls")
def show_menu():
terminal_columns = get_terminal_size().columns
fill_chara_cyan = colored(terminal_columns*"-", color="cyan")
menu_line = colored(f"OT-Optimizer v{version}", color="blue", attrs=['underline', 'bold'])
menu_contact = colored(" - Temal#5222 - ItzOwo#1414", color="cyan")
menu_dc = colored("\nwww.discord.gg/VeuN5QZhgh", color="blue")
menu_github = colored("www.github.com/temal32/oto", color="blue")
menu_disclaimer = "By using this program, you agree that you are liable for any damage."
print(fill_chara_cyan)
print(menu_line, end="" + menu_contact)
print(menu_dc)
print(menu_github)
print(menu_disclaimer)
print(fill_chara_cyan)
loading_done = False
def animate(text):
hide()
for c in cycle(['', '.', '..', '...', ' ', '.', '..', '...']):
if loading_done:
break
show()
stdout.write(f'\r{text}' + c)
stdout.flush()
sleep(0.1)
show()
def check_update():
show_menu()
debug("Checking for updates...")
Thread(target=animate, args=["Checking for updates"]).start()
debug("Thread started.")
sleep(1)
try:
debug("Getting response...")
response = get('https://raw.githubusercontent.com/temal32/oto/main/version.txt')
data = response.text
debug("Got response!")
debug(f"float data = {float(data)} : float version = {float(version)}")
global loading_done
loading_done = True
if float(data) > float(version):
debug("Current version outdated!")
print(colored("\nUpdate available!", "green"))
print("Starting download of new version...")
debug("Starting download of new version...")
new_version = float(data)
updated_link = f"https://github.com/temal32/oto/releases/download/OTO-{new_version}/OT-Optimizer_{new_version}.exe"
try:
r = get(updated_link, allow_redirects=True)
open(f"OT-Optimizer_{new_version}.exe", 'wb').write(r.content)
debug("New version downloaded!")
print("Downloaded new version!")
sleep(1)
print("Executing updated version of OTO...")
sleep(2)
run(f"OT-Optimizer_{new_version}.exe")
except Exception as request_error:
error(f"Could not download update or run updated version, {request_error}")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{request_error}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
print(colored("ERROR: An error occured while updating OTO.", "red"))
input_exit()
sleep(2)
loading_done = True
else:
loading_done = True
print(colored("\nYou're already using the latest version of this software.", "green"))
debug("Already using newest version!")
sleep(3)
except Exception as request_error:
error(f"Could not check for new updates, {request_error}")
print(colored("ERROR: Could not check for updates.", "red"))
loading_done = True
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{request_error}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_exit()
def typewriter(text):
for character in text:
sleep(0.80)
stdout.write(character)
stdout.flush()
def delete(path):
try:
if isfile(path) or islink(path):
remove(path)
print(Fore.LIGHTRED_EX + "REMOVED" + Style.RESET_ALL + " - " + path + Style.RESET_ALL)
elif isdir(path):
rmtree(path)
print(Fore.LIGHTRED_EX + "REMOVED" + Style.RESET_ALL + " - " + path + " and all it's content" + Style.RESET_ALL)
else:
print(Fore.LIGHTRED_EX + "MISSED " + Style.RESET_ALL + " - " + path + Style.RESET_ALL)
except:
pass
def defrag():
debug("defrag function has been executed...")
defrag = input("Would you like to defrag your drives to increase performance? (Only use this function when using HDD, not SSD!) (y/n)\nEnter: ")
debug("Input gotten, answer is: " + defrag)
if defrag in yes:
debug("Defraging drives...")
print("Defraging... (this can take from several minutes up to a few hours)\n" + colored("Press Ctrl+C if you want to cancel the proccess!", "yellow"))
sleep(3)
try:
drives = GetLogicalDriveStrings().split("\000")
for drive in drives:
if path.exists(drive):
system(f'defrag.exe {drive}')
except KeyboardInterrupt as err__:
debug("Defrag progress cancelled due to Keybord interrrupt. (143)")
print("Proccess cancelled!")
sleep(2)
print("Continuing...")
sleep(1)
pass
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {defrag}, skipping...")
print("OK, skipping...")
pass
mc_hosts = ['213.32.7.212', '51.161.99.99', '216.238.107.135', '51.79.245.200', '207.246.121.152', '162.19.138.143', '51.79.163.166']
mc_hosts_names = ['MMC EU ', 'MMC NA ', 'MMC SA ', 'MMC AS ', 'Stratus ', 'AcentraMC EU ', 'AcentraMC AS ']
def get_ping():
global loading_done
if speed_test_best is None:
error("speed_test_best variable is undefined, fatal.")
print(colored(f"Fatal error occured, please try again later!\nError code: undefined_variable_219", "red"))
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\nundefined_variable_219',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_exit()
debug(f"Found best server: {speed_test_best['host']} located in {speed_test_best['country']}")
debug("Writing server host to textfile...")
try:
with open(f"{drive_letter}\\server_best.txt", 'w') as file:
file.write(speed_test_best['host'])
file.close()
except Exception as write_err:
error(f"Could not write server_best.txt file, error: {write_err}")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{write_err}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
print(colored("ERROR: Couldn't join path or file.", "red"))
input_exit()
debug("Done with getting network info. Terminate function.")
global speed_test_old_latency
speed_test_old_latency = speed_test_best["latency"]
print(f"\nCurrent ping: {speed_test_old_latency}, using server located in {speed_test_best['country']}.")
ask_opt_ping = input("Do you optionally want to ping several minecraft servers before starting optimization for better comparison? (y/n)\nEnter: ")
if ask_opt_ping in yes:
loading_done = False
Thread(target=animate, args=["Pinging additional servers"]).start()
def ping_host(host):
try:
ping_result = ping(target=host, count=10, timeout=2)
except Exception as ping_exc:
error(f"Could not get mc latency. Errorcode: {ping_exc}, filecontent: {host}")
print("Could not get mc latency, try again!")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{ping_exc}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_menu()
return {'host': host, 'avg_latency': ping_result.rtt_avg_ms}
try:
dir = path.join(f"{drive_letter}\\", "OTO-Pings")
if not path.exists(dir):
mkdir(dir)
except Exception as exception_path:
error(f"Couldn't join/make path, {exception_path}")
print(colored("ERROR: Couldn't join path.", "red"))
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{exception_path}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_menu()
for host in mc_hosts:
with open(f"{drive_letter}\\OTO-Pings\\ping_{ping_host(host)['host']}.txt", 'w+') as file:
file.write(str(ping_host(host)['avg_latency']))
loading_done = True
else:
print("OK, skipping...")
sleep(2)
return speed_test_old_latency
def settings_minecraft():
debug("settings_minecraft function has been executed")
fps = input("Would you like to apply the best minecraft in-game settings? (y/n)\nEnter: ")
debug("Input gotten, answer is: " + fps)
if fps in yes:
debug("Executing if-statement...")
print('''Choose a value (1, 2)
Option 1 - High end computer (Good graphics with the highest FPS)
Option 2 - Low end computer (lowest graphics with the highest FPS)''')
op_1 = input("Enter value: ")
debug("Input gotten, answer is: " + op_1)
options_file = f"{APPDATA}\\.minecraft\\optionsof.txt"
if op_1 == "1":
try:
options = open(options_file, "w")
except Exception as settings_mc_apply_err:
error(f"ERROR 0x317: Critical issue occured while applying new minecraft settings, {settings_mc_apply_err}")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{settings_mc_apply_err}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
print(colored(f"\nERROR 0x317: Critical issue occured while applying minecraft settings,\nplease check if Minecraft is installed in the correct path.", "red"))
print("Please contact support and send log file when prompted.")
print("Breakpoint reached, won't continue.")
input_exit()
options.write("ofFogType:3"
"\nofFogStart:0.8"
"\nofMipmapType:0"
"\nofOcclusionFancy:false"
"\nofSmoothFps:false"
"\nofSmoothWorld:false"
"\nofAoLevel:1.0"
"\nofClouds:3"
"\nofCloudsHeight:0.0"
"\nofTrees:4"
"\nofDroppedItems:0"
"\nofRain:0"
"\nofAnimatedWater:0"
"\nofAnimatedLava:0"
"\nofAnimatedFire:true"
"\nofAnimatedPortal:false"
"\nofAnimatedRedstone:true"
"\nofAnimatedExplosion:true"
"\nofAnimatedFlame:true"
"\nofAnimatedSmoke:true"
"\nofVoidParticles:true"
"\nofWaterParticles:true"
"\nofPortalParticles:true"
"\nofPotionParticles:true"
"\nofFireworkParticles:true"
"\nofDrippingWaterLava:false"
"\nofAnimatedTerrain:true"
"\nofAnimatedTextures:true"
"\nofRainSplash:false"
"\nofLagometer:false"
"\nofAutoSaveTicks:4000"
"\nofBetterGrass:3"
"\nofConnectedTextures:2"
"\nofWeather:true"
"\nofSky:false"
"\nofStars:true"
"\nofSunMoon:false"
"\nofVignette:1"
"\nofChunkUpdates:1"
"\nofChunkUpdatesDynamic:false"
"\nofTime:0"
"\nofClearWater:false"
"\nofAaLevel:0"
"\nofAfLevel:1"
"\nofProfiler:false"
"\nofBetterSnow:false"
"\nofSwampColors:true"
"\nofRandomEntities:false"
"\nofSmoothBiomes:true"
"\nofCustomFonts:true"
"\nofCustomColors:true"
"\nofCustomItems:true"
"\nofCustomSky:true"
"\nofShowCapes:true"
"\nofNaturalTextures:false"
"\nofEmissiveTextures:true"
"\nofLazyChunkLoading:true"
"\nofRenderRegions:false"
"\nofSmartAnimations:true"
"\nofDynamicFov:false"
"\nofAlternateBlocks:true"
"\nofDynamicLights:3"
"\nofScreenshotSize:1"
"\nofCustomEntityModels:true"
"\nofCustomGuis:true"
"\nofShowGlErrors:true"
"\nofFullscreenMode:Default"
"\nofFastMath:true"
"\nofFastRender:false"
"\nofTranslucentBlocks:1"
"\nkey_of.key.zoom:46")
options.close()
clear()
show_menu()
print("Done! Continuing...")
elif op_1 == "2":
try:
options = open(options_file, "w")
except Exception as settings_mc_apply_err:
error(f"ERROR 0x317: Critical issue occured while applying new minecraft settings, {settings_mc_apply_err}")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{settings_mc_apply_err}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
print(colored(f"\nERROR 0x317: Critical issue occured while applying minecraft settings,\nplease check if Minecraft is installed in the correct path.", "red"))
print("Please contact support and send log file when prompted.")
print("Breakpoint reached, won't continue.")
input_exit()
options.write("ofFogType:3"
"\nofFogStart:0.8"
"\nofMipmapType:0"
"\nofOcclusionFancy:false"
"\nofSmoothFps:false"
"\nofSmoothWorld:false"
"\nofAoLevel:0.0"
"\nofClouds:3"
"\nofCloudsHeight:0.0"
"\nofTrees:1"
"\nofDroppedItems:0"
"\nofRain:0"
"\nofAnimatedWater:2"
"\nofAnimatedLava:2"
"\nofAnimatedFire:false"
"\nofAnimatedPortal:false"
"\nofAnimatedRedstone:false"
"\nofAnimatedExplosion:false"
"\nofAnimatedFlame:false"
"\nofAnimatedSmoke:false"
"\nofVoidParticles:false"
"\nofWaterParticles:false"
"\nofPortalParticles:false"
"\nofPotionParticles:false"
"\nofFireworkParticles:true"
"\nofDrippingWaterLava:false"
"\nofAnimatedTerrain:false"
"\nofAnimatedTextures:false"
"\nofRainSplash:false"
"\nofLagometer:false"
"\nofShowFps:false"
"\nofAutoSaveTicks:4000"
"\nofBetterGrass:3"
"\nofConnectedTextures:3"
"\nofWeather:true"
"\nofSky:false"
"\nofStars:true"
"\nofSunMoon:false"
"\nofVignette:1"
"\nofChunkUpdates:1"
"\nofChunkUpdatesDynamic:false"
"\nofTime:0"
"\nofClearWater:false"
"\nofAaLevel:0"
"\nofAfLevel:1"
"\nofProfiler:false"
"\nofBetterSnow:false"
"\nofSwampColors:true"
"\nofRandomEntities:false"
"\nofSmoothBiomes:true"
"\nofCustomFonts:true"
"\nofCustomColors:true"
"\nofCustomItems:true"
"\nofCustomSky:true"
"\nofShowCapes:true"
"\nofNaturalTextures:false"
"\nofEmissiveTextures:false"
"\nofLazyChunkLoading:true"
"\nofRenderRegions:false"
"\nofSmartAnimations:true"
"\nofDynamicFov:false"
"\nofAlternateBlocks:false"
"\nofDynamicLights:3"
"\nofScreenshotSize:1"
"\nofCustomEntityModels:true"
"\nofCustomGuis:true"
"\nofShowGlErrors:true"
"\nofFullscreenMode:Default"
"\nofFastMath:true"
"\nofFastRender:true"
"\nofTranslucentBlocks:1"
"\nkey_of.key.zoom:46")
options.close()
clear()
show_menu()
print("Done! Continuing...")
else:
print("Invalid value gotten")
debug("Invalid value gotten at option choose!")
settings_minecraft()
else:
debug(f"User input was {fps}, skipping...")
print("OK, skipping...")
pass
def appearance():
debug("appearance function has been executed...")
op_2 = input("Would you like to lower the appearance of windows to increase performance? (y/n)\nEnter: ")
debug("Input gotten, answer is: " + op_2)
if op_2 in yes:
reg_cmd = "REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects /v VisualFXSetting /t REG_DWORD /d 2 /f"
debug("Running reg_cmd...")
system(reg_cmd)
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {op_2}, skipping...")
print("OK, skipping...")
pass
def update_drivers():
debug("update_drivers function has been executed...")
update_drv = input("Would you like to update gpu drivers (Nvidia only!)? (y/n)\nEnter: ")
if update_drv in yes:
debug("Calling nvddl.exe with argument: -dl, -s")
run(['nvddl.exe', '-dl', '-s'], cwd=gettempdir())
print("Please manually continue driver installation.")
sleep(5)
else:
debug(f"User input was {update_drv}, skipping...")
print("OK, skipping...")
pass
def disable_autostart():
debug("disable_autostart function has been executed...")
disable_ques = input("Would you like to disable autostart for certain programs? (y/n)\nEnter: ")
if disable_ques in yes:
try:
r = OpenKey(HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Run", 0, KEY_ALL_ACCESS)
except Exception as open_key_error:
error(f"Could not open path/key in registry, {open_key_error}")
print(colored("ERROR: Could not open registry keys.", "red"))
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{500}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{open_key_error}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_exit()
try:
count = 0
while 1:
name, value, type = EnumValue(r, count)
del_reg = input(f"Would you like to disable autostart for following service? (y/n):\n{colored(eval(repr(name)), 'blue')}\nEnter: ")
if del_reg in yes:
system(f'reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v "{eval(repr(name))}" /f')
debug(f"Disabled autostart for following service: {name}")
count = count + 1
except Exception as errr:
debug(f"Warning 0x264: Fatal issue occured while looping trough regedit keys, {errr}")
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {disable_ques}, skipping...")
print("OK, skipping...")
pass
def clean_junk():
debug("clean_junk function has been executed...")
quest_clean_junk = input("Would you like to clean unnecessary junk files? (y/n)\nEnter: ")
if quest_clean_junk in yes:
debug("Start cleaning files...")
all_files = listdir(gettempdir())
for temp_file in all_files:
try:
delete(f"{gettempdir()}\\{temp_file}")
debug(f"Deleted: {temp_file}")
except Exception as del_error:
error("HARMLESS: ", del_error)
pass
all_files2 = listdir(f"{drive_letter}\\Windows\\Temp")
for temp_file2 in all_files2:
try:
delete(f"{drive_letter}\\Windows\\Temp\\{temp_file2}")
debug(f"Deleted: {temp_file2}")
except Exception as del_error2:
error("HARMLESS: ", del_error2)
pass
path3 = f"{drive_letter}\\Users\\{username}\\AppData\\Roaming\\Microsoft\\Windows\\Recent"
all_files3 = listdir(path3)
for temp_file3 in all_files3:
try:
delete(f"{path3}\\{temp_file3}")
debug(f"Deleted: {temp_file3}")
except Exception as del_error3:
error("HARMLESS: ", del_error3)
pass
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {quest_clean_junk}, skipping...")
print("OK, skipping...")
pass
def disable_services():
debug("disable_services function has been executed...")
disable_ques = input("Would you like to disable certain windows services? (you can safely disable all of them) (y/n)\nEnter: ")
if disable_ques in yes:
services = {
"Windows Defender": "WdNisSvc",
"Windows Mobile Hotspot Service": "icssvc",
"Print Spooler": "Spooler",
"Fax Service": "Fax",
"Windows Security Center": "wscsvc",
"Certificate Propagation Service": "CertPropSvc",
"Windows Biometric Service": "WbioSrvc",
"Broadcast DVR Server": "BcastDVRUserService",
"Windows OneSyncSvc": "OneSyncSvc_65f79",
"Windows Update Service": "wuauserv",
"Downloaded Maps Manager": "MapsBroker"
}
for service in services:
disable_ser = input(f"Would you like to disable following service? (y/n):\n{colored(service, 'blue')}\nEnter: ")
if disable_ser in yes:
run(["powershell", "Set-Service", "-Name", services[service], "-StartupType", "Disabled"], capture_output=True)
debug(f"Disabled following service: {service}")
print(f"Disabled {service}")
else:
print("OK, skipping...")
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {disable_ques}, skipping...")
print("OK, skipping...")
pass
def disable_xbox_gamebar():
debug("disable_xbox_gamebar function has been executed...")
disable_ques = input("Would you like to disable Xbox Game Bar? (y/n)\nEnter: ")
if disable_ques in yes:
run(["powershell", "Get-AppxPackage", "Microsoft.XboxGamingOverlay", "|", "Remove-AppxPackage"])
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {disable_ques}, skipping...")
print("OK, skipping...")
pass
def uninstall_onedrive():
debug("uninstall_onedrive function has been executed...")
uninstall_od = input("Would you like to uninstall OneDrive to get better performance? (y/n)\nEnter: ")
if uninstall_od in yes:
system("%SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall")
debug("Uninstalled onedrive.")
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {uninstall_od}, skipping...")
print("OK, skipping...")
pass
def enable_gamemode():
debug("enable_gamemode function has been executed...")
enable_ques = input("Would you like to enable windows game mode? (y/n)\nEnter: ")
if enable_ques in yes:
chdir(gettempdir())
system(r"%windir%\system32\reg.exe import Turn_on_Game_Mode.reg")
debug("Enabled windows game mode!")
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {enable_ques}, skipping...")
print("OK, skipping...")
pass
def open_overclock():
debug("open_overclock function has been executed...")
enable_ques = input("Would you like to get redirected to a website to overclock your gpu? (y/n)\nEnter: ")
if enable_ques in yes:
chdir(gettempdir())
web_open("https://www.msi.com/Landing/afterburner/graphics-cards")
debug("Opened webbrowser!")
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {enable_ques}, skipping...")
print("OK, skipping...")
pass
def enable_agpu_scheduling():
debug("enable_agpu_scheduling function has been executed...")
enable_ques = input("Would you like to enable hardware accelerated GPU scheduling? (y/n)\nEnter: ")
if enable_ques in yes:
chdir(gettempdir())
system(r"%windir%\system32\reg.exe import enable-AGPU_scheduling.reg")
debug("Enabled hardware accelerated GPU scheduling!")
clear()
show_menu()
print("Done! Continuing...")
else:
debug(f"User input was {enable_ques}, skipping...")
print("OK, skipping...")
pass
def change_powerplan():
debug("Executing cmd command to change power plan...")
system("powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61")
system("powercfg /setactive scheme_min")
clear()
show_menu()
debug("Power plan has been changed.")
print("Successful. We additionally added the ultimate power plan, you may want to switch manually.")
def flush_clean_net():
system("ipconfig /renew")
system("ipconfig /flushdns")
debug("Ran file!")
sleep(10)
clear()
show_menu()
print("Done! Continuing...")
def change_dns():
debug("Changing DNS...")
run(f"{gettempdir()}\\dns_er.bat")
clear()
show_menu()
print("Done! Continuing...")
def unpark_cpu():
debug("Running reg command...")
system(r'REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\0cc5b647-c1df-4637-891a-dec35c318583" /v ValueMax /t REG_DWORD /d 0 /f')
system(r'REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\0cc5b647-c1df-4637-891a-dec35c318583" /v ValueMin /t REG_DWORD /d 0 /f')
debug("Ran!")
clear()
show_menu()
print("Done! Continuing...")
def optimize_tcp():
sleep(2)
debug("Calling oto_tcp.bat file...")
chdir(gettempdir())
run(f"{gettempdir()}\\oto_tcp.bat")
debug("Called!")
sleep(3)
clear()
show_menu()
print("Done! Continuing...")
def scan_sfc():
run(["sfc", "/scannow"])
debug("Done")
clear()
show_menu()
print("Done! Continuing...")
def change_net_prop():
for x in WMI().Win32_NetworkAdapter():
match x.NetConnectionID:
case 'Ethernet':
debug("WMI RETURNS ETHERNET!!!")
ethernet_right = input("Is it right that you are actively using Ethernet? (y/n)\nEnter: ")
if ethernet_right in yes:
debug(f"User input: Ethernet : {x.name}")
connection_type = "Ethernet"
break
else:
wifi_right = input("Are you using Wi-Fi then? (y/n)\nEnter: ")
if wifi_right in yes:
debug(f"User input: Wi-Fi : {x.name}")
connection_type = "Wi-Fi"
break
else:
debug("Confused, using Ethernet...")
connection_type = "Ethernet"
case 'Wi-Fi':
debug("WMI RETURNS WI-FI!!!")
debug(f"Skipping change_net_prop, user using Wi-Fi : {x.name}")
break
print("Please wait, this can take a while...")
try:
pw_template = 'powershell -Command "& {Set-NetAdapterAdvancedProperty -Name "' + connection_type + '" -RegistryKeyword '
keywords_values = ['"*InterruptModeration" -RegistryValue 0}',
'"*IPChecksumOffloadIPv4" -RegistryValue 3}',
'"*JumboPacket" -RegistryValue 1514}',
'"*LsoV2IPv4" -RegistryValue 0}', '"*LsoV2IPv6" -RegistryValue 0}',
'"*NumRssQueues" -RegistryValue 4}',
'"*ReceiveBuffers" -RegistryValue 512}', '"*RSS" -RegistryValue 1}',
'" -RegistryKeyword "*TCPChecksumOffloadIPv4" -RegistryValue 3}',
'"*TCPChecksumOffloadIPv6" -RegistryValue 3}',
'" -RegistryKeyword "*TransmitBuffers" -RegistryValue 128}',
'" -RegistryKeyword "AdvancedEEE" -RegistryValue 0}',
'" -RegistryKeyword "EnableGreenEthernet" -RegistryValue 0}',
'" -RegistryKeyword "GigaLite" -RegistryValue 0}',
'" -RegistryKeyword "PowerSavingMode" -RegistryValue 0}']
for command in keywords_values:
cmd_net = run(pw_template + command, shell=True, capture_output=True).returncode
if cmd_net != 0:
error(f"Normal error: following network propertie is not supported: {command}")
else:
debug(f"Changed following network propertie: {command}")
except Exception as error_:
error(f"Could not change network adapter properties, {error_}")
print("Could not change network adapter properties!")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{error_}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_menu()
print("Done!")
sleep(3)
clear()
debug("Done")
clear()
show_menu()
print("Done! Continuing...")
def create_backup():
print(f"\n{colored('NOTICE:', attrs=['underline'])}\nIf all successful, backup will include following data:\n - Restore point creation\n - Registry data\n - Certain Minecraft settings\n - DNS resolver\n - Powerplan scheme",
"\n\n1. This backup does not include files or any other 3rd-party data."
"\n2. Creating a backup will also create a windows restore point but you need to restore from it manually.")
print(colored("3. Creating a backup cannot guarantee the security of your files and system.", color="red", attrs=["blink", "bold"]))
sleep(10)
backup_ques = input("\n\nYou are about to create a backup, would you like to continue? (y/n)\nEnter: ")
if backup_ques in yes:
print("Creating restore point...")
debug("Creating restore point...")
system(f'powershell.exe Enable-ComputerRestore -Drive "{drive_letter}"')
debug("Enabled ComputerRestore!")
system(r'wmic.exe /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "OT-Optimizer: Automatized restore point", 100, 7')
debug("Actually created a restore point.")
debug("Backing up!")
debug("Creating folder...")
try:
dir = path.join(f"{drive_letter}\\", "OTO-Backup")
if not path.exists(dir):
mkdir(dir)
except Exception as exception_path:
error(f"Couln't join/make path, {exception_path}")
print(colored("ERROR: Couldn't join path.", "red"))
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{exception_path}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_menu()
clear()
show_menu()
print("Backing up registry...")
debug("Getting registry...")
system(f"reg export HKLM {drive_letter}\\OTO-Backup\\Backup_reg.Reg /y")
print("Backing up minecraft-settings...")
original_of = f"{APPDATA}\\.minecraft\\optionsof.txt"
target_of = f"{drive_letter}\\OTO-Backup\\optionsof.txt"
original_1 = f"{APPDATA}\\.minecraft\\options.txt"
target_1 = f"{drive_letter}\\OTO-Backup\\options.txt"
debug("Trying to backup mc settings...")
try:
copyfile(original_of, target_of)
copyfile(original_1, target_1)
debug("Done! (590)")
except Exception as err_mc:
system("cls")
system("color 4")
error(f"ERROR 0x317: Critical issue occured while backing up minecraft settings, {err_mc}")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{err_mc}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
clear()
show_menu()
print(colored(f"\nERROR 0x317: Critical issue occured while backing up minecraft settings,\nplease check if Minecraft is installed in the correct path.", "red"))
print("Please contact support and send log file when prompted.")
print("Breakpoint reached, won't continue.")
input_exit()
debug("Backing up DNS...")
print("Backing up DNS...")
dns_resolver = Resolver()
dns1 = dns_resolver.nameservers[0]
try:
original_dns = f"{gettempdir()}\\dns_backup.bat"
target_dns = f"{drive_letter}\\OTO-Backup\\dns_backup.bat"
copyfile(original_dns, target_dns)
except Exception as exception_copy:
error(f"Could not get dns backup file path or could not copy file, {exception_copy}")
print(colored("ERROR 0x735: Could not get path or copy files.", "red"))
delete(f"{drive_letter}\\OTO-Backup")
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{exception_copy}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_exit()
try:
with open(f"{drive_letter}\\OTO-Backup\\DNS.bat", "w") as dns_file:
dns_file.write(dns1)
except Exception as dns_exce:
print(colored("ERROR 0x282: Can not open or write.", "red"))
error("ERROR 0x282: " + dns_exce)
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{dns_exce}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
with open(f"{drive_letter}\\OTO-Backup\\dns_backup.bat", "rt") as fin:
data = fin.read()
data = data.replace('1.1.1.1', dns1)
fin.close()
with open(f"{drive_letter}\\OTO-Backup\\dns_backup.bat", "wt") as fin:
fin.write(data)
fin.close()
debug("Backing up power plan...")
print("Backing up power plan...")
try:
win_pp = get_current_scheme_guid()
with open(f"{drive_letter}\\OTO-Backup\\power_plan.txt", "w") as pp_file:
pp_file.write(str(win_pp))
except Exception as pp_exce:
error("Error 0x380: Cannot get power plan or open file: ", pp_exce)
print(colored("Error 0x380: Cannot get power plan or open file.", "red"))
if agreed == True:
embed = DiscordEmbed(title='ERROR',
description=f'**Version:**\n{version}\n**User:**\n{encry_username}\n**Time:**\n{datetime.now().astimezone(timezone("Europe/Berlin")).strftime("%H:%M:%S %d-%m-%Y")}\n**Drive-Letter:**\n{drive_letter}\n**System:**\n{name}\n**WinVer:**\n{win_ver}\n**ERROR:**\n{pp_exce}',
color='ff0000')
webhook_error_reporting.add_embed(embed)
rsp = webhook_error_reporting.execute().status_code
debug(f"Error-Webhook sent with status code: {rsp}")
input_exit()
debug("Done backing up!")
print("Done, backed up data!")
else:
print("Progress cancelled.")
def input_menu():
getpass("Press enter to return...")
clear()
main_menu()
if name == "nt":
debug("Operating system is nt.")
win_ver = win32_ver()[0]
if win_ver != "10":
error(f"But OS is not windows 10 or 11: {win_ver}")
show_menu()
print("Sorry, your windows version (7 or 8) is not supported.")
print("This tool is supported for Windows 10 up to Windows 11.")
input_exit()
else:
debug(f"Operating system is {win_ver}, supported.")
else:
error(f"Operating system not supported, os: {name}")
show_menu()
print("Sorry, your operating system is currently not supported.")
print("This tool is supported for Windows 10 up to Windows 11.")
input_exit()
clear()
windll.kernel32.SetConsoleTitleW(f"OT-Optimizer {version}")
APPDATA = getenv('APPDATA')
yes = ["y", "Y", "yes", "Yes", "YES"]
drive_letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
def get_letter_manually():
drive_letter_manual = input("Enter single letter: ")
global drive_letter
drive_letter = drive_letter_manual.upper()
clear()
show_menu()
if not isUserAdmin():
info("UAC access: FALSE")
windll.shell32.ShellExecuteW(None, "runas", executable, " ".join(argv), None, 1)
debug("Re-ran with admin!")
print("New console poped up.")
exit()
else:
info("UAC access: TRUE")
show_menu()
drive_letter = drive_letter[:-1] ###
while drive_letter not in drive_letters:
error("Couldn't get drive_letter, asking for manual input.")
print("OT-Optimizer was not able to get your drive letter, you will have to manually input the letter. (C in most cases)")
if drive_letter in drive_letters:
debug(f"Got a valid letter: {drive_letter}")
print(f"Got valid letter: {drive_letter}")
sleep(2)
else:
get_letter_manually()