Refresh Windows Explorer (WinXP)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Zvonko
Posts: 210
Joined: 19 Jun 2015, 11:52

Refresh Windows Explorer (WinXP)

27 Mar 2016, 12:20

It is not difficult to find hints how to refresh Windows Explorer programmatically (e.g. to activate changes made in Registry):
Send {F5},
PostMessage, 0x111 ...

However, these methods seems to fail in Windows XP: After changing the sincleclick/doubleclick setting ('Single-click to open item' ...) via Registry, F5 can be used in Win8.1 and Win10, but not in Win XP; here the change becomes effective only via Refresh from context menu.

So this is my question:
I know that InvokeVerb can be used to invoke a verb from context menu, or simply sending keystrokes to open context menu and select Refresh. However, I need a solution which is independent of the Windows language. (Also I am not sure that Refresh is the fourth item in the context menu in all Windows languages.)
So I would like to invoke directly, not via context menu, the same action which is done via Refresh.

Any idea?

Code: Select all

;Not working in WinXP:        
ControlSend, %ExplControl%, {F5}, ahk_id %curId%
PostMessage, 0x111, 41504,, %ExplControl%, ahk_id %curId%
PostMessage, 0x111, 28931,, %ExplControl%, ahk_id %curId%   ; ahk_class CabinetWClass
DllCall( "Shell32\SHChangeNotify", UInt,0x08000000, UInt,0, Int,0, Int,0 ) ; SHCNE_ASSOCCHANGED
PostMessage, 0x1A,,, %ExplControl%, ahk_id %curId% ; ahk_class Progman
Run RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
SendMessage, 0x1A,0, 10000,SysListView321, ahk_id %curId% ;ahk_class %ExplClass%
SendMessage, 0x0B, 0, 1,SysListView321, ahk_id %curId% ;ahk_class %ExplClass%
For me as a newbie it is frustrating to fail due to "little" problems in projects in which the entire concept and even complex functions are working perfectly...
qwerty12
Posts: 468
Joined: 04 Mar 2016, 04:33
Contact:

Re: Refresh Windows Explorer (WinXP)

27 Mar 2016, 18:38

I know you already said you tried SHChangeNotify, but it does actually work here for me at least to toggle between single and double-click with an instant refresh of all Explorer windows (including the Desktop) on an XP Pro virtual machine:

Code: Select all

VarSetCapacity(SHELLSTATE, 32, 0)
DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", 0x00000080, "Int", false) ;SSF_DOUBLECLICKINWEBVIEW
;NumPut(32 * !(NumGet(SHELLSTATE) >> 5), &SHELLSTATE,, "Int") ; Warning: Something tells me this isn't the proper way to do this...
NumPut(NumGet(SHELLSTATE) ^ (1 << 5), SHELLSTATE,, "Int")
DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", 0x00000080, "Int", true) ; SSF_DOUBLECLICKINWEBVIEW
DllCall("Shell32\SHChangeNotify", "Int", 0x8000000, "UInt", 0, "Ptr", 0, "Ptr", 0) ; SHCNE_ASSOCCHANGED
Last edited by qwerty12 on 12 Apr 2016, 09:53, edited 2 times in total.
Zvonko
Posts: 210
Joined: 19 Jun 2015, 11:52

Re: Refresh Windows Explorer (WinXP)

28 Mar 2016, 08:17

Thank you very much, querty12!!!

Your answer does not answer my explicite question (to which I would still like to have an answer), but it solves my specific problem:
I used another method to change the SC/DC setting. With your method there is no problem with refresh, so I will use this method.

PS:
Your NumPut line switches the setting (from SC to DC Mode or from DC to SC Mode).
To force the DC Mode, NumPut(32, &SHELLSTATE,, "Int") can be used,
to force the SC Mode, NumPut(0, &SHELLSTATE,, "Int") can be used.
For me as a newbie it is frustrating to fail due to "little" problems in projects in which the entire concept and even complex functions are working perfectly...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 310 guests