Jump to content
Sign in to follow this  
d3mon

Fatal error => Continue anyway...

Recommended Posts

d3mon

Hello I've made good script (PMD) I will put it on exemples script next time but I have problem with array error

I can't fix it because it change always, sometimes error sometimes not :P...

So if anyfunction can be created for script continue without error i will be happy...I know that doesnt exist I've look for help and I see that topic :

http://www.autoitscript.com/forum/index.ph...hl=Silent+error

For the same problem as me...If anyone can help me...


No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

Share this post


Link to post
Share on other sites
d3mon

Why nobody wants to read this topic ? :P


No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

Share this post


Link to post
Share on other sites
Andreik

Why nobody wants to read this topic ? :P

Post your code and then we can help you, otherwise we can't help you very much.

Verify if your variable is array IsArray() and your array dimension.

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
d3mon

Post your code and then we can help you, otherwise we can't help you very much.

Verify if your variable is array IsArray() and your array dimension.

Okay this is my code Array change bacause its for process memory list :

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=170_shell32.ico
#AutoIt3Wrapper_outfile=PMD.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=Process Memory Down (Memory Recovery)
#AutoIt3Wrapper_Res_Description=d3mon Corporation
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=d3mon Corporation
#AutoIt3Wrapper_AU3Check_Parameters=-q
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/cs1 /cn1 /cv1
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Misc.au3>
#include <Constants.au3>
#include <GuiConstants.au3>
Opt("RunErrorsFatal",0)

FileInstall("av-1277.jpg",@TempDir&"\av-1277.jpg")

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
Opt("GuiOnEventMode", 1)

TrayCreateItem("Wnd")
TrayItemSetOnEvent(-1,"_Wnd")

$TMFreeZ=TrayCreateMenu("FreeZ")

$TM1FreeZ=TrayCreateMenu("FreeZ M",$TMFreeZ)
$TM2FreeZ=TrayCreateMenu("FreeZ A",$TMFreeZ)

$TFreeZ=TrayCreateItem("FreeZ",$TM1FreeZ)
TrayItemSetOnEvent(-1,"_FreeZ")

$TUnFreeZ=TrayCreateItem("UnFreeZ",$TM1FreeZ)
TrayItemSetOnEvent(-1,"_UnFreeZ")
TrayItemSetState($TUnFreeZ,$TRAY_UNCHECKED)

$TFreeZ1=TrayCreateItem("FreeZ",$TM2FreeZ)
TrayItemSetOnEvent(-1,"_FreeZ1")

$TUnFreeZ1=TrayCreateItem("UnFreeZ",$TM2FreeZ)
TrayItemSetOnEvent(-1,"_UnFreeZ")
TrayItemSetState($TUnFreeZ1,$TRAY_UNCHECKED)

TrayCreateItem("")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"_Exit")

TraySetToolTip("PMD <d3mon Tools>"&@CRLF&"Initializing...")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"_Wnd")
TraySetState()

;Wnd-------------------------------------------------------------------------------------------------------------------------------
$win=GUICreate("Process Memory Down  <d3mon Tools>",495,275,-1,-1,$WS_CAPTION,BitOr($WS_EX_APPWINDOW,$WS_EX_TOOLWINDOW))
;TAB 1---------------------------------------------------------------------------------------
GUICtrlCreateTab(5,2,180,185)
GUICtrlCreateTabItem("Manual")
GUICtrlCreatePic(@TempDir&"\av-1277.jpg",25,37,0,0)
GUICtrlSetState(-1,$GUI_DISABLE)

GUICtrlCreateLabel("Add Process :",10,25)
$Z=GUICtrlCreateEdit("",10,40,150,17,$ES_AUTOHSCROLL)
GUICtrlSetTip(-1,"Process to FreeZ")
GUICtrlCreateButton("Add process",12,60,85,20)
GUICtrlSetOnEvent(-1,"_Add")
GUICtrlCreateButton("CLEAR",100,60,50,20)
GUICtrlSetOnEvent(-1,"_CLEAR")
GUICtrlCreateLabel("List :",10,85,30,17)
$list=GUICtrlCreateEdit("",36,82,145,17,$ES_READONLY+$ES_AUTOHSCROLL)
GUICtrlSetTip(-1,"Procez List to FreeZ")
GUICtrlSetData($list,FileRead(@TempDir&"\list.txt"))

