kylomas Posted October 13, 2011 Share Posted October 13, 2011 Hi All, I am trying to detect program/process end to key another program/process/action of some kind. Consider this rudimentary code: HotKeySet("{ESC}", "fini") local $ie_exists = false while 1 if processexists("iexplore.exe") then $ie_exists = True if not processexists("iexplore.exe") and $ie_exists then $ie_exists = False shellexecute("c:\program files\ccleaner\ccleaner.exe ","/auto") EndIf sleep(100) wend func fini() Exit endfunc This only handles one instance of the program and it is possible to miss the program within the sleep wait. This is the genesis of an idea that I have for writing a system monitor (sort of like the WIN SCHD facility with expanded functionality). I would like to key events by time, duration, interval, program start and program stop. The kinds of events that I would like to key are start/stop a program, sound an audible alarm/text, enforce a whitelist/blacklist. Incidentally, I have searched for things like "system monitor", "program start", "program stop", etc without success. Thanks, Kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
pieeater Posted October 13, 2011 Share Posted October 13, 2011 whats wrong with this? While 1 If Not ProcessExists($process) Then function() EndIf Sleep(10) WEnd and if for your blacklist im pretty sure you could do this Dim $process[3] = ["process1", "process2", "process3"] While 1 For $i = 0 To UBound($process) - 1 If ProcessExists($process[$i]) Then ProcessClose($process[$i]) ConsoleWrite($i & @CRLF) EndIf Next Sleep(10) WEnd [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
kylomas Posted October 13, 2011 Author Share Posted October 13, 2011 pieeater, Thanks for your prompt reply...I see that my description was vague. In the case of my example code I only want to fire an action (run CCLEANER) when the internet explorer has been used. Following your code I would continuously fire this event, regardless of an instance of IE. However, the technique in my example code seems clumsy and data dependent...any and all ideas are good to spur further thought, Thanks, Kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
pieeater Posted October 13, 2011 Share Posted October 13, 2011 then this should work to execute only once every time the process is opened: HotKeySet("{ESC}", "fini") While 1 If ProcessExists("iexplore.exe") Then $exist = True Else $exist = False $repeat = True EndIf If $exist And $repeat Then $repeat = False ShellExecute("c:\program files\ccleaner\ccleaner.exe ","/auto") EndIf Sleep(10) WEnd Func fini() Exit EndFunc [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
kylomas Posted October 13, 2011 Author Share Posted October 13, 2011 (edited) pieeater, Thanks again for your prompt reply. Logically that is pretty much what I am doing. My issue is with multiple instances of a program and that the code is data dependent (specific data hardcoded in the program). I want to externalize the data (am working on a SQLite solution) and accomodate multiple ocurrences of the same prog/proc. Thanks, Kylomas EDIT: How do you get this f##$%@g code insert to keep your spacing and indentation???? Edited October 13, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted October 13, 2011 Share Posted October 13, 2011 ProcessExists() and ProcessWaitClose() should do it simply. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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