tablacus/TablacusExplorer

Details pane (toggle)

Closed this issue ยท 11 comments

It's me again !
I am trying with my limited knowledge and the scripts you provided to create a script that toggles detail pane on/off when explorer frames are on.

      var WSHShell = new ActiveXObject("WScript.Shell");
      var detailsContainerPath = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Modules\\GlobalSettings\\DetailsContainer\\DetailsContainer";
                   
      // Get current registry values
     
      var currentDetailsValue = WSHShell.RegRead(detailsContainerPath);
      // var updatedDetailsValue = currentDetailsValue === "02 00 00 00 02 00 00 00" ? "01 00 00 00 02 00 00 00" : "02 00 00 00 02 00 00 00";
      
      if (currentDetailsValue !== null) {
        // Toggle the 1st byte (visibility)
        var sizerBytes = currentDetailsValue.split(" ").map(function (byte) {
            return parseInt(byte, 16);
        });
        sizerBytes[0] = sizerBytes[0] === 1 ? 2 : 1;

        // Convert back to hex string
        var updatedDetailsValue = sizerBytes.map(function (byte) {
            return byte.toString(16).padStart(2, "0");
        }).join("");
              
      // Update registry values
      
      WSHShell.RegWrite(detailsContainerPath, updatedDetailsValue, "REG_BINARY");
      
   
      // Refresh Explorer
      var FV = GetFolderView(Ctrl, pt);
      FV.Refresh();

I had a 'little help from Microsoft copilot but it seems that something is not working. If you have the time please take a look at the script.
Thank you.

ccfs commented

My conclusion:

  1. RegRead cannot return REG_BINARY in JScript. RegWrite can write only 1 value for REG_BINARY. Therefore I have to use VBScript and another method to change the Registry value.
  2. The Registry key is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer\PreviewPaneSizer, and the visibility value is at offset 4. I don't know whether this is due to Windows version difference or not.
  3. I have to switch FV.Type back and forth to do the refresh.
  4. If you use "Frame pane" add-on, "Details pane" option should be set to "Default".
  5. ValueName is PageSpaceControlSizer for Navigation pane and ReadingPaneSizer for Preview pane. However I cannot toggle Preview pane when Navigation pane is visible (but no problem in Windows Explorer).

Here is a sample setup:

Note "Type" is blank
image

ToggleDetailsPane.vbs

Const HKEY_CURRENT_USER = &H80000001
Const strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer"
Const strValueName = "PreviewPaneSizer"

Dim oReg, aValue
Set oReg = GetObject("winmgmts:root\default:StdRegProv")
Call oReg.GetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)
If aValue(4) = 0 Then
	aValue(4) = 1
Else
	aValue(4) = 0
End If
Call oReg.SetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)

RefreshFrame.js

te.LockUpdate();
FV.Type = CTRL_SB;
FV.Type = CTRL_EB;
te.UnlockUpdate();

I just tested this correcting the reg key ( for me it is "DetailsContainerSizer" for windows 11) but i have a mismatch error 'aValue' at line 8. Thank you for looking into this. I will try to continue with your code to see if I make it !

ccfs commented

Try toggling the pane in Windows Explorer and look for any change near Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings using Registry Editor, to find out the correct entry.

How about this?

var detailsContainerPath = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Modules\\GlobalSettings\\DetailsContainer\\DetailsContainer";
              
// Get current registry values
var currentDetailsValue = wsh.RegRead(detailsContainerPath);

// Toggle the 1st byte (visibility)
var sizerBytes = api.CreateObject("Array", currentDetailsValue);
if (sizerBytes.length) {
  sizerBytes[0] = sizerBytes[0] === 1 ? 2 : 1;

  // Convert to hex string
  var hexValue = [];
  for (var i = 0; i < sizerBytes.length; ++i) {
    hexValue.push(('0' + (sizerBytes[i].toString(16))).slice(-2));
  }
  // Update registry values
  api.CreateProcess('reg add ' + GetParentFolderName(detailsContainerPath) + ' /v ' + GetFileName(detailsContainerPath) + ' /t REG_BINARY /d ' + hexValue.join("") + ' /f');

  // Refresh Explorer
  var FV = GetFolderView(Ctrl, pt);
  FV.Refresh();
}

