Jump to content

Refreshing The Explorer ........... setting time to be done


Recommended Posts

hi ,

i want to refresh the explorer to let the settings change effect.

but the problem is that i want to set time for it .

here is the code which i am using for refreshing the explorer .

_UpdateExplorer()

Func _UpdateExplorer()
    Local $aWinFViewExpListArr = _ExplFViewWinGetList()
    
    If IsArray($aWinFViewExpListArr) Then
        For $i = 1 To $aWinFViewExpListArr[0]
            WinActivate($aWinFViewExpListArr[$i])
            ControlSend($aWinFViewExpListArr[$i], "FolderView", "", "{F5}")
        Next
    EndIf
    
    Local $aWinExpListArr = _ExplWinGetList()
    Local $hDll = DllOpen("user32.dll")
    
    If $hDll = -1 Then
        MsgBox(16, "Error", "There was an error to refresh explorer." & @LF & _
        "This can caused by the memory full, and also you might want to check file user32.dll (in your system dir), " & @LF & _
        "it must exists for this operation." & @LF & @LF & _
        "You can refresh the explorer windows by pressing F5 key in each needed window," & @LF & _
        "or call the context menu of the folder (SHIFT F10), and click on 'Refresh' item." & @LF & _
        "OK   --->   EXIT")
        Exit
    EndIf
    
    If IsArray($aWinExpListArr) Then
        For $i = 1 To $aWinExpListArr[0]
            DllCall($hDll, "long", "SendMessage", "hwnd", $aWinExpListArr[$i], "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    
    DllClose($hDll)
EndFunc

but how can i set the time for it ?

for example if i want to refresh the explorer every 10 minutes.

thanks!

Link to comment
Share on other sites

this should work:

$time = 10 ;minutes
$timer = TimerInit()
Func _UpdateExplorer()
    Local $aWinFViewExpListArr = _ExplFViewWinGetList()    
    If IsArray($aWinFViewExpListArr) Then
        For $i = 1 To $aWinFViewExpListArr[0]
            WinActivate($aWinFViewExpListArr[$i])
            ControlSend($aWinFViewExpListArr[$i], "FolderView", "", "{F5}")
        Next
    EndIf
    Local $aWinExpListArr = _ExplWinGetList()
    Local $hDll = DllOpen("user32.dll")
    If $hDll = -1 Then
        MsgBox(16, "Error", "There was an error to refresh explorer." & @LF & _
        "This can caused by the memory full, and also you might want to check file user32.dll (in your system dir), " & @LF & _
        "it must exists for this operation." & @LF & @LF & _
        "You can refresh the explorer windows by pressing F5 key in each needed window," & @LF & _
        "or call the context menu of the folder (SHIFT F10), and click on 'Refresh' item." & @LF & _
        "OK   --->   EXIT")
        Exit
    EndIf
    If IsArray($aWinExpListArr) Then
        For $i = 1 To $aWinExpListArr[0]
            DllCall($hDll, "long", "SendMessage", "hwnd", $aWinExpListArr[$i], "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    DllClose($hDll)
EndFunc
While
    if TimerDiff($timer) >= $time*60000 Then
        _UpdateExplorer()
        $timer = TimerInit()
    EndIf
    Sleep(10)
WEnd
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...