我的項目圍繞自動執行一些任務。我打開一個應用程序,一個新的3D文件,然後我從一個訪問基地做一些操作。我選擇了pywinauto
和圖形交互,因爲操作員需要對軟件進行干預。pywinauto更改應用程序名稱
我的問題是:當我打開一個新文件時,應用程序的名稱會改變。還有就是代碼:
# Search data on the Access Base
cursor = conn.cursor()
cursor.execute("SELECT * FROM [SophieBot_produit] WHERE [SophieBot_produit].[ID PRODUCTION] =?",(prod))
produit_sql = cursor.fetchall()
production, statut, produit_value, nb_element, cas, gamme, sl_tps_open, sl_tps_gen, sl_tps_save = produit_sql[0]
produit = str(produit_value).zfill(8)
# Data work, check with print()
#Connecting to the software
app = application.Application()
app.Connect(path='C:\\myprogram')
# First step everything works
app.SLMAutoFab.menu_select("File -> Open")
app.window_(title_re="Open file.*").Edit.SetEditText('S:\\32 - Articles\\'+ str(gamme) +'\\' + str(cas) +'\\' + str(produit) +'_sup.stl')
app.window_(title_re="Open file.*").Ouvrir.Click()
# New step is to do operation on the software
現在我的軟件應用程序的名稱改變Myprogram - 3DFile
當你寫的新名稱一切正常,例如:
app.SLMAutoFab00057389_sup.Part.Click()
但軟件變更的名稱,所以我嘗試:
win = 'MyProgram' + str(produit)
app.win.Part.Click()
該代碼不起作用,錯誤消息是:
MatchError: Could not find 'win' in 'dict_keys
我試圖用window(handle)
連接,如果它的工作原理將更新帖子。任何提示或指針非常感謝。
,請複製粘貼確切的錯誤信息 –
嗨插入錯誤消息的另一條評論 – Axel35136