GUICtrlCreateLabel("Freez Timer :",10,110)
$FreeZ=GUICtrlCreateEdit("",80,108,50,17,$ES_NUMBER)
GUICtrlSetTip(-1,"Time between process are FreeZ")
$FreeZL=GUICtrlCreateLabel("",135,110,50,17)
GUICtrlSetData($FreeZL,FileRead(@TempDir&"\FreeZTiMeR.txt"))

GUICtrlCreateButton("Add Timer",12,130,85,20)
GUICtrlSetOnEvent(-1,"_AddTimer")
GUICtrlCreateButton("CLEAR",100,130,50,20)
GUICtrlSetOnEvent(-1,"_CLEARTimer")

$BFreeZ=GUICtrlCreateButton("FreeZ !",122,160,60,20)
GUICtrlSetOnEvent(-1,"_BFreeZ")
GUICtrlSetTip(-2,"FreeZ/UnFreeZ procez list")

GUICtrlCreateButton("CLOSE",10,160,50,20)
GUICtrlSetOnEvent(-1,"_CLOSE")
GUICtrlCreateButton("EXIT",67,160,50,20)
GUICtrlSetOnEvent(-1,"_EXIT")

;TAB 2----------------------------------------------------------------------------------------
GUICtrlCreateTab(50,2,180,185)
GUICtrlCreateTabItem("Auto")
GUICtrlCreatePic(@TempDir&"\av-1277.jpg",25,37,0,0)
GUICtrlSetState(-1,$GUI_DISABLE)

$rlist=GUICtrlCreateButton("Refresh List",15,65,160,22)
GUICtrlSetOnEvent(-1,"_ZS")
GUICtrlSetTip(-2,"Refresh process List with their Memory")

GUICtrlCreateLabel("----------------------------------------------------------",7,95)
GUICtrlCreateLabel("Freez Timer :",10,110)
$FreeZ1=GUICtrlCreateEdit("",80,108,50,17,$ES_NUMBER)
GUICtrlSetTip(-1,"Time between process are FreeZ")
$FreeZL1=GUICtrlCreateLabel("",135,110,50,17)
GUICtrlSetData($FreeZL1,FileRead(@TempDir&"\FreeZTiMeR.txt"))

GUICtrlCreateButton("Add Timer",12,130,85,20)
GUICtrlSetOnEvent(-1,"_AddTimer")
GUICtrlCreateButton("CLEAR",100,130,50,20)
GUICtrlSetOnEvent(-1,"_CLEARTimer")

$BFreeZ1=GUICtrlCreateButton("FreeZ !",122,160,60,20)
GUICtrlSetOnEvent(-1,"_BFreeZ1")
GUICtrlSetTip(-2,"FreeZ/UnFreeZ all process")

GUICtrlCreateButton("CLOSE",10,160,50,20)
GUICtrlSetOnEvent(-1,"_CLOSE")
GUICtrlCreateButton("EXIT",67,160,50,20)
GUICtrlSetOnEvent(-1,"_EXIT")

;TAB 3-------------------------------------------------------------------------------------------
GUICtrlCreateTab(100,2,180,185)
GUICtrlCreateTabItem("Config")
GUICtrlCreatePic(@TempDir&"\av-1277.jpg",25,37,0,0)
GUICtrlSetState(-1,$GUI_DISABLE)

$ck_1=GUICtrlCreateCheckbox("",20,35,15,15)
GUICtrlCreateLabel("Fresh Manual at start-up",35,35,200)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-2,10)
GUICtrlSetTip(-3,"When the Script is lauched automatly FreeZ process list")

$ck_2=GUICtrlCreateCheckbox("",20,55,15,15)
GUICtrlCreateLabel("Fresh Auto at start-up",35,55,200)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-2,10)
GUICtrlSetTip(-3,"When the Script is launched automatly FreeZ all process")

GUICtrlCreateButton("Save",45,75,100,20)
GUICtrlSetOnEvent(-1,"_Savecfg")

