Created
August 1, 2016 14:29
-
-
Save kuguma/3080144548b38d9ab9a3820a23032e74 to your computer and use it in GitHub Desktop.
This file contains 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 -*- | |
""" | |
About: | |
Auto-tool for Native Instruments KOMPLETE9 Plugin Update | |
Requirements: | |
- Python3 | |
- Windows | |
- pywinauto | |
How to Use: | |
1. Use NI Service Center App and download all updater EXE. | |
2. Put together all updater EXE into something single folder. | |
3. Specify the path that folder on this script. | |
4. Close other programs and execute this. While Script is runnning, please don't do other operations. | |
5. Sometimes this script fail. If when it happend, delete(or move) succeeded updater, and re-run this. | |
""" | |
""" | |
KOMPLETE9のプラグイン更新の自動化ツール. | |
実行前にService Centerで更新用のexeを落としてきて適当なフォルダにぶち込み,そのパスを下のpathの部分に設定しておく. | |
その後動かすと勝手にマウスを操作してインストールをはじめます.実行中は他の操作を行わないこと. | |
KOMPLETEのクリーンインストールをしたあと60個位プラグインを手動で更新するのが面倒なので作った. | |
""" | |
import os | |
import subprocess as sp | |
import time | |
import pywinauto | |
path = 'C:/installer_folder_path' # <- modify this | |
def tick(): | |
time.sleep(0.5) | |
def wait_startup(): | |
ng = True | |
while(ng): | |
try: | |
app = pywinauto.Application().connect(title_re = 'Native Instruments.*') | |
ng = False | |
except: | |
time.sleep(1) | |
ng = True | |
return app | |
def wait_finish(app): | |
ng = True | |
while(ng): | |
try: | |
app.top_window_()[u'Finish'].Click() | |
ng = False | |
except: | |
time.sleep(0.5) | |
ng = True | |
return | |
def go_next(app): | |
while(True): | |
if app.top_window_()[u'Finish'].Exists(): | |
wait_finish(app) | |
break | |
elif app.top_window_()[u'TRzCheckBox'].Exists(): | |
app.top_window_()[u'TRzCheckBox'].Click() | |
tick() | |
app.top_window_()[u'&Next >'].Click() | |
elif app.top_window_()[u'&Next >'].Exists(): | |
try: | |
app.top_window_()[u'&Next >'].Wait('enabled',timeout=3) | |
app.top_window_()[u'&Next >'].Click() | |
except: | |
pass | |
tick() | |
def main(): | |
files = os.listdir(path) | |
os.chdir(path) | |
n = sum(1 for x in files if x.find('Setup PC.exe')!=-1) | |
cnt = 0 | |
for file in files: | |
cnt += 1 | |
if file.find('Setup PC.exe')==-1: | |
continue | |
print('install({cnt}/{n}) -> {file}'.format(**vars())) | |
app_path = os.path.abspath(path+'/'+file) | |
app = pywinauto.Application().Start(app_path) | |
app = wait_startup() | |
go_next(app) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment