Jump to content

Recommended Posts

Posted (edited)

Hi all,
 
i'm trying to automate an app installer with a checkbox at the end. If i leave it checked, the installed application will start. ( child process )
How can i call a WinClose method on it?
 
I'm using win32com.client w/ Dispatch in python 2.7
Tried WinSearchChildren set to 1, WinActivate, WinGetState, WinExists but it fails.
What is the way to handle the child properly?
I can get the pid, and force to close it by processkill, but its not the same as WinClose :(>
 
Any idea?

from win32com.client import Dispatch
_autoit = Dispatch("AutoItX3.Control")
_autoit.Opt("WinSearchChildren", 1)
_autoit.Run(installer)
_autoit.WinWaitActive("[Class:#32770]", "", 3)
#Language selection
_autoit.ControlCommand("[Class:#32770]", "", "ComboBox1", "SetCurrentSelection", 1)
#Next
_autoit.ControlClick("[Class:#32770]", "", "Button1")
_autoit.WinWaitActive("[Class:#32770]", "", 5)
#Install button
_autoit.ControlClick("[Class:#32770]", "", "Button2")
_autoit.WinWaitActive("[Class:#32770]", "", 5)
#Pull until install finishes
while not _autoit.ControlGetText("[Class:#32770]", "", "Static14"):
    time.sleep(0.25)
_autoit.WinWaitActive("[Class:#32770]", "", 3)
#This checkbox allow to run program after installer finish
#_autoit.ControlCommand("[Class:#32770]", "", "Button4", "UnCheck", "")
_autoit.WinWaitActive("[Class:#32770]", "", 3)
#Close
_autoit.ControlClick("[Class:#32770]", "", "Button2")
#wait till it loads
time.sleep(3)
print _autoit.WinExists("ClassWindow")
print _autoit.WinGetState("ClassWindow")
_autoit.WinSetState("ClassWindow", "", autoit.SW_SHOW)
_autoit.WinActivate("ClassWindow")
_autoit.WinClose("ClassWindow")
Edited by s4pp3r
Posted

Welcome to AutoIt and the forum!

I can't help with your problem but I'm sure you will get as much help as possible when posting your code.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

A little update, all previous try can work if i use Title instead of the class...i can't use it because currently ~17 language is supported, and don't want to using regex match or any hardcoded string in it

update#2:

Looks like Au3Info window control does not work, but WinGetClassList tells me this:

Chrome_WidgetWin_0
Chrome_RenderWidgetHostHWND
CompositorHostWindowClass
 
tried, Chrome_RenderWidgetHostHWND and autoit.WinClose("[CLASS:Chrome_RenderWidgetHostHWND; INSTANCE:1]") but still fails to close it :(
 
okay: acceptable solution
 
because its a special application ( a form with chrome render ) cannot acces window class properly, so i would check for child processes and using winclose with title method
Edited by s4pp3r
Posted

Does not work...

>>> au.WinClose("[CLASS:Chrome_WidgetWin_0]", "")
1
>>> au.WinClose("[CLASS:Chrome_WidgetWin_1]", "")
1
 
Cannot control a chrome class within a form. So i will use title by language codes and matching it with the form title.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...