Regards,

I found the correct entry. The change in registry key is happening . Scripts working no change in TE or Explorer.I think there is another key I have to change DetailsContainer\DetailsContainer.
You got it first ! I added you last jscript but the registry entry does not change. I continue testing and I will let you know.
Thank you again ! ใ‚ใ‚ŠใŒใจใ† !

Success ! I used your first vbs script and edited the keys. Here's the code

Const HKEY_CURRENT_USER = &H80000001
Const strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\DetailsContainer"
Const strValueName = "DetailsContainer"

Dim oReg, aValue
Set oReg = GetObject("winmgmts:root\default:StdRegProv")
Call oReg.GetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)
If aValue(0) = 1 Then
	aValue(0) = 2
Else
	aValue(0) = 1
End If
Call oReg.SetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)

Now using three scripts but with what I learned from you I think I can optimize it !
Thank you !

I completed the code using your instructions and I send it for future use. (Windows 11)
### ToggleDetailsPane0.vbs

Const HKEY_CURRENT_USER = &H80000001 ' Registry key for the currently logged-in user
Const strKeyPath1 = "Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer"               ' Details pane size settings key registry path
Const strKeyPath2 = "Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\DetailsContainer"    ' Details pane main key registry path
Const strValueName1 = "DetailsContainerSizer"
Const strValueName2 = "DetailsContainer"

' Create objects for registry manipulation
Dim oReg1, aValue1, oReg2, aValue2
Set oReg1 = GetObject("winmgmts:root\default:StdRegProv") ' Initialize object1 for registry manipulation
Set oReg2 = GetObject("winmgmts:root\default:StdRegProv") ' Initialize object2 for registry manipulation

' Retrieve the binary value associated with DetailsContainerSizer
Call oReg1.GetBinaryValue(HKEY_CURRENT_USER, strKeyPath1, strValueName1, aValue1)

' Toggle the sizer pane (DetailsContainerSizer) on/off
If aValue1(4) = 1 Then
    aValue1(4) = 0 ' Turn it on
Else
    aValue1(4) = 1 ' Turn it off
End If

' Retrieve the binary value associated with DetailsContainer
Call oReg2.GetBinaryValue(HKEY_CURRENT_USER, strKeyPath2, strValueName2, aValue2)

' Toggle the Preview pane off
If aValue2(4) = 1 Then  ' If preview pane is on
    aValue2(4) = 2      ' turn it off before enabling details pane
End If

' Toggle the details pane (DetailsContainer) on/off
If aValue2(0) = 1 Then
    aValue2(0) = 2 ' Turn it off
Else
    aValue2(0) = 1 ' Turn it on
End If

' Set the modified values back to the registry
Call oReg1.SetBinaryValue(HKEY_CURRENT_USER, strKeyPath1, strValueName1, aValue1)
Call oReg2.SetBinaryValue(HKEY_CURRENT_USER, strKeyPath2, strValueName2, aValue2)
 

after this we need your ### RefreshFrame.js

te.LockUpdate();
FV.Type = CTRL_SB;
FV.Type = CTRL_EB;
te.UnlockUpdate();

and ### TogglePreviewPane0.vbs

Const HKEY_CURRENT_USER = &H80000001
Const strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\DetailsContainer"
Const strValueName = "DetailsContainer"

Dim oReg, aValue
Set oReg = GetObject("winmgmts:root\default:StdRegProv")
Call oReg.GetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)
If aValue(0) = 1 Then aValue(0) = 2 End If																	
If aValue(4) = 2 Then
	aValue(4) = 1
Else
	aValue(4) = 2
End If
Call oReg.SetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)

of course we again call RefreshFrame.js.

In order to use these scripts please refer to the sample setup posted above.

Again thank you for your help !

ccfs commented

Reference: https://appuals.com/enable-disable-the-pane-features-in-file-explorer-on-windows-10/

One more. I think that this will work on Windows 7 thru 10. ToggleNavPane.vbs

