Jump to content

Help with WinClose/WinKill


Recommended Posts

I have this code:

if WinExists("[Title:notes.csv - Notepad]") then
        .
        .
        .
        sleep(1000)
        ;ProcessClose( "notepad.exe" )
        WinClose("[Title:notes.csv - Notepad]")
        WinKill("[Title:notes.csv - Notepad]")
    endif

Why WinClose, WinKill not reliable in closing the specified notepad?
Only ProcessClose was reliable in closing notepad all the time?

I dont want to use ProcessClose because, it will close "other" notepads. I only want to close the notepad that had the notes.csv file opened..

 

Link to comment
Share on other sites

What OS are you running this on?  If it is Win10, one possible reason that particular method of identifying the window might fail, is that the title in Notepad will include an asterisk (*) when the file is modified.  This doesn't happen on Win7.  One way to be able to have it work regardless of the OS, is to use RegExpTitle to look for a partial match or use "Opt('WinTitleMatchMode', -2)", which will look for a case-insensitive substring match.  Look at the help file to see how each is implemented.

If you opened notepad in your script, then the most reliable way of identifying the window is to use its handle.

Edited by TheXman
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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