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
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 := ""
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 := ""