FileSelectFile - control the display view type
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
FileSelectFile - control the display view type
Hello, is there any way to ensure that when fileselectfolder opens up the dialogue box to select a file that the view is set to Large Icons? Thanks
Re: FileSelectFile - control the display view type
Hi.
Maybe something is of use here:
Search for "HIDE/SHOW DESKTOP ICONS" on this thread. The target window wont be "ahk_class Progman" but something more like the CDialog ahk_class #32770.
This reference is worth a look as well as this, and the Nirsoft utility might come in useful as well.
Note to self: Search for "EXPLORER FOLDER WINDOW MESSAGES / VIEW MODES" on this page
Maybe something is of use here:
Search for "HIDE/SHOW DESKTOP ICONS" on this thread. The target window wont be "ahk_class Progman" but something more like the CDialog ahk_class #32770.
This reference is worth a look as well as this, and the Nirsoft utility might come in useful as well.
Note to self: Search for "EXPLORER FOLDER WINDOW MESSAGES / VIEW MODES" on this page
itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: FileSelectFile - control the display view type
Thanks for the links. I've given up on fileselectfile for my project and decided to build a custom GUI. Once I called up fileselectfile I couldn't find a way to interact with the dialogue. Thanks again.
Re: FileSelectFile - control the display view type
This is not entirely true. The thread indeed stops waiting for user's feedback. But if you launch another thread e.g. via Timer beforehand, then this thread can do the changes you wish.PuzzledGreatly wrote:Once I called up fileselectfile I couldn't find a way to interact with the dialogue.
Code: Select all
SetTimer, ChangeDialog, -300
FileSelectFile, fFile
MsgBox % fFile
Return
ChangeDialog:
WinWaitActive, ahk_class #32770 ahk_exe AutoHotkey.exe
Send, +{Tab 2}
Sleep, 300
Send, {Down}
Sleep, 300
Send, {Down}
Sleep, 300
Send, {Down}
Sleep, 300
Send, {Down}
;Replace the code above with the desired one!
Return
esc::ExitApp
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: FileSelectFile - control the display view type
My statement was completely true: I couldn't find a way but you could! Thanks for the idea. I think that technique will be useful.
Re: FileSelectFile - control the display view type
Based on rommmcek's script, and the VIEW MODES section that lmstearn mentioned. Cheers.
I couldn't find anything for FileSelectFolder, if there was a way, it might involve TVM_SETIMAGELIST.
FileSelectFolder uses SHBrowseForFolder, which uses the BROWSEINFO struct.
I found a way to enlarge the buttons, but not the icon size:
[EDIT:] I had partial success with TVM_GETIMAGELIST/ImageList_SetIconSize. But there wasn't enough space for the enlarged icons, and they were low quality.
Code: Select all
;FileSelectFile with large icons
vScriptPID := DllCall("kernel32\GetCurrentProcessId", "UInt")
SetTimer, ChangeDialog, -300
FileSelectFile, vPath
MsgBox, % vPath
return
ChangeDialog:
WinWait, % "ahk_class #32770 ahk_pid " vScriptPID
hWnd := WinExist()
PostMessage, 0x111, 28751, 0, SHELLDLL_DefView1, % "ahk_id " hWnd ;View, Large icons
return
FileSelectFolder uses SHBrowseForFolder, which uses the BROWSEINFO struct.
I found a way to enlarge the buttons, but not the icon size:
Code: Select all
;FileSelectFolder with large buttons (but icons same size)
vScriptPID := DllCall("kernel32\GetCurrentProcessId", "UInt")
SetTimer, ChangeDialog, -300
FileSelectFolder, vPath
MsgBox, % vPath
return
ChangeDialog:
WinWait, % "ahk_class #32770 ahk_pid " vScriptPID
hWnd := WinExist()
ControlGet, hCtl, Hwnd,, SysTreeView321, % "ahk_id " hWnd
;SendMessage, 0x111C, 0, 0,, % "ahk_id " hCtl ;TVM_GETITEMHEIGHT := 0x111C
;MsgBox, % ErrorLevel
SendMessage, 0x111B, 64, 0,, % "ahk_id " hCtl ;TVM_SETITEMHEIGHT := 0x111B
;TVGN_CARET := 0x9
SendMessage, 0x110A, 0x9, 0,, % "ahk_id " hCtl ;TVM_GETNEXTITEM := 0x110A
hItem := ErrorLevel
PostMessage, 0x1114, 0, % hItem,, % "ahk_id " hCtl ;TVM_ENSUREVISIBLE := 0x1114
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: FileSelectFile - control the display view type
You can use SelectFolderEx() by just me.
Code: Select all
SetTimer, ChangeDialog, -100
MsgBox, % SelectFolderEx()
return
ChangeDialog:
WinWait, % "ahk_class #32770 ahk_pid " DllCall("GetCurrentProcessId")
PostMessage, 0x111, 28751, 0, SHELLDLL_DefView1 ;View, Large icons
return
; ==================================================================================================================================
; Shows a dialog to select a folder.
; Depending on the OS version the function will use either the built-in FileSelectFolder command (XP and previous)
; or the Common Item Dialog (Vista and later).
; Parameter:
; StartingFolder - the full path of a folder which will be preselected.
; Prompt - a text used as window title (Common Item Dialog) or as text displayed withing the dialog.
; ---------------- Common Item Dialog only:
; OwnerHwnd - HWND of the Gui which owns the dialog. If you pass a valid HWND the dialog will become modal.
; BtnLabel - a text to be used as caption for the apply button.
; Return values:
; On success the function returns the full path of selected folder; otherwise it returns an empty string.
; MSDN:
; Common Item Dialog -> msdn.microsoft.com/en-us/library/bb776913%28v=vs.85%29.aspx
; IFileDialog -> msdn.microsoft.com/en-us/library/bb775966%28v=vs.85%29.aspx
; IShellItem -> msdn.microsoft.com/en-us/library/bb761140%28v=vs.85%29.aspx
; ==================================================================================================================================
SelectFolderEx(StartingFolder := "", Prompt := "", OwnerHwnd := 0, OkBtnLabel := "") {
Static OsVersion := DllCall("GetVersion", "UChar")
, IID_IShellItem := 0
, InitIID := VarSetCapacity(IID_IShellItem, 16, 0)
& DllCall("Ole32.dll\IIDFromString", "WStr", "{43826d1e-e718-42ee-bc55-a1e261c37bfe}", "Ptr", &IID_IShellItem)
, Show := A_PtrSize * 3
, SetOptions := A_PtrSize * 9
, SetFolder := A_PtrSize * 12
, SetTitle := A_PtrSize * 17
, SetOkButtonLabel := A_PtrSize * 18
, GetResult := A_PtrSize * 20
SelectedFolder := ""
If (OsVersion < 6) { ; IFileDialog requires Win Vista+, so revert to FileSelectFolder
FileSelectFolder, SelectedFolder, *%StartingFolder%, 3, %Prompt%
Return SelectedFolder
}
OwnerHwnd := DllCall("IsWindow", "Ptr", OwnerHwnd, "UInt") ? OwnerHwnd : 0
If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
Return ""
VTBL := NumGet(FileDialog + 0, "UPtr")
; FOS_CREATEPROMPT | FOS_NOCHANGEDIR | FOS_PICKFOLDERS
DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", 0x00002028, "UInt")
If (StartingFolder <> "")
If !DllCall("Shell32.dll\SHCreateItemFromParsingName", "WStr", StartingFolder, "Ptr", 0, "Ptr", &IID_IShellItem, "PtrP", FolderItem)
DllCall(NumGet(VTBL + SetFolder, "UPtr"), "Ptr", FileDialog, "Ptr", FolderItem, "UInt")
If (Prompt <> "")
DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", Prompt, "UInt")
If (OkBtnLabel <> "")
DllCall(NumGet(VTBL + SetOkButtonLabel, "UPtr"), "Ptr", FileDialog, "WStr", OkBtnLabel, "UInt")
If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", OwnerHwnd, "UInt") {
If !DllCall(NumGet(VTBL + GetResult, "UPtr"), "Ptr", FileDialog, "PtrP", ShellItem, "UInt") {
GetDisplayName := NumGet(NumGet(ShellItem + 0, "UPtr"), A_PtrSize * 5, "UPtr")
If !DllCall(GetDisplayName, "Ptr", ShellItem, "UInt", 0x80028000, "PtrP", StrPtr) ; SIGDN_DESKTOPABSOLUTEPARSING
SelectedFolder := StrGet(StrPtr, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "Ptr", StrPtr)
ObjRelease(ShellItem)
} }
If (FolderItem)
ObjRelease(FolderItem)
ObjRelease(FileDialog)
Return SelectedFolder
}
Re: FileSelectFile - control the display view type
@jeeswg: Thanks for brilliant finish! (I had in mind your Explorer tutorial too, but didn't have time)
@tmplinshi: Thanks for that code & link! Here is my contribution to it.
P.s.: All this not to be PuzzledGreatly! Ha, ha, beautiful name!
@tmplinshi: Thanks for that code & link! Here is my contribution to it.
P.s.: All this not to be PuzzledGreatly! Ha, ha, beautiful name!
Who is online
Users browsing this forum: Chunjee, Hansielein, Lpanatt and 321 guests