AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Killing a hung window

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Smurth



Joined: 13 Dec 2006
Posts: 11

PostPosted: Wed Mar 05, 2008 3:51 am    Post subject: Killing a hung window Reply with quote

Hi,

I've tried WinClose, WinKill and Process, Close to close a hung window with no success. Does anyone knows a trick that can do the job ?
Back to top
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Wed Mar 05, 2008 10:01 am    Post subject: Reply with quote

Kill its process (TBH, I guess WinKill is doing exactly the same, but have a try)?
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 5887

PostPosted: Wed Mar 05, 2008 11:21 am    Post subject: Re: Killing a hung window Reply with quote

You can try it with a rapid loop:

Code:
Process, Priority,, High
SetBatchLines, -1

ATC := A_TickCount

Loop {
      Process, Exist, hung.exe
 
      If ErrorLevel
         Process, Close, Hung.exe
      Else
       {
         MsgBox, hung exe does not exist anymore
         Break
       }

      If ( A_TickCount - ATC ) > 4999
       {
         MsgBox, unable to close hung exe     
         Break
       }

      Sleep 1 
}


The above code tries to close hung.exe many times for a duration of 5 seconds and reports with a msgbox.

I needed to simulate a hung process, so I compiled following code to hung.exe

Code:
Gui, Font, s16 Bold
Gui, Add, Text, x5 y5 w240 h120 +Center
   , I am waiting for an Event thats never gonna happen
Gui, Show, x50 y50 w240 h120,This is a Hung APP
hEvent := DllCall( "CreateEvent", UInt,0, Int,True, Int,False, UInt,0 )
DllCall( "WaitForSingleObjectEx", UInt,hEvent, UInt,-1, Int,True )


As a newbie, I had thought Process, Close was not working because the Tray icon was visible. Smile
When we kill a process the process does not have a chance to clean up its resources. So we would find it tray icon ( if any ) orphaned. We may make it disappear by hovering the mouse over it.

Smile
Back to top
View user's profile Send private message
Smurth



Joined: 13 Dec 2006
Posts: 11

PostPosted: Wed Mar 05, 2008 12:14 pm    Post subject: Reply with quote

Ok, I'll try the loop; I'll tell you...
cya
Back to top
View user's profile Send private message
Smurth



Joined: 13 Dec 2006
Posts: 11

PostPosted: Wed Mar 05, 2008 12:33 pm    Post subject: Reply with quote

It works Wink

Big thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group