If FileRead(@TempDir&"\PMDSave.txt")="1" Then
GUICtrlSetState($ck_1,$GUI_CHECKED)
_FreeZ()
ElseIf FileRead(@TempDir&"\PMDSave.txt")="2" Then
GUICtrlSetState($ck_2,$GUI_CHECKED)
_FreeZ1()
ElseIf FileRead(@TempDir&"\PMDSave.txt")="3" Then
GUICtrlSetState($ck_1,$GUI_CHECKED)
GUICtrlSetState($ck_2,$GUI_CHECKED)
_FreeZ()
_FreeZ1()
EndIf

GUICtrlCreateLabel("----------------------------------------------------------",7,95)


GUICtrlCreateButton("CLOSE",10,160,50,20)
GUICtrlSetOnEvent(-1,"_CLOSE")
GUICtrlCreateButton("EXIT",67,160,50,20)
GUICtrlSetOnEvent(-1,"_EXIT")
GUICtrlCreateButton("FreeZ !",122,160,60,20)
GUICtrlSetState(-1,$GUI_DISABLE)

;TAB 4--------------------------------------------------------------------------------------------
GUICtrlCreateTab(150,2,180,185)
GUICtrlCreateTabItem("Alert")
GUICtrlCreatePic(@TempDir&"\av-1277.jpg",25,37,0,0)
GUICtrlSetState(-1,$GUI_DISABLE)

$ck_3=GUICtrlCreateCheckbox("",20,35,15,15)
GUICtrlCreateLabel("Alert Memory",35,35,200)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-2,10)
GUICtrlSetTip(-3,"Alert if memory is highter than "&FileRead(@TempDir&"\AlertMEM.txt")&"%")

$ck_4=GUICtrlCreateCheckbox("",20,55,15,15)
GUICtrlCreateLabel("Alert Process",35,55,200)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-2,10)
GUICtrlSetTip(-3,"Alert if process is highter than "&FileRead(@TempDir&"\AlertUC.txt")&"%")

GUICtrlCreateLabel("Alert Memory :",20,75,100)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-2,10)
$AMEM=GUICtrlCreateEdit("",115,77,20,17,$ES_NUMBER)
GUICtrlSetTip(-1,"Percent limit of Alert Memory")
GUICtrlCreateLabel("%",155,78)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$AlertMEM=GUICtrlCreateLabel("",140,78,20)
GUICtrlSetData($AlertMEM,FileRead(@TempDir&"\AlertMEM.txt"))

GUICtrlCreateLabel("Alert Process :",20,98,100)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-2,10)
$AUC=GUICtrlCreateEdit("",115,97,20,17,$ES_NUMBER)
GUICtrlSetTip(-1,"Percent limit of Alert Process")
GUICtrlCreateLabel("%",155,100)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$AlertUC=GUICtrlCreateLabel("",140,100,20)
GUICtrlSetData($AlertUC,FileRead(@TempDir&"\AlertUC.txt"))

GUICtrlCreateButton("Save",45,130,100,20)
GUICtrlSetOnEvent(-1,"_SaveAlert")

If FileRead(@TempDir&"\PMDSave.txt")="1" Then
GUICtrlSetState($ck_3,$GUI_CHECKED)
Global $Alert=1
ElseIf FileRead(@TempDir&"\PMDSave.txt")="2" Then
GUICtrlSetState($ck_4,$GUI_CHECKED)
Global $Alert=2
ElseIf FileRead(@TempDir&"\PMDSave.txt")="3" Then
GUICtrlSetState($ck_3,$GUI_CHECKED)
GUICtrlSetState($ck_4,$GUI_CHECKED)
Global $Alert=3
EndIf

GUICtrlCreateButton("CLOSE",10,160,50,20)
GUICtrlSetOnEvent(-1,"_CLOSE")
GUICtrlCreateButton("EXIT",67,160,50,20)
GUICtrlSetOnEvent(-1,"_EXIT")
GUICtrlCreateButton("FreeZ !",122,160,60,20)
GUICtrlSetState(-1,$GUI_DISABLE)

GUISetState(@SW_HIDE,$win)

