1.安裝python
下載地址:https://www.python.org/
2.安裝uiautomation
安裝pip,步驟略(一般裝完python已經安裝)
打開cmd 執行:pip install uiautomation
3.基本操作
import subprocess import uiautomation as automation import time def main(): subprocess.Popen('redcore.exe') #啟動瀏覽器 time.sleep(1) redWindow = automation.WindowControl(searchDepth = 1, ClassName = 'Chrome_WidgetWin_1') #取瀏覽器handle if not redWindow.Exists(0): automation.Logger.WriteLine('未找到紅芯瀏覽器,請重試!',automation.ConsoleColor.Yellow) return redWindow.ShowWindow(automation.ShowWindow.Maximize) #最大化瀏覽器 redWindow.SetActive() time.sleep(1) # MenuOperation.menuOperation(redWindow) #操作瀏覽器菜單 login = redWindow.TextControl(Name=u'未登錄',searchDepth=3,searchWaitTime=10) if login.Exists(5): print("未登錄!") loginImages = redWindow.ImageControl(searchDepth=6,foundIndex=6) time.sleep(1) loginImages.Click() print(loginImages) time.sleep(2) redWindow.SendKeys('{alt}{F4}') time.sleep(2) if __name__ == '__main__': main() input('全部運行完成')