Posts: 1,271
Threads: 399
Joined: Mar 2003
function: process_watcher
trigger: $p 0x7 ""
function event pid pidparent $name
;event: 1 started, 2 ended, 4 running
sel event
,case 1
,
,case 2
,
,case 3
how much can i do with that ?
how reliable/stable is it ?
--
can it auto kill process when IsHungWindow ?
can it end a process when ram usage is higher then n mb ?
Posts: 12,147
Threads: 143
Joined: Dec 2002
It is reliable and stable. On Vista does not work for some processes if QM is not as admin. But it is probably because ShutDownProcess does not have enough privileges, not because the trigger woul not work.
pid can be passed to ShutDownProcess.
I used that to kill that annoying Vista processes that start while I am working and eat computer resources.
Quote:can it auto kill process when IsHungWindow ?
can it end a process when ram usage is higher then n mb ?
No, unless then starts some process.
Posts: 1,271
Threads: 399
Joined: Mar 2003
process_watcher
function event pid pidparent $name
;event: 1 started, 2 ended, 4 running
str exe_name
sel event
,case 1
,,out pid
,,_s=PidToExename(pid exe_name 1)
,,out _s
,case 2
,
,case 3
i must be blind, why does _s not show the exe path ?
i get always 0.
Posts: 12,147
Threads: 143
Joined: Dec 2002
PidToExename does not return a string.
Posts: 1,271
Threads: 399
Joined: Mar 2003
how to make it return the exe name or path as string ?
that would allow me to use
sel pid2exe(pid) 1
case "firefox"
Posts: 12,147
Threads: 143
Joined: Dec 2002
function'str arguments
...
ret local str var
But it is dangerous. When you assign the function to a str variable, then OK. But if you assign it to a lpstr variable or function argument, the lpstr will be invalid. Same with sel.
Or can be
function'lpstr arguments
...
ret thread-local str variable
Then you can assign it to str, lpstr, sel, etc. The string becomes invalid when the thread exits or the function called again, but it is usually already not used then.
For these reasons it is better to use str& argument instead.
Posts: 1,271
Threads: 399
Joined: Mar 2003
i try and try ...
please show me how you would transform PidToExename to pid2exe,
so that it can be used for sel.
thanks
:oops: :oops: :oops:
Posts: 12,147
Threads: 143
Joined: Dec 2002
The best way - use str member function that returns lpstr of itself. Forgot that yesterday.
Member function str.PidToExename
;/
function$ pid [flags] ;;flags: 1 full
;Gets program name from process id.
;EXAMPLE
;int pid
;if(!GetWindowThreadProcessId(win("" "Shell_TrayWnd") &pid)) ret
;out _s.PidToExename(pid 1)
#if _winnt
int hp hm i
this.len=0
hp=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ 0 pid); if(!hp) ret
if(EnumProcessModules(hp &hm 4 &i))
,this.all(MAX_PATH)
,if(flags&1) this.fix(GetModuleFileNameEx(hp hm this MAX_PATH))
,else this.fix(GetModuleBaseName(hp hm this MAX_PATH)); if(this.endi(".exe")) this.fix(this.len-4)
CloseHandle(hp)
ret this
#endif