;List & progress-------------------------------------------------------------------------------
$ZLISTWIEW=GUICtrlCreateListView(" List                                | Memory [Ko]   | UC",190,10,300,175)
GUICtrlSetTip(-1,"Process List with their Memory")

$Progress_1=CreateProgress(8,190,480,20)
$Progress_2=CreateProgress(8,220,480,20)
$Progress_3=CreateProgress(8,250,480,20)
$nb=500
_ZS()

;Wnd-------------------------------------------------------------------------------------------------------------------------------

;While-----------------------------------------------------------------------------------------------------------------------------
While 1
$nb=$nb+10
If $nb>500 Then
$memory=MemGetStats()
UpdateProgress($Progress_1, Round(100*($memory[1]-$memory[2])/$memory[1], 1), "Physical RAM: ")
UpdateProgress($Progress_2, Round(100*($memory[3]-$memory[4])/$memory[3], 1), "Pagefile size: ")
UpdateProgress($Progress_3, Round(100*($memory[5]-$memory[6])/$memory[5], 1), "Virtual RAM size: ")
$nb=0
EndIf

If GUICtrlRead($BFreeZ)="UnFreeZ !" Then
;FreeZ List-----------------------------------------------------------------------
Global $Rlist = FileRead(@TempDir&"\list.txt")
Global $proceZlist = StringSplit($Rlist, "|")
Global $RFreeZ=FileRead(@TempDir&"\FreeZTiMeR.txt")

For $i = 1 To UBound($proceZlist)-1
$pid = ProcessExists($proceZlist[$i])
If $pid Then _ReduceMemory($pid)
Next
_MemoryOptimize()
_ReduceMemory()
;FreeZ List-----------------------------------------------------------------------
Global $Tray="PMD <d3mon Tools>"&@CRLF&"Manual : FreeZ"
Else
Global $Tray="PMD <d3mon Tools>"&@CRLF&"Manual : UnFreeZ"
EndIf

If GUICtrlRead($BFreeZ1)="UnFreeZ !" Then
;FreeZ All------------------------------------------------------------------------
Global $RFreeZ1=FileRead(@TempDir&"\FreeZTiMeR1.txt")

$ZS=ProcessList()
For $i = 1 to $ZS[0][0]
$pid = ProcessExists($ZS[$i][0])
If $pid Then _ReduceMemory($pid)

If $Alert=3 or $Alert=2 Then
$avRET = _ProcessListProperties($ZS[$i][1])
If $avRET[1][6]>=GuiCtrlRead($AlertUC) Then
If $ZS[$i][0]<>"[System Process]" Then
Global $ZAlert=$ZS[$i][0]
TraySetState(4)
TrayTip("PMD Alert Process",$ZS[$i][0]&" take +"&GUICtrlRead($AlertUC)&"% of process !"&@CRLF&"Double right click on icon to FreeZ it !",3,2)
TraySetOnEvent($TRAY_EVENT_SECONDARYDOUBLE,"_FreeZAlert")
TraySetState(8)
EndIf
EndIf
EndIf
Next
_MemoryOptimize()
_ReduceMemory()
Sleep($RFreeZ1)
;FreeZ All------------------------------------------------------------------------
TraySetToolTip($Tray&@CRLF&"Auto : FreeZ")
Else
TraySetToolTip($Tray&@CRLF&"Auto : UnFreeZ")
EndIf
TraySetState()

$RFreeZ=FileRead(@TempDir&"\FreeZTiMeR.txt")
Sleep($RFreeZ)
WEnd
;While-----------------------------------------------------------------------------------------------------------------------------

;Functions-------------------------------------------------------------------------------------------------------------------------
Func _Wnd()
GUISetState(@SW_SHOW,$win)
EndFunc;==> _Wnd

Func _Add()
If FileRead(@TempDir&"\list.txt")="" Then
FileWrite(@TempDir&"\list.txt",GUICtrlRead($Z))
Else
FileWrite(@TempDir&"\list.txt","|"&GUICtrlRead($Z))
EndIf
FileClose(@TempDir&"\list.txt")
GUICtrlSetData($list,FileRead(@TempDir&"\list.txt"))
EndFunc ;==> _Add

