Poksi Posted December 2, 2011 Posted December 2, 2011 Hi! I need an script what closes an program when its non responding. but before he close the program it should check every 1 minute if its active and every minute it should activate it per mouseclick or something and then it should close it when its non responding. can someone write me a little script what can do this? sorry for my bad english. what the script should do: closes a program what is non responding activate the window/program every 1 minute hope that someone can help me. thanks. best regards
guinness Posted December 2, 2011 Posted December 2, 2011 Search the forum for 'Hung Application' this will show you many examples of how closing an application that is hanging. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Poksi Posted December 2, 2011 Author Posted December 2, 2011 (edited) @guinness: Thank you very much, will do this. ok find this one: ; finding if an application is hung ; neogia If _NotResponding("TITLE HERE", "TEXT HERE[OPTIONAL]", 1) Then; The last parameter indicates whether you want to close the hung app or not. MsgBox(0,"", "Hung Application, closing app now.") Else MsgBox(0,"", "Application running as intended.") EndIf Func _NotResponding($title, $text, $closeIfHung = 0) $hWnd = WinGetHandle($title, $text) If $hWnd == "" Then MsgBox(0,"Error","Could not find window") Exit EndIf $retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $hWnd) If @error == 0 Then If $retArr[0] == 1 Then If $closeIfHung Then ProcessClose(WinGetProcess($title, $text)) EndIf Return 1 EndIf Else Return 0 EndIf EndFunc but what should i write here: If _NotResponding("TITLE HERE", "TEXT HERE[OPTIONAL]", 1) at the "title here". the title when its frozen or the nromal title? i mean example "firefox.exe" or "firefox.exe - not responding". and when i want to give this in an loop and check if its not responding every 1 minute then i should write: While 1 Sleep(6000) "SCRIPT HERE" Wend or? thanks for help. regards, Poksi Edited December 2, 2011 by Poksi
Poksi Posted December 2, 2011 Author Posted December 2, 2011 Ok i got it now with a normal batch file, started with autoit . dont need autoit but i use it to start the batchfile got this info and help from an user from the german autoit forum: $File = FileOpen(@ScriptDir & 'killtask.bat', 2) FileWrite($File, 'taskkill /f /fi "status eq not responding"') FileClose($File) While Sleep(6000) RunWait(@ScriptDir & 'killtask.bat', @SystemDir, @SW_HIDE) WEnd is exactly that what i need.
Blue_Drache Posted December 2, 2011 Posted December 2, 2011 (edited) Title is either a partial or full window title, usually... and if the UDF author did his/her homework, you could use window handles (My preferred method) too. Window titles are mutable. Handles are not. Edited December 2, 2011 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
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