Refreshing the file explorer

Get help with using AutoHotkey and its commands and hotkeys
manosathya98
Posts: 4
Joined: 04 Jan 2016, 08:56

Refreshing the file explorer

04 Jan 2016, 10:08

I am using two scripts which toggle file extensions and hidden files in the file explorer, however the changes only come into effect when I refresh the screen.

Here are the scripts I am using:

Code: [Select all] [Download] GeSHi © Codebox Plus

<#h:: 
RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
If HiddenFiles_Status = 2
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
Else
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2
WinGetClass, eh_Class,A
If (eh_Class = "#32770" OR A_OSVersion = "WIN_VISTA")
send, {F5}
Else PostMessage, 0x111, 28931,,, A
Return


and:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Is there any way to get file explorer to automatically refresh, even whilst I am not on the screen (e.g. lets say I am on file explorer, toggle the files, and the screen automatically refreshes - but when I go on, say, google chrome, and toggle the hidden files, I don't want the chrome screen to refresh) - I think using send F5 would accomplish the first bit (refreshing whilst I am on the file explorer screen), but it would refresh chrome if I were on the google chrome screen.
Any help is appreciated!
User avatar
kczx3
Posts: 309
Joined: 06 Oct 2015, 21:39

Re: Refreshing the file explorer

04 Jan 2016, 11:31

This function may do the trick for ya.

Code: [Select all] [Download] GeSHi © Codebox Plus

refreshExplorer()
{
for wb in ComObjCreate("Shell.Application").Windows
{
if wb.Name = "Windows Explorer"
ControlSend, ToolbarWindow323, {F5}, % "ahk_id " wb.hwnd
}
Return
}
manosathya98
Posts: 4
Joined: 04 Jan 2016, 08:56

Re: Refreshing the file explorer

04 Jan 2016, 12:02

Thank you! It didn't work at first, so just changed windows explorer to file explorer and now it works brilliantly :)
manosathya98
Posts: 4
Joined: 04 Jan 2016, 08:56

Re: Refreshing the file explorer

04 Jan 2016, 12:13

One more thing actually, everything works as it is, but is it possible to do the above whilst file explorer is closed completely? (at the moment it only works when on the screen or minimised)
User avatar
kczx3
Posts: 309
Joined: 06 Oct 2015, 21:39

Re: Refreshing the file explorer

04 Jan 2016, 12:24

I guess I don't see why it would be necessary if explorer.exe isn't open as a window. I would think it should display correctly if you open it after using your hotkey to update the registry.
manosathya98
Posts: 4
Joined: 04 Jan 2016, 08:56

Re: Refreshing the file explorer

04 Jan 2016, 14:30

It doesn't work as it is if the file explorer is closed, but it's not really a necessity, just wanted to see if it could be done haha
shajeeh

Re: Refreshing the file explorer

11 Jan 2017, 23:06

I am also having the same problem of refreshing the explorer, i used the above combination on my windows 10 as
[;------------------------------------------------------------------------
; Show hidden folders and files in Windows XP
;------------------------------------------------------------------------
; User Key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
; Value Name: Hidden
; Data Type: REG_DWORD (DWORD Value)
; Value Data: (1 = show hidden, 2 = do not show)

#z::

RegRead, ShowHidden_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
if ShowHidden_Status = 2
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
Else
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2
WinGetClass, CabinetWClass
PostMessage, 0x111, 28931,,, A
refreshExplorer()
{
for wb in ComObjCreate("Shell.Application").Windows
{
if wb.Name = "Windows Explorer"
ControlSend, ToolbarWindow323, {F5}, % "ahk_id " wb.hwnd
}
}
Return
]
but is not refreshing and i have to refresh manually
i also tried writing "File Explorer" instead of "Windows Explorer" but that did not help as well
can someone please identify the mistake
Noesis
Posts: 54
Joined: 26 Apr 2014, 07:57

Re: Refreshing the file explorer

12 Jan 2017, 01:17

You're never actually calling the refreshExplorer() function you've only got it being defined. You need a line saying refreshExplorer() within the hotkey (there is an implied return between PostMessage and the current refreshExplorer() function definition). In other words, Function definitions aren't auto-executed.
User avatar
jeeswg
Posts: 222
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Refreshing the file explorer

12 Jan 2017, 02:12

I used this to toggle hide/show extensions on Windows XP:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

just me
Posts: 3697
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Refreshing the file explorer

12 Jan 2017, 06:20

You might want to try this (on your own risk). It doesn't need a refresh here:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Except as noted otherwise all of my code is tested on Win 10 Pro (x64) using the current AHK version.

Return to “Ask For Help”

Who is online

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