Func _ZS()
$ZS=ProcessList()
GUICtrlDelete($ZLISTWIEW)
GUICtrlSetState($rlist,$GUI_DISABLE)
$ZLISTWIEW=GUICtrlCreateListView(" List                                | Memory [Ko]   | UC",190,10,300,175)
For $i = 1 to $ZS[0][0]
$avRET = _ProcessListProperties($ZS[$i][1])
$ZVIEW=GUICtrlCreateListViewItem($ZS[$i][0]&"|"&$avRET[1][7]*0.001&"|"&$avRET[1][6],$ZLISTWIEW)
$String=StringLeft($i/$ZS[0][0]*10^2,4)
GUICtrlSetData($rlist,"Refreshing list "&$String&"%")
;~ $ZMENU=GuiCtrlCreateContextMenu($ZVIEW)
;~ GuiCtrlCreateMenuItem("Kill "&$ZS[$i][0],$ZMENU)
;~ GUICtrlSetOnEvent(-1,"_Kill")
Next
GUICtrlSetState($rlist,$GUI_ENABLE)
GUICtrlSetData($rlist,"Refresh list")
EndFunc ;==> _ZS

;~ Func _Kill()
;~ ProcessClose($ZS[$i][0])
;~ _ZS()
;~ EndFunc ;==> _Kill

Func _CLEAR()
FileDelete(@TempDir&"\list.txt")
GUICtrlSetData($list,"")
EndFunc ;==> _CLEAR

Func _AddTimer()
FileDelete(@TempDir&"\FreeZTiMeR.txt")
FileWrite(@TempDir&"\FreeZTiMeR.txt",GUICtrlRead($FreeZ))
GUICtrlSetData($FreeZL,FileRead(@TempDir&"\FreeZTiMeR.txt"))
GUICtrlSetData($FreeZL1,FileRead(@TempDir&"\FreeZTiMeR.txt"))
EndFunc ;==> _AddTiMeR

Func _CLEARTimer()
FileDelete(@TempDir&"\FreeZTiMeR.txt")
GUICtrlSetData($FreeZL,"")
GUICtrlSetData($FreeZL1,"")
EndFunc ;==> _CLEARTiMeR

Func _CLOSE()
GUISetState(@SW_HIDE,$win)
EndFunc ;==> _CLOSE

Func _Savecfg()
FileDelete(@TempDir&"\PMDSave.txt")
If (GUICtrlRead ($ck_1) == $GUI_CHECKED) and (GUICtrlRead ($ck_2) == $GUI_CHECKED) Then
FileWrite(@TempDir&"\PMDSave.txt","3")
Else
If (GUICtrlRead ($ck_1) == $GUI_CHECKED) Then
FileWrite(@TempDir&"\PMDSave.txt","1")
ElseIf (GUICtrlRead ($ck_2) == $GUI_CHECKED) Then
FileWrite(@TempDir&"\PMDSave.txt","2")
EndIf
EndIf
EndFunc ;==>_Savecfg

Func _SaveAlert()
FileDelete(@TempDir&"\PMDSaveAlert.txt")
If (GUICtrlRead ($ck_3) == $GUI_CHECKED) and (GUICtrlRead ($ck_4) == $GUI_CHECKED) Then
FileWrite(@TempDir&"\PMDSaveAlert.txt","3")
Else
If (GUICtrlRead ($ck_3) == $GUI_CHECKED) Then
FileWrite(@TempDir&"\PMDSaveAlert.txt","1")
ElseIf (GUICtrlRead ($ck_4) == $GUI_CHECKED) Then
FileWrite(@TempDir&"\PMDSaveAlert.txt","2")
EndIf
EndIf

FileDelete(@TempDir&"\AlertMEM.txt")
FileWrite(@TempDir&"\AlertMEM.txt",GUICtrlRead($AMEM))
GUICtrlSetData($AlertMEM,GUICtrlRead($AMEM))
FileDelete(@TempDir&"\AlertUC.txt")
FileWrite(@TempDir&"\AlertUC.txt",GUICtrlRead($AUC))
GUICtrlSetData($AlertUC,GUICtrlRead($AUC))
EndFunc ;==>_SaveAlert

