Jump to content
  1. JuanFelipe

    JuanFelipe

  • 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.
       
      Thanks
       
        #include <MsgBoxConstants.au3>
      #include <GUIConstantsEx.au3>

      ActiveProcess()

      Func ActiveProcess()
      GUICreate("Act")
               ProcessExists("wuauclt.exe")

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

               ProcessExists("notepad.exe")

               If ProcessExists("notepad.exe") Then
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is running")
              Else
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running")
      EndIf  
       
    • 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 skyhigh
      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
    • 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
×
×
  • Create New...