Jump to content

Replicate Windows Close Button


Javier
 Share

Recommended Posts

Hi All,

What i'm trying to do is to replicate the command action equal to windows close button (red X on windows). I tryed already few options with no sucess.

This is what i'm using, from AutoIt examples

; WMI Example
;
; Kill a process
;
; Derived from a KiXtart script ENDPROC by Conrad Wheeler
; See also: http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=82164
; execute a program

Func EndProc($proc, $strComputer=".")

  $oWMI=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
  $oProcessColl=$oWMI.ExecQuery("Select * from Win32_Process where Name= " & '"'& $Proc & '"')

  For $Process In $oProcessColl
    $Process=$Process.Terminate
  Next

EndFunc


; Example usage

Endproc ("iexplore.exe")  ; Kills all instances of the Internet Explorer :-)

This code works like a charm, closing all windows explorer. For some reason is not the same when you just click on the red button closing the windows.

Please any help will be appreciated

Thanks in advance.

Javier

Link to comment
Share on other sites

Thanks Richard,

WinClose("[CLASS:Notepad]", "")

With this command (using notepad), also works but I cannot make it with internet explorer. Can you please, explain how.

Here's a little bit more details about this project.

I'm using APPEON in a our website to load the application. When you open this webpage (appeon add-on) on our appeon manager shows one new session opens. So far so good.

When you close the webpage using windows close button, this session ends intermediately. Perfect, this is the way that suppose to work.

Here is my problems, when you do it using commands like taskkill (DOS) or process.close() etc, it doesn't work.

The session still opens in our Appeon manager

Any idea how I can try?

Thanks

Javier

Link to comment
Share on other sites

Hi Richard,

Your explanation solved the problem. Big thanks for that!

The only one now is when I closing the windows, sometimes, I'm getting this error message below and doesn't allow to close it.

closing the winows may cause it to crashand display error messages

I tryed winkill command with same result

Do you have any other idea?

Thanks in advance

Link to comment
Share on other sites

What gives you that message? AutoIt or the program being closed?

Internet Explorer detects activity in that webpage and its telling me if I want to close or not the webpage. I was using winkill() to force this windows to close the webpage without success.
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...