Jump to content

IE auto clean-up


 Share

Recommended Posts

Hi everyone!

I'm in need of some help. I programed this UDF that goes into an app I did for my company. It escentially cleans-up IE's 6 cache, cookies and history, which we need to do before changing proxy for a couple of reasons, but sometimes it freezes while doing one of those operations and sience I block the windows it opens so that users won't mess with them during the clean-up execution, they can't close it when it hangs up. Here's the code:

Func limpiaIE6()
    WinMinimizeAll()
; abre Propiedades de Internet
    ProgressOn("Cambio de proxy", "Espere mientras se cambia el proxy", "Iniciando...")
    Run('control inetcpl.cpl', "", @SW_SHOW)
ReduceMemory()
    WinWaitActive('Propiedades de Internet')
    $historyhandle = WinGetHandle("Propiedades de Internet")
    _WinAPI_EnableWindow($historyhandle, False)
    Sleep(250)
; Selecciona el tab "General"
    $hndl  = ControlGetHandle($historyhandle, "", "SysTabControl321")
    $gentab = _GUICtrlTab_FindTab($hndl, "General")
    _GUICtrlTab_ClickTab($hndl, $gentab, "left", False)
ReduceMemory()
; borra cookies
    ProgressSet(30, "Eliminando cookies")
    ControlClick($historyhandle, '', 'Button6')
    WinWaitActive('Eliminar cookies')
    Sleep(250)
    ControlClick(WinGetHandle('Eliminar cookies'), '', 'Button1')
ReduceMemory()
; borra temporales
    ProgressSet(50, "Eliminando archivos temporales")
    Sleep(250)
    ControlClick($historyhandle, '', 'Button7')
    WinWaitActive('Eliminar archivos')
    Sleep(250)
    ControlClick(WinGetHandle('Eliminar archivos'), '', 'Button1')
    Sleep(250)
    ControlClick(WinGetHandle('Eliminar archivos'), '', 'Button2')
ReduceMemory()
; borra historial
    ProgressSet(90, "Eliminando historial")
    Sleep(250)
    ControlClick($historyhandle, '', 'Button10')
    WinWaitActive('Opciones de Internet')
    Sleep(250)
    ControlClick(WinGetHandle('Opciones de Internet'), '', 'Button1')
ReduceMemory()
; cierra Propiedades de Internet
    ProgressSet(100, "Finalizando...")
    Sleep(250)
    _WinAPI_EnableWindow($historyhandle, True)
    WinKill($historyhandle)
    ProgressOff()
    WinMinimizeAllUndo()
EndFunc

I'm pretty sure the error is here because of some debugging, that's why I'm just posting the UDF. You may also notice I use another function, which I borrowed from this forum, ReduceMemory():

Func ReduceMemory()
    Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Return $ai_Return[0]
    Sleep(10)
EndFunc

Any help will be much appreciated. I apologize in advance for any misspelling or grammar errors, and for the UDF being in spanish (it's not translated sience what's not in English bears no importance, they are just titles), but bear in mind I'm a 19 year old Argentinian. :D

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...