| Bernard DELPORTE 2005-09-12, 6:59 pm |
| Below you will find an object rexx program which is meant to close
"Application Error" boxes.
This program currently runs on Windows2k (currently Object Rexx 2.1.1 is
installed on this machine).
The problem I encounter is the following : the boxes can also appear when my
workstation is locked; in such a case the method PushButtonInWindow is not
working.
Thanks in advance for your help.
And if you have suggestions to do the same thing in a better way...
/**
* A small utility which closes the Windows "Application error" boxes
*/
cf=.stream~new('csrss.txt')
do forever
address cmd 'tlist csrss >csrss.txt'
call syssleep 5 -- wait before reading the file
l=cf~arrayin
cf~close
if CloseBoxes(l) then iterate -- redo it directly in case of
multiple occurrences
call syssleep 5*60 -- the checks runs every 5 minutes
end
return
CloseBoxes: procedure
/**
* If a box is there then close it
* @param l=list of entries of the task list
* @return 1=a box was closed (needs to test again). 0 no errors
*/
use arg l
if l~items=0 then return
parse value l[1] with pid'CSRSS.EXE'apn
if apn~strip=='' then return 0 -- No box to close.
wnmg=.WindowsManager~new
-- Try to place the focus on the OK button before using the PushButtonIn
Window method
wo=wnmg~find(apn~strip)
if wo\=.nil then -- when
PC is locked wo is nil
do
wpb=wo~findchild('OK')
wo~focusitem(wpb)
end
wnmg~PushButtonInWindow(apn~strip,'OK') -- this is
not working when PC is locked.
say '['Date('S')' 'time('N')'] Error window "'apn~strip'" closed.'
call syssleep 2
return 1
::requires 'WINSYSTM.CLS'
|