Resizing the preview pane of Windows Explorer

Get help with using AutoHotkey and its commands and hotkeys
paik1002
Posts: 337
Joined: 28 Nov 2015, 02:45

Resizing the preview pane of Windows Explorer

06 Apr 2017, 21:26

How do I resize the preview pane of Windows Explorer to a certain fixed size, e.g. width=800 pixels?
An empty preview pane has ClassNN=Shell Preview Extension Host1,
but generally the ClassNN differs by what it is displaying, e.g. PDF, text, MS Office documents, etc.

Code: Select all

#ifwinactive ahk_class CabinetWClass
^+!F12::		; resize the preview pane to have a fixed width of 800 pixels
{
    ControlMove, Shell Preview Extension Host1,,,800,, ahk_class CabinetWClass,,Program Manager
    return
}
#if
paik1002
Posts: 337
Joined: 28 Nov 2015, 02:45

Re: Resizing the preview pane of Windows Explorer

21 Jun 2017, 19:13

Does anyone have any idea to solving this problem?
User avatar
jeeswg
Posts: 5942
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Resizing the preview pane of Windows Explorer

22 Jun 2017, 02:29

I don't usually use the preview pane, but I thought it was an interesting problem so I gave it a shot.

I have one method that works by emulating a mouse drag to resize the preview pane, it uses the Acc library to get the preview pane width.
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

I tried resizing controls, but the problem is, no matter which control I resized, the divider stayed where it was, I'm not sure which control or element the divider belongs to, or whether there is a way to affect it programmatically.

Code: Select all

q:: ;resize Explorer preview pane (tested on Windows 7)
ControlGet, hCtl, Hwnd,, DirectUIHWND2, A
oAcc := Acc_Get("Object", "4.3", 0, "ahk_id " hCtl)
vEltW := Acc_Location(oAcc).w

;ControlGetPos,,, vCtlW,, Shell Preview Extension Host1, A
ControlGet, hCtl, Hwnd,, SHELLDLL_DefView1, A
;ControlGet, hCtl, Hwnd,, DirectUIHWND3, A
;ControlGet, hCtl, Hwnd,, CtrlNotifySink3, A

vEltWNew := 800
if (vEltW = vEltWNew)
{
	oAcc := ""
	return
}

VarSetCapacity(RECT, 16)
DllCall("GetWindowRect", Ptr,hCtl, Ptr,&RECT)
vCtlX := NumGet(RECT, 0, "Int")
vCtlY := NumGet(RECT, 4, "Int")
vCtlR := NumGet(RECT, 8, "Int")
vCtlB := NumGet(RECT, 12, "Int")

CoordMode, Mouse, Screen
;seems to require 2 mouse moves to show the resize cursor
MouseMove, % vCtlR, % (vCtlY+vCtlB)/2-1
MouseMove, % vCtlR, % (vCtlY+vCtlB)/2
MouseClickDrag, Left, 0, 0, % vEltW-vEltWNew, 0, 0, R
ToolTip, % vEltW " " (vEltW-vEltWNew)
oAcc := ""
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
BoBo
Posts: 2518
Joined: 13 May 2014, 17:15

Re: Resizing the preview pane of Windows Explorer

22 Jun 2017, 07:38

Probably [this] is of help (and can be scripted/triggered) :)
Would be interested to see if it's possible to refresh explorer to work with changed settings on the fly. :lolno:

[Another] more "in-depth" finding ...
Spoiler
User avatar
jeeswg
Posts: 5942
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Resizing the preview pane of Windows Explorer

30 Jun 2017, 13:44

Cheers for the link BoBo, I actually came across it and meant to share it. I don't know if it will do what the OP wants, it might be good enough.

Solution to Windows 7 preview pane size problem | Johan Draaisma's website
https://www.johandraaisma.nl/solution-t ... e-problem/

This other one you linked, is also interesting, which I didn't see:

Skinning through the shellstyle - here a short explanation
https://vistastylebuilder.com/forum/ind ... opic=721.0
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 5942
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Resizing the preview pane of Windows Explorer

01 Jul 2017, 14:35

I think I've found which control subelement determines the size of the preview pane. However I don't know of a way to do 'ElementMove' cf. WinMove or ControlMove.

To find out, I did things like use ControlMove to move controls out of the way, and see if the slider(separator/divider?) remained where it was, and also I used AccViewer. I also used WinGetPos to get the control positions, in order to show a border around each control.

Anyhow, whatever the right element is, I believe it belongs to the DirectUIHWND2 control.

Code: Select all

;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

q:: ;get Preview Pane coordinates
WinGet, hWnd, ID, A
ControlGet, hCtl, Hwnd,, DirectUIHWND2, A
oAcc := Acc_Get("Object", "4.3", 0, "ahk_id " hCtl) ;Preview Pane
vEltX := Acc_Location(oAcc).x
vEltY := Acc_Location(oAcc).y
CoordMode, Mouse, Screen
MouseMove, % vEltX, % vEltY
vName := oAcc.accName(0)
MsgBox, % vName
oAcc := ""
return
[EDIT:] Perhaps this would be useful, but I'd need a bit of assistance:
c# - How to move an UI automation element to a different location? - Stack Overflow
https://stackoverflow.com/questions/104 ... t-location
TransformPattern Class (System.Windows.Automation)
https://msdn.microsoft.com/en-us/librar ... ttern.aspx

[EDIT:] Something else that might be useful (and some potentially useful template code relating to column interaction and interfaces):
IPreviewHandler interface (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Explorer column interaction (get/set: which appear, width, ascending/descending order) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=33129
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 5942
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Resizing the preview pane of Windows Explorer

29 Aug 2017, 00:10

paik1002 wrote:How do I resize the preview pane of Windows Explorer to a certain fixed size, e.g. width=800 pixels?
I now have a reasonably satisfactory script for this. You change the setting in the registry, navigate to a different folder and return. If possible I would like a better approach for the re-navigation.

Some things that didn't work:
- F5 to refresh the window didn't work (to reset the pane width in the current folder).
- Toggling hide/show the preview pane didn't work either.
- I also considered navigating to the same path but the short form or a PIDL form.
- I also tried things to refresh Explorer like AHK's EnvUpdate command. Cheers.

Code: Select all

q:: ;set preview pane width

;set preview pane width in the registry
vWidth := 300
vHex := Format("{:02X}{:02X}", vWidth & 0xFF, (vWidth/256) & 0xFF) "000001000000000000009E030000"
RegWrite, REG_BINARY, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\GlobalSettings\Sizer, ReadingPaneSizer, % vHex

;new folder windows will have the correct preview pane width
;to reset the pane width of the current window, re-navigate to it
WinGet, hWnd, ID, A
WinGetClass, vWinClass, % "ahk_id " hWnd
if !(vWinClass = "CabinetWClass") && !(vWinClass = "ExploreWClass")
	return
for oWin in ComObjCreate("Shell.Application").Windows
	if (oWin.HWND = hWnd)
	{
		vDir := oWin.Document.Folder.Self.Path
		SplitPath, vDir,, vDir2
		oWin.Navigate(vDir2)
		while oWin.busy
			Sleep 10
		oWin.Navigate(vDir)
	}
oWin := ""
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], electrone77, scriptor2016, sinkfaze, SOTE and 183 guests