SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

Post your working scripts, libraries and tools
User avatar
SKAN
Posts: 667
Joined: 29 Sep 2013, 16:58

SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

15 May 2020, 09:22

SHELLSTATE( [Check, Variadic parameters] )
SHELLSTATE() when called without any parameters will retrieve the global Shell settings.

The following is (a slightly incomplete) list of available settings that can be used with SHELLSTATE()
  • Code: Select all

    ; Flags
    ShowAllObjects       := 0x1
    ShowExtensions       := 0x2         ; HideFileExt
    NoConfirmRecycle     := 0x4
    ShowCompColor        := 0x10        ; ShowCompColor
    DoubleClickInWebView := 0x20
    DontPrettyPath       := 0x100       ; DontPrettyPath
    MapNetDrvBtn         := 0x400       ; MapNetDrvBtn
    ShowInfoTip          := 0x800       ; ShowInfoTip
    HideIcons            := 0x1000      ; HideIcons
    WebView              := 0x2000      ; WebView
    Filter               := 0x4000      ; Filter
    ShowSuperHidden      := 0x8000      ; ShowSuperHidden
    NoNetCrawling        := 0x10000
    AutoCheckSelect      := 0x800000    ; AutoCheckSelect
    
    ; Exflags
    SeparateProcess      := 0x100000    ; SeparateProcess
    StartPanelOn         := 0x200000
    IconsOnly            := 0x1000000   ; IconsOnly
    ShowTypeOverlay      := 0x2000000   ; ShowTypeOverlay
    ShowStatusBar        := 0x4000000   ; ShowStatusBar   (Win 8+)
    
    ; The names in comment are keys found in
    ; HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced
    
Before one can proceed with examples, take a back up of your current shell settings:
Save the results from MsgBox % Clipboard := SHELLSTATE() to a file.

Check a setting: for example: To test if ShowExtensions is enabled, call If SHELLSTATE(0x2)

Change a setting: Omit the Check parameter (or pass a false), and pass any number of variadic parameters as follows:
To enable a setting, prefix the constant value with "+=", for example: SHELLSTATE(0,"+=0x2") will enable ShowExtensions.
In same logic, SHELLSTATE(0,"-=0x2") will disable and SHELLSTATE(0,"^=0x2") will toggle ShowExtensions state.

You may prefix assignment operator ":=" to change entire setting in one go.
For example, if you have a backup with savedSHELLSTATE := SHELLSTATE() then call SHELLSTATE(0, ":=" . savedSHELLSTATE) to restore.
Don't try this: SHELLSTATE(0, ":=0") will disable all settings (except 0x8 which creeps back in) and
Don't try this: SHELLSTATE(0, ":=-1") will enable all settings (You may find your explorer acting strange).

  • To see a breakup of settings as individual values, you may call MsgBox % flags( SHELLSTATE() ). You can get flags() here.
  • Atleast in Win 7, a F5 is required for refreshing explorer windows. One may find RefreshExplorer() very refreshing in such a situation.
  • There are situations where F5 wouldn't work. For example: SHELLSTATE(0, "+=0x1000") will hide desktop icons but user will have to log-off-log-in to see the effect.
    I tried my best and there seems no way to refresh. You may instead use DesktopIcons() to Show/Hide
Low-level stuff


The function

Code: Select all

SHELLSTATE(C:=0, P*) {                   ; SHELLSTATE v0.9 by SKAN on D35B/D35D @ tiny.cc/shellstate
Local K,V,M,X,N:=VarSetCapacity(X,32,0), NP:=P.Count(), Get:=(not C and not NP), Set:=(not C and NP) 
  If Set and ( M:=SHELLSTATE() )
   For K,V in P 
       N:=StrSplit(V,"="," ",2), K := N[1], V:=Round(N[2])
     , M:=K="+" ? M|V : K="-" ? M&~V : K="^" ? M^V : K=":" ? V : M|V
  DllCall("Shell32\SHGetSetSettings","Ptr"
     , Set ? NumPut(M & 0xfffff,NumPut(M >> 20,X,28,"UInt")-32, "UInt")-4 : &X, "Int",-1, "Int",Set)
Return Set ? SHELLSTATE() : Format("0x{2:08X}", N:=NumGet(X,"UInt") | (NumGet(X,28,"UInt")*0x100000)
     , Get ? N : (N & C)=C ? N : 0)
}
User avatar
elModo7
Posts: 167
Joined: 01 Sep 2017, 02:38
GitHub: elModo7
Location: Spain
Contact:

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 04:36

Thank you for sharing, I was looking for this!
:beer:
robodesign
Posts: 660
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 06:39

In the latest windows 10....the status bar seem to always be hidden in explorer ..... Would this help force show it?

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
SKAN
Posts: 667
Joined: 29 Sep 2013, 16:58

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 07:07

@elModo7 :thumbup: :)
robodesign wrote: In the latest windows 10....the status bar seem to always be hidden in explorer ..... Would this help force show it?
Hi Marius,
Did a quick test. The following works fine for me in Win 10
 

Code: Select all

#IfWinActive ahk_class CabinetWClass
#Space:: SHELLSTATE(,"^=0x4000000") ; Toggle ShowStatusBar(0x4000000)
#IfWinActive
Let me know if it does not work for you and I will investigate.
:)
 
robodesign
Posts: 660
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 07:14

Thank you... But it doesn't work.... 😔... The status bar stays hidden nonetheless.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
SKAN
Posts: 667
Joined: 29 Sep 2013, 16:58

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 07:18

robodesign wrote:But it doesn't work.... 😔... The status bar stays hidden nonetheless.
Thanks for the feedback. I will check.
User avatar
SKAN
Posts: 667
Joined: 29 Sep 2013, 16:58

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 08:16

I earlier wrote:I will check.
 
@robodesign
Tested and my other (family) HTPC also seems okay.

According to this external topic Status bar seems to be available for one user but not the other on the same PC?.

If you try (or had already tried) this let me know:
How to fix Microsoft Windows status bar continues to be disabled
https://www.computerhope.com/issues/ch000584.htm
robodesign
Posts: 660
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 08:29

Thank you very much again, but... it still does not work, even after doing those steps...
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
SKAN
Posts: 667
Joined: 29 Sep 2013, 16:58

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 08:37

robodesign wrote:it still does not work, even after doing those steps...
If possible, create a new user account and check if Status bar is visible.
If still not visible, we may presume Microsoft did it. :(
robodesign
Posts: 660
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 09:30

SKAN wrote:
24 Jun 2020, 08:37
robodesign wrote:it still does not work, even after doing those steps...
If possible, create a new user account and check if Status bar is visible.
If still not visible, we may presume Microsoft did it. :(
Based on additional Google searches and forum posts.... Other users have this issue as well, since the 1903 release. I'll just use another file explorer.... Thank you, anyway.

Ps. Make a github.com repository, with your scripts and functions. It's easy. Here on the forum, it's harder to find stuff.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
SKAN
Posts: 667
Joined: 29 Sep 2013, 16:58

Re: SHELLSTATE() : Get / Check / Set global SHELL settings (Explorer)

24 Jun 2020, 15:36

robodesign wrote:Based on additional Google searches and forum posts.... Other users have this issue as well, since the 1903 release. I'll just use another file explorer...
 
In case you find any solution, please do post.
 
robodesign wrote:Make a github.com repository, with your scripts and functions. It's easy. Here on the forum, it's harder to find stuff.
 
Thanks for the suggestion. Our forum too needs content. :)
My signature has the link to my Scripts and functions.

Best regards :)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: pgeugene, Scatterthought and 22 guests