Jump to content

How to check if a process is responding?

Recommended Posts

I wrote a script based on a loop. I want my script to check at the start of every cycle if one or more processes are still running and responding, then react if they are no more. I can do the former using ProcessExist, but how about the latter?

Does exist a function that verifies if a process is still responding?

Thanks in advance

Link to post
Share on other sites
  • Moderators

Process "responding" is going to be different depending on the process. What is the process, and what defines that it is still working (writing to a db, output to a file, etc. etc.)?

You can always use ProcessGetStats, to return an array of the operations performed, and compare from loop to loop (e.g. if number of read operations between loop 1 and 2 has increased by at least x%)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Per this post, you are trying to monitor Firefox and the Flash plugin. Can you provide a link to the site you are trying to interact with?

From that, how do you deduce "trying to monitor Firefox and the Flash plugin"?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

Per this post, you are trying to monitor Firefox and the Flash plugin. Can you provide a link to the site you are trying to interact with?

Thank you for yor help.

Here some examples



and more streaming sites using flash plugin.

Here is the background, a description of the script I am coding:

A script to open Firefox and go to a random URL. The url changes randomly every X minutes between 12.00 Pm and 4.00 Pm through a loop.

I want to make my script to be as indipendent as possible. To do so I need it to check if:

- Firefox is still working and responding (working on my on my own)

- Adobe Flash plugin is still working

- Plugin-container is still working

- ?Others sensible processes able to compromise the script?

Also, I am not sure what is better, to perform the check at the beginning of the loop or to perform it regularly, i.e every 5 minutes.


EDIT: NOPE: I am working on streaming sites only, no bots involved :)

Edited by skyhigh
Link to post
Share on other sites

maybe https://www.autoitscript.com/forum/topic/116592-checking-if-process-is-suspendedhangednot-responding/

I read in stackoverflow:

There is no general solution to this problem.

It is impossible to tell if a particular process is hanging or not, because the term "hanging" is entirely dependent upon the context of the process that is executing.

The hanging process will always do what it was coded to do. The developer may have coded it badly, but Windows can't make assumptions about what is right/wrong.

Possible ideas to try might be:

  1. The Process.Responding call will indicate whether or not a process that is executing a windows message loop is responding.

  2. One possible solution for the more general case might be to poll the memory usage for the process at intervals and if it doesn't change after enough time, assume that it is hung. You could do this with Process.WorkingSet64. However, I expect that this would cause a number of false positives - stable processes that are not processing anything might appear to be hanging. It would also cause false negatives where a hanging process that had a memory leak would appear to be doing something useful, when in fact it was stuck in a loop.

  3. If the process writes to the StandardError/StandardOutput streams (as many console applications do), then you could try listening for such output: Process.BeginOutputReadLine and Process.BeginErrorReadLine. If there is no such output within a given period, you might deduce that it has hung.

Edited by argumentum
Link to post
Share on other sites
  • 1 month later...

Well, I am still alive and so is my script.
After the information you gave me I have performed some searches through the net. I have found a software that could be useful to me: Kiwi Application Monitor. It has a free and a paid version. The paid version is the most interesting one because it allows you to set advanced rules for specific processes. The rules are not different from scripts created through a GUI:


As you can see from the screenshot Kiwi has even a way to know if a process is responsive or not, which seems exactly what I am looking for. Unfortunately Kiwi has not a trial version, so I can't try its full power.
If I buy it my problem will change: I'll need to manage the interaction between my autoit script and Kiwi . I am thinking about it, but it does not look to be a simple task. While I would solve the main problem (what to if FF stop responding or crashes) I have not figured out yet how to tell autoit that a third part software is closing or rebooting FF. I don't think a specific process would appear in these cases.

What do you think about it?



Edited by skyhigh
Link to post
Share on other sites

I think it's an advertisement for paid software.

You have not even tried to implement this yourself, even though everything in that screenshot is easily done in AutoIt.

So yes, an advertisement , that's what I think about it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

Do you think it's spam? I can understand your reasons but you are totally wrong. To be clear, I have just asked to a mod if I ought to edit the name of the software from the post and from the screenshot. If he will tell me to do it, I will execute immediately.

But I will not give up the core of my question.

I began to work on this script months ago. I wrote it one piece at time, some parts of it thanks to the people of this forum. I do not have much time to dedicate to it but I really want to complete my script.

The last answer from @argumentum clearly says that there is no a definitive and easy way for autoit to do what I need. Paying some dollars could save me from spending a lot of time of study and trial-and-error scripting. In this case I'll be glad to pay!

But if you do know better than him please, go on and tell me, explain to me: because I would be even gladder if I spare some bucks.




Link to post
Share on other sites

There have been many suggestions here in this thread, you've come back after a while posting a third party app, but you have not tried any of the suggestions or at least not posted what you tried, and that's what makes me think it's just an ad.

But I'm just a person on the internet who answered your question, you can safely ignore me.

And that screenshot does not mention a process at all, just app, it's most likely using some or all of the approaches mentioned here.

EDIT: And here's another thought, when a process stops working, windows generally notifies you off it "Blah has stopped working, close, debug, send error report" etc...


Can you clarify what "non responsive" means from a system point of view? What exactly is Kiwi looking for with this condition?

