1

I am using AutoItX3.Control via win32com.client to detect and close Windows security dialog ("do you trust..."). I use WinExist with window title\text and It works fine when running the python script (Autoit version is 3.3.8.1).

Problem is with the compiled Python script (compiled with PyInstaller). The window is not detected and I can't close it. When I run the Autoit application (SciTE4AutoIt3) it does detect the window.

Any advice?

///// adding some more info: using the following autoit options:

Opt('WinWaitDelay', 500)
Opt('SendKeyDelay', 8)
Opt('WinTitleMatchMode', 4)
Opt('WinSearchChildren', 1)
Opt('SendKeyDownDelay', 10)
Opt('WinDetectHiddenText', 1)

also, Im running the autoit on another process as an instance of the Process class (Process(target=handle_window_func))

Ido A
  • 87
  • 1
  • 1
  • 8

3 Answers3

0

Did you try to use the classic method to set the the active X options? Like:

oAutoItx.AutoItSetOption("WinTitleMatchMode", 4)

instead of: oAutoItx.Opt("WinTitleMatchMode", 4)

Also AutoItx help says: "Mode 4 ("only" Kept for backward compatibility)". So check your options and took the simplest you can use.

Bijan
  • 7,737
  • 18
  • 89
  • 149
ReFran
  • 897
  • 8
  • 14
0

Try using the following code:

import pythoncom
pythoncom.CoInitialize()

This initializes the COM libraries for the calling thread.

See more info here: http://docs.activestate.com/activepython/2.5/pywin32/pythoncom__CoInitialize_meth.html

Nir
  • 894
  • 3
  • 13
  • 24
0

Solved by running both the autoit functionality and the process triggering the pop up window in the same script and monitoring for the pop up while the process runs: popup_p = Popen(*cmd_args, no_wait=True, *cmd_kwargs) while popup_p.is_running(): handle_window_func() time.sleep(1) Note that Popen is run with no_wait - returns the process without waiting for it to finish.

Ido A
  • 87
  • 1
  • 1
  • 8