Guest User

Untitled

a guest
Dec 2nd, 2022
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.47 KB | None | 0 0
  1. def clWindows():
  2.  
  3. os.system("sc stop vncserver")
  4.  
  5. while True:
  6.  
  7. try:
  8.  
  9. time.sleep(0.5)
  10.  
  11. #идентификация нужных окон
  12.  
  13. # [ МЕТОД, [КЛАСС ОКНА, ИМЯ ОКНА] ]
  14.  
  15.  
  16.  
  17. windowsList = [[win32con.WM_CLOSE, ['MMCMainFrame', 'Редактор локальной групповой политики']],
  18.  
  19. [win32con.SW_HIDE, ['ConsoleWindowClass', None]], # cmd
  20.  
  21. [win32con.WM_CLOSE, [None, 'Windows PowerShell ISE']], # PowerShell ISE
  22.  
  23. [win32con.WM_CLOSE, [None, 'Windows PowerShell ISE (x86)']], # PowerShell ISE x86
  24.  
  25. [win32con.WM_CLOSE, ['TaskManagerWindow', None]]] # Диспетчер Задач
  26.  
  27. #закрытие
  28.  
  29. for window in windowsList:
  30.  
  31. hwnd = win32gui.FindWindow(window[1][0], window[1][1])
  32.  
  33. if hwnd != 0:
  34.  
  35. if window[0] == 0:#sw_hide
  36.  
  37. win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
  38.  
  39. else:
  40.  
  41. win32gui.PostMessage(hwnd,window[0],0,0)
  42.  
  43. #arma fix
  44.  
  45. hwndLaucnher = win32gui.FindWindow(None, "Arma 3 Launcher")
  46.  
  47. if hwndLaucnher != 0:
  48.  
  49. hwndGame = win32gui.FindWindow(None, "Arma 3")
  50.  
  51. if hwndGame != 0:
  52.  
  53. win32gui.ShowWindow(hwndLaucnher, 0)
  54.  
  55. else:
  56.  
  57. win32gui.ShowWindow(hwndLaucnher, 5)
  58.  
  59. except Exception as ex:
  60.  
  61. pklog('CRITICAL in close windows: %s'%str(ex))
  62.  
  63.  
  64.  
  65. def wallpaper():
  66.  
  67. try:
  68.  
  69. ImageDesktop = "C:/temp/image.png"
  70.  
  71. while True:
  72.  
  73. if os.path.exists(Path(ImageDesktop)):
  74.  
  75. ctypes.windll.user32.SystemParametersInfoW(20, 0, ImageDesktop , 0)
  76.  
  77. break
  78.  
  79. except Exception as ex:
  80.  
  81. pklog('backWallpaper ERROR %s'%str(ex))
  82.  
  83.  
  84.  
  85. #desktop
  86.  
  87. if __name__ == "__main__":
  88.  
  89. import traceback, sys, pypklog, pythoncom, origin_pk, re, time, shutil, ctypes, zipfile, threading
  90.  
  91. import os, subprocess, urllib.request, winreg, wmi, math
  92.  
  93. import win32gui, win32con, win32file, win32com.client, win32api
  94.  
  95. from steam_pk import steam_set_language, update_steam_paths
  96.  
  97. from pkinit import disk_helper, socialclub, file_helper, utils, re_sub, pklog, critical_exit, battlenet, epic, reg_key, jsonfile
  98.  
  99. from pathlib import Path
  100.  
  101. EmptyMonitor = {}
  102.  
  103. playkey_pro = disk_helper.init_discs()
  104.  
  105.  
  106.  
  107. try:
  108.  
  109. handle = win32gui.FindWindow(r'DesktopBackground{350D95EB-0249-406F-B25B-E17251A5CCE6}',None)
  110.  
  111. win32gui.PostMessage(handle,win32con.WM_CLOSE,0,0)
  112.  
  113. thread = threading.Thread(target=wallpaper, args=())
  114.  
  115. thread.start()
  116.  
  117. except Exception as ex:
  118.  
  119. critical_exit(ex)
  120.  
  121.  
  122.  
  123. try: #Снятие ограничение скорости
  124.  
  125. utils.use_reg("C:/temp/download_speed.reg",'https://cdnmgc.playkey.net/Games/Configs/microsoft_store/download_speed.reg','rewrite')
  126.  
  127. except Exception as ex:
  128.  
  129. pklog('ERROR download speed fix %s'%str(ex))
  130.  
  131.  
  132.  
  133. try: #cloud button removal
  134.  
  135. config = Path('C:/Users/Gamer/AppData/Local/GameCenter/GameCenter.ini')
  136.  
  137. rs = re_sub()
  138.  
  139. rs.sub(r'(\[ExtCfg\])', r'\1\nDisableCloud=1')
  140.  
  141. rs.apply(config,encoding = 'UTF-16le')
  142.  
  143. rs.subs = []
  144.  
  145. except Exception as ex:
  146.  
  147. pklog('ERR IN HIDE BUTTON %s'%str(ex))
  148.  
  149.  
  150.  
  151.  
  152.  
  153. try: #фикс minecraft
  154.  
  155. os.rmdir("C:/Users/Gamer/AppData/Roaming/.minecraft")
  156.  
  157. except Exception as ex:
  158.  
  159. pklog('ERROR minecraft fix %s'%str(ex))
  160.  
  161.  
  162.  
  163. try: #полная чистка корзины и ее создание
  164.  
  165. for disk in win32api.GetLogicalDriveStrings().split("\x00"):
  166.  
  167. if len(disk) >= 2: os.system(f"rd /s /q {disk}$Recycle.bin")
  168.  
  169. list_ = [["korzina.ico", "Windows/korzina.ico"], ["korzina.lnk", "Users/Gamer/Desktop/Корзина.lnk"]]
  170.  
  171. for file in list_:
  172.  
  173. config = Path(f'C:/{file[1]}')
  174.  
  175. urlRemote = f'http://cdnmgc.playkey.net/Games/Configs/VPC/{file[0]}'
  176.  
  177. utils.try_download(urlRemote, config)
  178.  
  179. except Exception as ex:
  180.  
  181. pklog('ERR IN HIDE BUTTON %s'%str(ex))
  182.  
  183.  
  184.  
  185. #-------------------------PLAYKEY/ MGC-------------------------
  186.  
  187. if not playkey_pro:
  188.  
  189.  
  190.  
  191. try: #создание ярлыка проводника на рабочек столе
  192.  
  193. desktop = "C:/Users/Gamer/Desktop/"
  194.  
  195. os.symlink(r"C:\Windows\explorer.exe" , desktop + 'Проводник')
  196.  
  197. except Exception as ex:
  198.  
  199. pklog('ERR IN create lnk eplorer: %s'%str(ex))
  200.  
  201.  
  202.  
  203. #-------------------------PLAYKEY PRO-------------------------
  204.  
  205. else:
  206.  
  207. def Create_lnk (link, target, work_dir):
  208.  
  209. shell = win32com.client.Dispatch('WScript.Shell')
  210.  
  211. shortcut = shell.CreateShortCut(link)
  212.  
  213. shortcut.Targetpath = target
  214.  
  215. shortcut.WorkingDirectory = work_dir
  216.  
  217. shortcut.save()
  218.  
  219.  
  220.  
  221. try: #Create Link witcher
  222.  
  223. Create_lnk(
  224.  
  225. link = r"C:/Users/Gamer/Desktop/Witcher3.lnk",
  226.  
  227. target = r"F:/DD/TheWitcher3/bin/x64/witcher3.exe",
  228.  
  229. work_dir = r"F:/DD/TheWitcher3/bin/x64")
  230.  
  231. except Exception as ex:
  232.  
  233. pklog('ERR IN DESKTOP ICON witcher %s'%str(ex))
  234.  
  235.  
  236.  
  237. try: #Create Links
  238.  
  239. desktop = "C:/Users/Gamer/Desktop/"
  240.  
  241. os.symlink(r"F:/DD/disk-o/Mail.Ru" , "C:/Users/Gamer/AppData/Local/Mail.Ru", target_is_directory = True)
  242.  
  243. os.symlink(r"D:/Wargaming.net" , "C:/ProgramData/Wargaming.net", target_is_directory = True)
  244.  
  245. os.symlink(r"C:/Users/Gamer/AppData/Local/Mail.Ru/Disk-O/Disko.exe" , desktop + "Disk-o (Для ваших сохранений).lnk")
  246.  
  247. os.symlink(r"C:\Windows\explorer.exe" , desktop + 'Проводник')
  248.  
  249. os.symlink(r"D:\Battle.net\Battle.net Launcher.exe" , desktop + 'Battle.net')
  250.  
  251. os.symlink(r"D:\Epic Games\Launcher\Portal\Binaries\Win64\EpicGamesLauncher.exe" , desktop + 'Epic Games')
  252.  
  253. os.symlink(r"D:\Innova\4game2.0\4game.exe" , desktop + 'Innova')
  254.  
  255. os.symlink(r"D:\Mail.Ru\GameCenter\GameCenter.exe" , desktop + 'Игровой центр')
  256.  
  257. os.symlink(r"D:\Origin\Origin.exe" , desktop + 'Origin')
  258.  
  259. os.symlink(r"D:\Rockstar Games\Launcher\Launcher.exe" , desktop + 'Rockstar')
  260.  
  261. os.symlink(r"D:\Steam\steam.exe" , desktop + 'Steam')
  262.  
  263. os.symlink(r"D:\Ubisoft Game Launcher\upc.exe" , desktop + "Uplay")
  264.  
  265. os.symlink(r"D:\Wargaming.net\GameCenter\wgc.exe" , desktop + "Wargaming")
  266.  
  267. os.symlink(r"F:\Discord\app-1.0.9005\Discord.exe" , desktop + "Discord")
  268.  
  269. os.symlink(r"F:\DD\Genshin Impact\launcher.exe" , desktop + "Genshin Impact")
  270.  
  271. os.symlink(r"F:\DD\Cyberpunk2077\bin\x64\Cyberpunk2077.exe" , desktop + "Cyberpunk2077")
  272.  
  273. os.symlink(r"F:\DD\Mozilla Firefox\firefox.exe" , desktop + "Firefox")
  274.  
  275. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/lnk_del_game/del_cyberpunk.bat", Path("C:/Users/Gamer/Documents/My Games/del_cyberpunk.bat"))
  276.  
  277. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/lnk_del_game/del_witcher.bat", Path("C:/Users/Gamer/Documents/My Games/del_witcher.bat"))
  278.  
  279. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/lnk_del_game/Delete_Cyberpunk_2077.lnk", Path(desktop + "Удалить Cyberpunk 2077.lnk"))
  280.  
  281. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/lnk_del_game/Delete_The_Witcher3_Wild_Hunt.lnk", Path(desktop + "Удалить The Witcher 3 - Wild Hunt.lnk"))
  282.  
  283.  
  284.  
  285. refresh_desktop = Path("C:/Users/gamer/Documents/rDesktop.exe")
  286.  
  287. urlRemote = 'https://cdnmgc.playkey.net/Games/Configs/adaptation_team/rDesktop.exe'
  288.  
  289. utils.try_download(urlRemote, refresh_desktop)
  290.  
  291. subprocess.Popen("C:/Users/gamer/Documents/rDesktop.exe", shell=True)
  292.  
  293.  
  294.  
  295. #xbox
  296.  
  297. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/xbox/Xbox.lnk", Path("C:/Users/Gamer/Desktop/Xbox.lnk"))
  298.  
  299. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/xbox/xboxBat.bat", Path("C:/Users/Gamer/Documents/launchXbox/xboxBat.bat"))
  300.  
  301. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/xbox/xboxIco.ico", Path("C:/Users/Gamer/Documents/launchXbox/xboxIco.ico"))
  302.  
  303. utils.try_download(r"http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/xbox/xboxVbs.vbs", Path("C:/Users/Gamer/Documents/launchXbox/xboxVbs.vbs"))
  304.  
  305. except Exception as ex:
  306.  
  307. pklog('ERR IN DESKTOP ICONS %s'%str(ex))
  308.  
  309.  
  310.  
  311. try: #Sort Icons
  312.  
  313. time.sleep(10)
  314.  
  315. reg_desktopok = Path('F:/DesktopOK/virtual_desok.reg')
  316.  
  317. subprocess.call(['reg', 'import', str(reg_desktopok)])
  318.  
  319. subprocess.call(['reg', 'import', str(reg_desktopok), '/reg:64'])
  320.  
  321. dok_config = Path(r'C:/Users/Gamer/AppData/Roaming/DesktopOK/DesktopOK__.dok') #desktop.dok
  322.  
  323. urlRemote = r'http://cdnmgc.playkey.net/Games/Configs/virtual_desktop/DesktopOK__.dok'
  324.  
  325. utils.try_download(urlRemote, dok_config)
  326.  
  327. os.startfile(dok_config)
  328.  
  329. except Exception as ex:
  330.  
  331. pklog('ERR IN ICONS SORT %s'%str(ex))
  332.  
  333.  
  334.  
  335. try:
  336.  
  337. steam_set_language('russian') #lang fix
  338.  
  339. update_steam_paths("F:/launch/Steam/") #install dir fix
  340.  
  341. except Exception as ex:
  342.  
  343. pklog('ERR IN STEAM FIXES %s'%str(ex))
  344.  
  345.  
  346.  
  347. try:# Battle net oops fix
  348.  
  349. utils.register_appinitdll_x64(r'D:\Battle.net\PKDefFiles\oo_x64.dll')
  350.  
  351. agent = r"C:\ProgramData\Battle.net"
  352.  
  353. if os.path.islink(agent) : os.unlink(agent)
  354.  
  355. except Exception as ex:
  356.  
  357. pklog('ERR IN Battle.net FIXES %s'%str(ex))
  358.  
  359.  
  360.  
  361. try:#install dir fix
  362.  
  363. dst = "C:/Users/Gamer/AppData/Roaming/Origin/local.xml"
  364.  
  365. urlRemote = 'https://cdnmgc.playkey.net/Games/Configs/virtual_desktop/local_roaming.xml'
  366.  
  367. utils.try_download(urlRemote, dst)
  368.  
  369. except Exception as ex:
  370.  
  371. pklog('ERR IN ORIGIN FIXES %s'%str(ex))
  372.  
  373.  
  374.  
  375. try: #Epic default install drive change
  376.  
  377. egs_settings_file = Path("C:/Users/gamer/AppData/Local/EpicGamesLauncher/Saved/Config/Windows/GameUserSettings.ini")
  378.  
  379. if os.path.exists(egs_settings_file):
  380.  
  381. rs = re_sub()
  382.  
  383. rs.sub(r'(DefaultAppInstallLocation)=.+',r'\1=D:/DD');
  384.  
  385. rs.apply(egs_settings_file)
  386.  
  387. else:
  388.  
  389. urlRemote = 'https://cdnmgc.playkey.net/Games/Configs/pk_config/Epic/GameUserSettings.ini'
  390.  
  391. utils.try_download(urlRemote, egs_settings_file)
  392.  
  393. except Exception as ex:
  394.  
  395. pypklog.log('ERR IN EPIC FIXES %s'%str(ex))
  396.  
  397.  
  398.  
  399. try: #change lang for uplay
  400.  
  401. uplay_file = Path("C:/Users/Gamer/AppData/Local/Ubisoft Game Launcher/settings.yaml")
  402.  
  403. if os.path.exists(uplay_file):
  404.  
  405. rs = re_sub()
  406.  
  407. rs.sub(r'(code:) .+', r'\1 ru-RU')
  408.  
  409. rs.apply(uplay_file)
  410.  
  411. else:
  412.  
  413. urlRemote = 'https://cdnmgc.playkey.net/Games/Configs/Ubisoft_Game_Launcher/settings.yaml'
  414.  
  415. utils.try_download(urlRemote, uplay_file)
  416.  
  417. except Exception as ex:
  418.  
  419. pklog('chamge lang for en ERR: %s'%str(ex))
  420.  
  421.  
  422.  
  423. try: #wargaming launcher fix
  424.  
  425. config_preferences = Path('D:/Wargaming.net/GameCenter/preferences.xml')
  426.  
  427. remoteConfig_preferences = config_preferences.with_name('preferences_virtual.xml')
  428.  
  429. urlRemote = 'https://cdnmgc.playkey.net/Games/Configs/Wargaming/%s' % remoteConfig_preferences.name
  430.  
  431. utils.try_download(urlRemote, remoteConfig_preferences)
  432.  
  433. file_helper.create_symlink(config_preferences, remoteConfig_preferences)
  434.  
  435.  
  436.  
  437. path_to_data = Path('D:/Wargaming.net/GameCenter/data')
  438.  
  439. if not os.path.exists(path_to_data):
  440.  
  441. os.makedirs(path_to_data)
  442.  
  443. remoteConfig_path = Path('D:/Wargaming.net/GameCenter/data/wgc_path.dat')
  444.  
  445. urlRemote_path = 'https://cdnmgc.playkey.net/Games/Configs/Wargaming/wgc_path_virtual.dat'
  446.  
  447. utils.try_download(urlRemote_path, remoteConfig_path)
  448.  
  449. except Exception as ex:
  450.  
  451. pklog('ERR IN WARGAMING FIX %s'%str(ex))
  452.  
  453.  
  454.  
  455. try: #epic games store fix
  456.  
  457. runasadmin_reg = Path('C:/Users/Gamer/Documents/runasadmin_virtual.reg')
  458.  
  459. urlRemote = 'https://cdnmgc.playkey.net/Games/Configs/epic_store/runasadmin_virtual.reg'
  460.  
  461. utils.try_download(urlRemote, runasadmin_reg)
  462.  
  463. subprocess.call(['reg', 'import', str(runasadmin_reg)])
  464.  
  465. subprocess.call(['reg', 'import', str(runasadmin_reg), '/reg:64'])
  466.  
  467. except Exception as ex:
  468.  
  469. pklog('ERR IN EGS FIX %s'%str(ex))
  470.  
  471.  
  472.  
  473. try: #rockstar fix
  474.  
  475. file_helper.create_symlink('C:/Program Files/Rockstar Games/Social Club', 'D:/Rockstar Games/Program_Files/Social Club')
  476.  
  477. file_helper.create_symlink('C:/Program Files (x86)/Rockstar Games/Social Club', 'D:/Rockstar Games/Program_Files_x86/Social Club')
  478.  
  479. file_helper.create_symlink('C:/ProgramData/Rockstar Games/Social Club', 'D:/Rockstar Games/ProgramData/Social Club')
  480.  
  481. file_helper.create_symlink('C:/Program Files/Rockstar Games/Social Club', 'D:/Rockstar Games/Program_Files/Social Club')
  482.  
  483. file_helper.create_symlink('C:/ProgramData/Rockstar Games/Launcher', 'D:/Rockstar Games/ProgramData/Launcher')
  484.  
  485. except Exception as ex:
  486.  
  487. pklog('ERR IN ROCKSTAR FIX %s'%str(ex))
  488.  
  489.  
  490.  
  491. try: #cyberpunk resolution fix
  492.  
  493. width, height = int(sys.argv[1]), int(sys.argv[2])
  494.  
  495. config_adaptive = Path('C:/Users/Gamer/AppData/Local/CD Projekt Red/Cyberpunk 2077/UserSettings.json')
  496.  
  497. rs = re_sub()
  498.  
  499. resolution = str(width) + 'x' + str(height)
  500.  
  501. rs.sub(r'("Resolution",\n\D*)("\d*x\d*")', r'\1"%s"' %resolution)
  502.  
  503. rs.apply(config_adaptive)
  504.  
  505. except Exception as ex:
  506.  
  507. pklog('ERR IN CYBERPUNK FIX %s'%str(ex))
  508.  
  509.  
  510.  
  511. try:#COD shaders fix
  512.  
  513. shader = 'C:/ProgramData/Activision/Call Of Duty Black Ops Cold War/shadercache/ppsod.dat'
  514.  
  515. if os.path.exists(shader):
  516.  
  517. os.remove(shader)
  518.  
  519. gpu = 'T4'
  520.  
  521. if 'NVIDIA Tesla T10' in utils.get_gpu(): gpu = 'T10'
  522.  
  523. if "2070" in utils.get_gpu(): gpu = '2070'
  524.  
  525. if "1080ti" in utils.get_gpu(): gpu = '1080Ti'
  526.  
  527.  
  528.  
  529. configSh = Path(shader)
  530.  
  531. remoteConfigSh = configSh.with_name('ppsod_%s.dat' % gpu)
  532.  
  533. urlRemoteSh = 'https://cdnmgc.playkey.net/Games/Configs/CoD_CW/%s' % remoteConfigSh.name
  534.  
  535. utils.try_download(urlRemoteSh, configSh)
  536.  
  537. except Exception as ex:
  538.  
  539. pklog('ERR IN COD SHADER %s'%str(ex))
  540.  
  541.  
  542.  
  543. clWindows()
Add Comment
Please, Sign In to add comment