Jump to content

[Question] Why `WinKill` does not work?


HoratioCaine
 Share

Recommended Posts

Hi, everyone.

I have python code for kill window,  but sometimes it does not working .

My code is :

import subprocess
import time
import ctypes

au3_dll = ctypes.windll.LoadLibrary(r'D:\AutoIt\AutoItX3.dll')

def close_ie(title):
    subprocess.Popen(f"C:/Program Files (x86)/Internet Explorer/iexplore.exe https://cn.bing.com/?mkt=zh-CN")
    time.sleep(2)
    
    au3_dll.AU3_Opt("WinTitleMatchMode", 2)
    ret = au3_dll.AU3_WinKill(title, "")
    print(ret)

if __name__ == '__main__':
    title = '必应 - Internet Explorer'
    for i in range(10):
        close_ie(title)

My expectation is that all IE windows will be closed, but there will always be a few windows still there.

My env:
    win10      64bit
   python3.6.4
   autoit     v3.3.14.2

 

Any suggestions would be appreciated  :)

Link to comment
Share on other sites

16 hours ago, Danp2 said:

您是否尝试过使用 ProcessClose 代替?

Sorry, I didn't.       

The information I can get is the title, and I want to operate the window that was last activated.

When the AU3_WinKill function does not work for the first time, execute AU3_WinKill again, and it will succeed. But I dont know When to succeed and when to fail···

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...