Javier Posted April 15, 2011 Posted April 15, 2011 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
Javier Posted April 15, 2011 Author Posted April 15, 2011 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
Richard Robertson Posted April 15, 2011 Posted April 15, 2011 Is there a specific title all of the windows you want to close would share?
Javier Posted April 15, 2011 Author Posted April 15, 2011 Sure, this is one of the common WebHotelEXPERT 6.0 -
Richard Robertson Posted April 15, 2011 Posted April 15, 2011 (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 April 15, 2011 by Richard Robertson
Javier Posted April 20, 2011 Author Posted April 20, 2011 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 messagesI tryed winkill command with same resultDo you have any other idea?Thanks in advance
Richard Robertson Posted April 20, 2011 Posted April 20, 2011 What gives you that message? AutoIt or the program being closed?
Javier Posted April 21, 2011 Author Posted April 21, 2011 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.
Javier Posted April 21, 2011 Author Posted April 21, 2011 (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 April 21, 2011 by Javier
Richard Robertson Posted April 23, 2011 Posted April 23, 2011 WinKill just wraps a native API. If IE is rejecting that, there's nothing you can do.
Blue_Drache Posted April 26, 2011 Posted April 26, 2011 ProcessClose() Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Richard Robertson Posted April 26, 2011 Posted April 26, 2011 The first thing they tried was killing the process but they want the effect of the window being closed.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now