It's like pinging a server: Kiwi sends a command to an application GUI to which she responds. If the application does not respond, it either froze or is under heavy processing. So if you include the "above 90% processor load" rule, you can rule the last occasion out.


In other words "_WinAPI_IsHungAppWindow"

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

The last answer from @argumentum clearly says that there is no a definitive and easy way for autoit to do what I need.

lol, nope, I said what's written. And looking at the website, the app. they show, can be perfectly written in AutoIt.
As far as "an easy way", well, the code has to be written. It certainly is time consuming.
The money the ask is not much, go for it. But I feel, it will not satisfy your wanting.

Anywayz, just wanted to clarify and give my 2 cents.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jake_s
      Hi All, 
      I am a begginer in auto it. I am trying to build simple gui that will show me if for example notepad.exe process is currently running on the system. I have built something like this, but when I execute it shows me message boxes, but I want the results to show in gui. If you can help me start with this.
        #include <MsgBoxConstants.au3>
      #include <GUIConstantsEx.au3>


      Func ActiveProcess()

             If ProcessExists("wuauclt.exe") Then
       MsgBox($MB_SYSTEMMODAL, "", "Windows Upates are running")
       MsgBox($MB_SYSTEMMODAL, "", "Windows Updates are not running")


               If ProcessExists("notepad.exe") Then
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is running")
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running")
    • By therks
      Is there any reason that ProcessExists would start returning false on a process that still .. exists?
      I'm having an issue that I'm so far unable to reproduce reliably, so this is more a general question/advice thread. I have a rather elaborate script running and interacting with a server application. Because the server can crash, one of the purposes of my script is to relaunch the server if it stops.
      I'm accomplishing this by storing the PID whenever I Run() the server, and I have an if statement with ProcessExists() in a loop to relaunch. This is a snippet:
      While 1 If Not ProcessExists($I_PID) Then _LogWrite('Process lost: ' & $I_PID) If TimerDiff($iRelaunchTimer) < 5000 Then $iRelaunchCount += 1 Else $iRelaunchCount = 1 EndIf If $iRelaunchCount <= 5 Then _LogWrite('Relaunching... (attempt ' & $iRelaunchCount & ')') _Launch() Else Local $sRelaunchExceeded = 'Relaunch looped ' & $iRelaunchCount & ' times in ' & Round(TimerDiff($iRelaunchTimer)/1000) & ' seconds. Check that server is not already running. Exiting.' _LogWrite($sRelaunchExceeded) MsgBox(0x10, $APP_NAME, $sRelaunchExceeded) ExitLoop EndIf $iRelaunchTimer = TimerInit() Else ; Do a bunch of other stuff EndIf WEnd Func _Launch() Global $I_PID = Run($SERVER_CMD, $SERVER_DIR, @SW_HIDE, $STDERR_MERGED) If @error Then MsgBox(0x10, $APP_NAME, 'Error running command:' & @LF & $SERVER_CMD & @LF & @LF & 'In directory:' & @LF & $SERVER_DIR) ; OK: 1 Exit 600 EndIf _LogWrite('Server launched (PID:' & $I_PID & ').') IniWrite($INI_FILE, 'Config', 'PID', $I_PID) EndFunc That's not really runnable, but you get the general idea. As I suggested above, the issue I'm experiencing is that sometimes ProcessExists returns false even though the process does still exist (getting the PID from the log, and checking task manager I can see it's still running with the same PID), and the server won't relaunch if it's already running. And the major problem I'm having with diagnosing this is that it happens completely intermittently. It could go for days just fine, or only hours (it's never quick though of course). The server runs on our media computer all the time and the computer and server sometimes go for a few days without being checked on, but ideally we'd like it running all the time.
      Anyway, I'm stumped, so any advice on offer will be gratefully accepted.
    • By u01jmg3
      HotKeySet("^``", "toggle_media_controls") ; Ctrl + ` While 1 Sleep(100) WEnd If Not ProcessExists("wmplayer.exe") And RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") = 1 Then ; Disable autohide controls RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0") EndIf Func toggle_media_controls() Local $sVar = RegRead("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled") If ProcessExists("wmplayer.exe") Then If $sVar = 0 Then ; Enable autohide controls RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "1") Else ; Disable autohide controls RegWrite("HKCU\Software\Microsoft\MediaPlayer\Preferences", "HoverTransportsEnabled", "REG_DWORD", "0") EndIf EndIf EndFuncHow do I amend this code so that without pressing a hotkey, after Windows Media Player is not running, the regkey above is set to 0?
      My function and hotkey all work without issue
    • By JuanFelipe
      Gentlemen Good morning, today I ask you a little help to you with a check I'm trying to do, it is I want to run a .exe that I did, what I do is that before running check if it is already that open, am using ProcessExists, but what happens is that I just to run first mistake, I tried to do it in different ways, but I'm not.
      $proceso = ProcessExists("aceptar ventanas business.exe") If $proceso > 2 Then MsgBox(16,"Error","Ya esta abierto") Else while 1 If WinExists("Recuperando los datos...")Then WinActivate("Recuperando los datos...") Send("{enter}") Else EndIf WEnd EndIf  
  • Create New...