Func _Exit()
FileDelete(@TempDir&"\av-1277.jpg")
Exit
EndFunc ;==>_Exit

;FreeZ----------------------------------------------------------------
Func _FreeZAlert()
 _ReduceMemory($ZAlert)
TrayTip("PMD Alert","Process "&$ZAlert&" has been FreeZ !",3)
TraySetState()
EndFunc

Func _BFreeZ()
If GUICtrlRead($BFreeZ)="FreeZ !" Then
_FreeZ()
ElseIf GUICtrlRead($BFreeZ)="UnFreeZ !" Then
_UnFreeZ()
EndIf
EndFunc ;==> _BFreeZ

Func _FreeZ()
TrayItemSetState($TFreeZ,$TRAY_CHECKED)
TrayItemSetState($TUnFreeZ,$TRAY_UNCHECKED)
GUICtrlSetData($BFreeZ,"UnFreeZ !")
EndFunc ;==> _FreeZ

Func _FreeZ1()
TrayItemSetState($TFreeZ1,$TRAY_CHECKED)
TrayItemSetState($TUnFreeZ1,$TRAY_UNCHECKED)
GUICtrlSetData($BFreeZ1,"UnFreeZ !")
EndFunc ;==> _FreeZ1
;FreeZ-----------------------------------------------------------------


;FreeZ1----------------------------------------------------------------
Func _BFreeZ1()
If GUICtrlRead($BFreeZ1)="FreeZ !" Then
_FreeZ1()
ElseIf GUICtrlRead($BFreeZ1)="UnFreeZ !" Then
_UnFreeZ1()
EndIf
EndFunc ;==> _BFreeZ1

Func _UnFreeZ()
TrayItemSetState($TFreeZ,$TRAY_UNCHECKED)
TrayItemSetState($TUnFreeZ,$TRAY_CHECKED)
GUICtrlSetData($BFreeZ,"FreeZ !")
EndFunc ;==> _UnFreeZ

Func _UnFreeZ1()
TrayItemSetState($TFreeZ1,$TRAY_UNCHECKED)
TrayItemSetState($TUnFreeZ1,$TRAY_CHECKED)
GUICtrlSetData($BFreeZ1,"FreeZ !")
EndFunc ;==> _UnFreeZ1
;FreeZ1----------------------------------------------------------------


;Memory----------------------------------------------------------------
Func _ReduceMemory($i_PID = -1)
If $i_PID <> -1 Then
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', $i_PID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Else
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf

Return $ai_Return[0]
EndFunc  ;==>_ReduceMemory

Func _MemoryOptimize()
$memory1 = MemGetStats()
    Do
        _ReduceMemory()
        $list = ProcessList()
        For $i=1 To $list[0][0]
            If StringInStr($list[$i][0], "csrss") > 0 Or StringInStr($list[$i][0], "smss") > 0 Or StringInStr($list[$i][0], "winlogon") > 0 Or StringInStr($list[$i][0], "lsass") > 0 Then ContinueLoop
            _ReduceMemory($list[$i][1])
        Next
        $memory2 = $memory1
        $memory1 = MemGetStats()
    Until $memory1[2]>=$memory2[2]
EndFunc  ;==>_MemoryOptimize

