 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Smurth
Joined: 13 Dec 2006 Posts: 11
|
Posted: Wed Mar 05, 2008 3:51 am Post subject: Killing a hung window |
|
|
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 |
|
 |
BoBoĻ Guest
|
Posted: Wed Mar 05, 2008 10:01 am Post subject: |
|
|
| 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
|
Posted: Wed Mar 05, 2008 11:21 am Post subject: Re: Killing a hung window |
|
|
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.
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.
 |
|
| Back to top |
|
 |
Smurth
Joined: 13 Dec 2006 Posts: 11
|
Posted: Wed Mar 05, 2008 12:14 pm Post subject: |
|
|
Ok, I'll try the loop; I'll tell you...
cya |
|
| Back to top |
|
 |
Smurth
Joined: 13 Dec 2006 Posts: 11
|
Posted: Wed Mar 05, 2008 12:33 pm Post subject: |
|
|
It works
Big thanks |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|