Sign in to follow this  
Followers 0
Javier

Replicate Windows Close Button

14 posts in this topic

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

Share this post


Link to post
Share on other sites



WinClose("Title")

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Is there a specific title all of the windows you want to close would share?

Share this post


Link to post
Share on other sites

Sure, this is one of the common

WebHotelEXPERT 6.0 -

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Opt("WinTitleMatchMode", 2)

$windows = WinList("WebHotelEXPERT 6.0 -")

For $i = 1 to $windows[0][0]
    WinClose($windows[$i][1])
Next

Does something like this work?

Edited by Richard Robertson

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I was using winkill() to force this windows to close the webpage without success. Is winkill() not suppose to force the windows to close?

Edited by Javier

Share this post


Link to post
Share on other sites

Any Help?

Thanks

Share this post


Link to post
Share on other sites

WinKill just wraps a native API. If IE is rejecting that, there's nothing you can do.

Share this post


Link to post
Share on other sites

ProcessClose()


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

The first thing they tried was killing the process but they want the effect of the window being closed.

Share this post


Link to post
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
Sign in to follow this  
Followers 0