Jump to content
Sign in to follow this  
ArifDigitalLab

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

Recommended Posts

ArifDigitalLab

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!

Share this post


Link to post
Share on other sites
sandin

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

Share this post


Link to post
Share on other sites
ArifDigitalLab

@ sandin

thanx a ton for the great support help and reply !

but it is giving error

While

While^ERROR

Error: Error in expression.

---------

i could not understand how to solve this problem.

will u please tell me what to do now ?

Thanx again.

Share this post


Link to post
Share on other sites
BrettF
sandin
ArifDigitalLab

but i still could not understand ....

can you please give a example ( i am newbie in this situation )

thanx !

Share this post


Link to post
Share on other sites
sandin
ArifDigitalLab

thanks bro , it is working fine and compiled exe is also giving no error but when i checks its syntrex it gives some errors .

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  

×