Func CreateProgress($x, $y, $w, $h, $Label="")
    Dim $Progress[2]
    $Progress[0] = GuiCtrlCreateProgress($x, $y, $w, $h)
    $Progress[1] = GuiCtrlCreateLabel($Label, $x, $y, $w, $h, $SS_CENTER )
    GUICtrlSetBkColor($Progress[1], $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont($Progress[1],12)
    Return $Progress
EndFunc  ;==> CreateProgress

Func UpdateProgress($ProgressID, $Percent, $Label="")
GUICtrlSetData($ProgressID[0], $Percent)
GUICtrlSetData($ProgressID[1], $Label & $Percent & "%")
If $Percent<25 Then
GUICtrlSetColor($ProgressID[0],0x33CC33)
GUICtrlSetColor($ProgressID[1],0x33CC33)
ElseIf $Percent>=25 Then
GUICtrlSetColor($ProgressID[0],0xFFAA00)
GUICtrlSetColor($ProgressID[1],0xFFAA00)
ElseIf $Percent>=50 Then
GUICtrlSetColor($ProgressID[0],0xFF6600)
GUICtrlSetColor($ProgressID[1],0xFF6600)
ElseIf $Percent>=75 Then
GUICtrlSetColor($ProgressID[0],0xFF0000)
GUICtrlSetColor($ProgressID[1],0xFF0000)
EndIf

If $Percent>=GUICtrlRead($AlertMEM) Then
If $Alert=3 or $Alert=1 Then
TraySetState(4)
TrayTip("PMD Alert Memory","Memory is highter than "&GUICtrlRead($AlertMEM)&"% !",3,2)
TraySetState(8)
EndIf
EndIf
EndFunc  ;==> UpdateProgress

Func _ProcessListProperties($Process = "", $sComputer = ".")
    Local $sUserName, $sMsg, $sUserDomain, $avProcs, $dtmDate
    Local $avProcs[1][2] = [[0, ""]], $n = 1

    If StringIsInt($Process) Then $Process = Int($Process)
    $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\cimv2")
    If IsObj($oWMI) Then
        If $Process = "" Then
            $colProcs = $oWMI.ExecQuery("select * from win32_process")
        ElseIf IsInt($Process) Then
            $colProcs = $oWMI.ExecQuery("select * from win32_process where ProcessId = " & $Process)
        Else
            $colProcs = $oWMI.ExecQuery("select * from win32_process where Name = '" & $Process & "'")
        EndIf
        
        If IsObj($colProcs) Then
            If $colProcs.count = 0 Then Return $avProcs
            ReDim $avProcs[$colProcs.count + 1][10]
            $avProcs[0][0] = UBound($avProcs) - 1

            For $oProc In $colProcs
                $avProcs[$n][0] = $oProc.name
                $avProcs[$n][1] = $oProc.ProcessId
                $avProcs[$n][2] = $oProc.ParentProcessId
                If $oProc.GetOwner($sUserName, $sUserDomain) = 0 Then $avProcs[$n][3] = $sUserDomain & "\" & $sUserName
                $avProcs[$n][4] = $oProc.Priority
                $avProcs[$n][5] = $oProc.ExecutablePath
                $dtmDate = $oProc.CreationDate
                If $dtmDate <> "" Then
                    Local $sRegExpPatt = "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)"
                    $dtmDate = StringRegExpReplace($dtmDate, $sRegExpPatt, "$2/$3/$1 $4:$5:$6")
                EndIf
                $avProcs[$n][8] = $dtmDate
                $avProcs[$n][9] = $oProc.CommandLine
                $n += 1
            Next
        Else
            SetError(2)
        EndIf
        $colProcs = 0

        Local $oRefresher = ObjCreate("WbemScripting.SWbemRefresher")
        $colProcs = $oRefresher.AddEnum($oWMI, "Win32_PerfFormattedData_PerfProc_Process" ).objectSet
        $oRefresher.Refresh

        Local $iTime = TimerInit()
        Do
            Sleep(20)
        Until TimerDiff($iTime) >= 100
        $oRefresher.Refresh
        For $oProc In $colProcs
            For $n = 1 To $avProcs[0][0]
                If $avProcs[$n][1] = $oProc.IDProcess Then
                    $avProcs[$n][6] = $oProc.PercentProcessorTime
                    $avProcs[$n][7] = $oProc.WorkingSet
                    ExitLoop
                EndIf
            Next
        Next
    Else
        SetError(1)
    EndIf
        Return $avProcs
EndFunc;==>_ProcessListProperties
;Memory----------------------------------------------------------------

;Functions-------------------------------------------------------------------------------------------------------------------------

No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

Share this post


Link to post
Share on other sites
d3mon

Any suggest ?


No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE

Share this post


Link to post
Share on other sites
zeevid

Any suggest ?

That is some script. What Function is failing? What is the name of the array that you are having the script error with?

Have you tried to check the UBound of the array and if you have more items then will fit into the current array redim the array to add more items?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×