Const HKEY_CURRENT_USER = &H80000001
Const strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer"
Const strValueName = "PageSpaceControlSizer"

Dim oReg, aValue
Set oReg = GetObject("winmgmts:root\default:StdRegProv")
Call oReg.GetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)
If aValue(4) = 0 Then
	aValue(4) = 1
Else
	aValue(4) = 0
End If
Call oReg.SetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)

  1. I suggest that you can simplify ToggleDetailsPane0.vbs a little - we only need one oReg, no need to use two (oReg1, oReg2).
  2. All of the above actually have a problem: At the first click, the pane may not toggle (and other panes may toggle), IF you have toggled the pane (and other panes) in other tabs (or Windows Explorer).
    This is because the scripts toggle the settings in Registry (updated by any tab or Windows Explorer), not the settings in the tab, and the tab will take the latest settings in Registry after RefreshFrame.js runs.
    To solve this problem, the scripts should do either one:
  • take the setting in the tab (but sorry I don't know how to do this), toggle it, and update Registry.
  • do a Windows function call to toggle (again I don't know how to do this), disregarding Registry.
ccfs commented

On Windows 7, I could not toggle Details pane and Preview pane when Navigation pane was visible. I find out a solution: run the vbs in the middle of RefreshFrame.js. Therefore I refine the set up as:

20240405_142200

ToggleDetailsPane.js

if (FV.Type == CTRL_EB) {
	te.LockUpdate();
	FV.Type = CTRL_SB;
	importScript("%TE_CONFIG%\\script\\ToggleDetailsPane.vbs");
	FV.Type = CTRL_EB;
	te.UnlockUpdate();
}

If you get a similar problem, you can try the above.

Alternatively, you can set up like this to make it portable, without using "External script" add-on.
20240405_142653

Reference: https://appuals.com/enable-disable-the-pane-features-in-file-explorer-on-windows-10/

One more. I think that this will work on Windows 7 thru 10. ToggleNavPane.vbs

Const HKEY_CURRENT_USER = &H80000001
Const strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer"
Const strValueName = "PageSpaceControlSizer"

Dim oReg, aValue
Set oReg = GetObject("winmgmts:root\default:StdRegProv")
Call oReg.GetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)
If aValue(4) = 0 Then
	aValue(4) = 1
Else
	aValue(4) = 0
End If
Call oReg.SetBinaryValue(HKEY_CURRENT_USER, strKeyPath, strValueName, aValue)
1. I suggest that you can simplify ToggleDetailsPane0.vbs a little - we only need one oReg, no need to use two (oReg1, oReg2).

2. All of the above actually have a problem: At the first click, the pane may not toggle (and other panes may toggle), IF you have toggled the pane (and other panes) in other tabs (or Windows Explorer).
   This is because the scripts toggle the settings in Registry (updated by any tab or Windows Explorer), not the settings in the tab, and the tab will take the latest settings in Registry after RefreshFrame.js runs.
   To solve this problem, the scripts should do either one:


* take the setting in the tab (but sorry I don't know how to do this), toggle it, and update Registry.

* do a Windows function call to toggle (again I don't know how to do this), disregarding Registry.
  1. Of course I should have simplified the code but I am not a programmer just a hobbyist that learns from you :) I will do my best !
  2. You are absolutely right on this but bear in mind that I disregard the use of the native file explorer and use TE. Now when we change tabs it would be good if the frames had kept their individual settings but we are dealing with registry as you said. Is there something like Global variables embedded into the 'Frames' Addon that would do the registry keeping for each tab (or inside the tabs code) Then we could modify the scripts and do the checking before changing anything? (idea : dynamic buttons in general that change status depending on a condition. something like the clipboard addon that you did.)
    I came across this https://github.com/microsoft/detours and you are the only one who can demystify it and find something that may be helpful !
  3. ToggleNavPane.vbs works fine for me in windows 11.
  4. I liked the method of importScript ! (learned something again !)
    Thank you as always !
ccfs commented
  1. I am also a hobbyist, not a programmer. :)
  2. I am making a new add-on to toggle the panes, in order to solve this problem. It will be available in a few days.