Guest Posted February 2, 2015 Share Posted February 2, 2015 (edited) Hello, I want to detect this kind of window: And this: In widows 7 and 8. And get its handle to read its content How it can be done? I think that I need to use _WinAPI_FindWindow but i don't know what parameters I need to write in this function. I can't find it by title because there is no unique string in the title(only the name of the app).. Thanks for helpers! EDIT: The overall goal is to constantly check if the process crashed with "has stopped working" error. one way I thought of is to check for this window.. But if there is a better way then I prefer the better way Something I now think about it is to read every X seconds the windows event log and check there if the error occurred and reed the error content from there. I check now how I can do that Edited February 2, 2015 by Guest Link to comment Share on other sites More sharing options...
alienclone Posted February 2, 2015 Share Posted February 2, 2015 you can search for windows by text instead of title.. Do sleep(90) until WinExists("","has stopped working") If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2015 Share Posted February 2, 2015 (edited) you can search for windows by text instead of title.. Do sleep(90) until WinExists("","has stopped working") Thanks but it does not work for me. (I have Windows 7 64bit) But I know what your idea. I thought about it.I prefer to avoid from writing a function that checks all of the opened windows.. I'm not sure that this is the best method EDIT: I think this is the right direction for my purpose:https://www.autoitscript.com/autoit3/docs/libfunctions/_EventLog__Read.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_EventLog__Notify.htm I will continue research this ..Thanks anyway Edited February 2, 2015 by Guest Link to comment Share on other sites More sharing options...
alienclone Posted February 2, 2015 Share Posted February 2, 2015 another suggestion that isnt AutoIt related, i use a free program called Pulseway (formerly called PC Monitor) installed on my pc and i can tell it watch certain programs and it will alert me on my cell phone through the mobile app (also free) if that program stops responding. comes in very handy. If @error Then MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!") EndIf "Yeah yeah yeah patience, how long will that take?" -Ed Gruberman REAL search results | SciTE4AutoIt3 Editor Full Version Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2015 Share Posted February 2, 2015 Thanks but I need the functionality for "custom-made" something and I can get it from the Internet. Someone need to build it first. And here came autoit for this task Link to comment Share on other sites More sharing options...
Spider001 Posted February 2, 2015 Share Posted February 2, 2015 (edited) Do you have c# expirence ? It's easy from there Process[] procs; procs = Process.GetProcessesByName(appName); bool restartRequired = false; foreach (Process proc in procs) { if (!proc.Responding) { restartRequired = true; proc.Kill(); break; } } if (restartRequired) { Process procRun = new Process(); procRun.StartInfo.FileName = @"C:\Program Files\Winword.exe" procRun.Start(); } Edited February 2, 2015 by Spider001 Link to comment Share on other sites More sharing options...
JohnOne Posted February 2, 2015 Share Posted February 2, 2015 There's an API named something similar to IsHungAppWindow which may be of use to you. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2015 Share Posted February 2, 2015 (edited) Do you have c# expirence ? It's easy from there Process[] procs; procs = Process.GetProcessesByName(appName); bool restartRequired = false; foreach (Process proc in procs) { if (!proc.Responding) { restartRequired = true; proc.Kill(); break; } } if (restartRequired) { Process procRun = new Process(); procRun.StartInfo.FileName = @"C:\Program Files\Winword.exe" procRun.Start(); } 1) The appName can be the exe name or pid? My code knows what is the exe name or pid so it will better to use a variable that already exists to know if the process crashed. 2) !proc.Responding really means that the app crashed and not just not responding? I need it to be True only when the error "has stopped working" occurred. Maybe this is a more efficient way then using _EventLog functions Edited February 2, 2015 by Guest Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2015 Share Posted February 2, 2015 (edited) I just started to write this code.I built this base to move forward from here. It's objective is to detect an error from event log in realtime in background expandcollapse popup#include <EventLog.au3> #AutoIt3Wrapper_Run_AU3Check=n HotKeySet('{ESC}','Exit1') Func Exit1() Exit EndFunc ; Proses name/pid - Global varibale AppCrashEventDetector_StartStop(1) ; Start the AppCrashEventDetector function... While 1 Sleep(1000) ; Other Code WEnd AppCrashEventDetector_StartStop(0) ; Stop the AppCrashEventDetector function... ; $NError Parameter is for internal use only Func AppCrashEventDetector_StartStop($StartUp,$NError = 0) Local Static $Error If $NError Then $Error = $NError If $Error And $StartUp >= 0 Then Return If $StartUp = 1 Then If Not AdlibRegister('AppCrashEventDetector',5000) Then $Error = 1 Else AdlibUnRegister('AppCrashEventDetector') EndIf EndFunc ; You should never call this function directly! Look at everything except what inside "If $nEventRNumber <> $aEvent[1] Then" as internal use. Func AppCrashEventDetector() Local $hEventLog = _EventLog__Open('', 'Application') If $hEventLog = 0 Then AppCrashEventDetector_StartStop(-1,2) Return EndIf Local $aEvent = _EventLog__Read($hEventLog, True, False) ; read last event If Not $aEvent[0] Then AppCrashEventDetector_StartStop(-1,3) Return EndIf Local Static $nEventRNumber = $aEvent[1] If $nEventRNumber <> $aEvent[1] Then ; When new Error will be detected in the event log, It will prit the error here ConsoleWrite("Result ............: " & $aEvent[0]&@CRLF) ConsoleWrite("Record number .....: " & $aEvent[1]) ConsoleWrite("Submitted .........: " & $aEvent[2] & " " & $aEvent[3]&@CRLF) ConsoleWrite("Generated .........: " & $aEvent[4] & " " & $aEvent[5]&@CRLF) ConsoleWrite("Event ID ..........: " & $aEvent[6]&@CRLF) ConsoleWrite("Type ..............: " & $aEvent[8]&@CRLF) ConsoleWrite("Category ..........: " & $aEvent[9]&@CRLF) ConsoleWrite("Source ............: " & $aEvent[10]&@CRLF) ConsoleWrite("Computer ..........: " & $aEvent[11]&@CRLF) ConsoleWrite("Username ..........: " & $aEvent[12]&@CRLF) ConsoleWrite("Description .......: " &@CRLF&$aEvent[13]&@CRLF) ConsoleWrite(@CRLF & @CRLF & @CRLF) $nEventRNumber = $aEvent[1] EndIf _EventLog__Close($hEventLog) EndFunc Maybe this code snippet is useful to someone. From here it's not a problem to do what I need .. (I just need to write the needed code in If $nEventRNumber <> $aEvent[1] Then) The name of the function is incorrect because this is not finished function. The name should be NewEventDetector() EDIT: I added some important comments in the code Edited February 2, 2015 by Guest Link to comment Share on other sites More sharing options...
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