member just me please

Get help with using AutoHotkey and its commands and hotkeys
raylan
Posts: 12
Joined: 29 Dec 2015, 06:30

member just me please

08 Jun 2016, 02:12

I'm your fan

your all functions perfect
I'm so good

autohoykey FileSelectFolder uncomfortable

FileSelectFolder The new vista dialog style Please make
just me
Posts: 8708
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: member just me please

08 Jun 2016, 15:19

Hi,

I've absolutely no problem with FileSelectFolder. The Vista+ dialog would require an implemantation of the Common Item Dialog. That's COM, and COM isn't my preferred playground. But maybe some other member will do it or has done it already.
raylan
Posts: 12
Joined: 29 Dec 2015, 06:30

Re: member just me please

09 Jun 2016, 01:08

thanks for reading
just me
Posts: 8708
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: member just me please

09 Jun 2016, 03:36

Well, it turned out to be not that difficult as I expected. Here's a minimum implementation, seemingly working:

Code: Select all

SelectFolder() {
   ; 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
   Static OsVersion := DllCall("GetVersion", "UChar")
   Static Show := A_PtrSize * 3
   Static SetOptions := A_PtrSize * 9
   Static GetResult := A_PtrSize * 20
   SelectedFolder := ""
   If (OsVersion < 6) { ; IFileDialog requires Win Vista+
      FileSelectFolder, SelectedFolder
      Return SelectedFolder
   }
   If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
      Return ""
   VTBL := NumGet(FileDialog + 0, "UPtr")
   DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", 0x00000028, "UInt") ; FOS_NOCHANGEDIR | FOS_PICKFOLDERS
   If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", 0, "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)
      }
   }
   ObjRelease(FileDialog)
   Return SelectedFolder
}
raylan
Posts: 12
Joined: 29 Dec 2015, 06:30

Re: member just me please

09 Jun 2016, 08:36

hi just me

I can never thank you enough
Couldn't be better
You're the best!
thank you so much

Please be happy always!
raylan
Posts: 12
Joined: 29 Dec 2015, 06:30

Re: member just me please

09 Jun 2016, 12:56

my windows 10 Pro x64
It works perfectly
by any chance Prompt title ?
Okay Thanks just me
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: member just me please

09 Jun 2016, 13:12

This seems to set the title.

Code: Select all

SelectFolder("My Title")

SelectFolder(Title:="") {
   ; 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
   Static OsVersion := DllCall("GetVersion", "UChar")
   Static Show := A_PtrSize * 3
   Static SetOptions := A_PtrSize * 9
   Static SetTitle := A_PtrSize * 17
   Static GetResult := A_PtrSize * 20
   SelectedFolder := ""
   If (OsVersion < 6) { ; IFileDialog requires Win Vista+
      FileSelectFolder, SelectedFolder
      Return SelectedFolder
   }
   If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
      Return ""
   VTBL := NumGet(FileDialog + 0, "UPtr")
   DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", 0x00000028, "UInt") ; FOS_NOCHANGEDIR | FOS_PICKFOLDERS
   If (Title != "")
      DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "Str", Title, "UInt")
   If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", 0, "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)
      }
   }
   ObjRelease(FileDialog)
   Return SelectedFolder
}
Here's the vtable offsets for the other methods.

Code: Select all

IFileDialog vtable offsets
0   QueryInterface
1   AddRef 
2   Release 
3   Show 
4   SetFileTypes 
5   SetFileTypeIndex 
6   GetFileTypeIndex 
7   Advise 
8   Unadvise 
9   SetOptions 
10  GetOptions 
11  SetDefaultFolder 
12  SetFolder 
13  GetFolder 
14  GetCurrentSelection 
15  SetFileName 
16  GetFileName 
17  SetTitle 
18  SetOkButtonLabel 
19  SetFileNameLabel 
20  GetResult 
21  AddPlace 
22  SetDefaultExtension 
23  Close 
24  SetClientGuid 
25  ClearClientData 
26  SetFilter
raylan
Posts: 12
Joined: 29 Dec 2015, 06:30

Re: member just me please

09 Jun 2016, 13:59

Hi Kon
I owe you thanks
just me
Posts: 8708
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: member just me please

10 Jun 2016, 02:23

IFileDialog::SetTitle wrote:LPCWSTR pszTitle

Code: Select all

      DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", Title, "UInt")
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: member just me please

10 Jun 2016, 10:43

Thanks for the correction just me. The sad thing is I know that all COM strings should be Unicode. There's a lot to keep track of, and I need more practice with DllCall data types. :)

raylan, Because of the incorrect string type, my code above would not work on ANSI versions of AHK.
User avatar
Delta Pythagorean
Posts: 619
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: member just me please

21 Dec 2017, 20:18

Ok, old topic, I know.
But I'd like to get this dialog to be a "child" to an AHK made Gui, know of any way? I've tried the DllCall SetParent, I've Tried Gui, +OwnDialogs nothing worked...
I haven't found a solution in the Microsoft docs either. I'm completely stumped :s

[AHK]......: v2.0-rc.2 | 64-bit
[OS].......: Windows 10.0.19044.2251
[GITHUB]...: github.com/DeltaPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat#3703


You should maybe start to migrate to v2. Practice with small features first!
Remember to use [code] ... [/code] for your multi-line scripts.
jeuneperkersauvage

Re: member just me please

21 Dec 2017, 20:43

Delta Pythagorean wrote:Ok, old topic, I know.
But I'd like to get this dialog to be a "child" to an AHK made Gui, know of any way? I've tried the DllCall SetParent, I've Tried Gui, +OwnDialogs nothing worked...
I haven't found a solution in the Microsoft docs either. I'm completely stumped :s
When creating your GUI, make sure to tell AutoHotkey to save its HWND to a variable.

You can then change SelectFolder() { to SelectFolder(hwndOwner := 0) { and DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", 0, "UInt") into DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", hwndOwner, "UInt").

Pass said HWND when calling SelectFolder and it should be OK. Documentation on the Show method can be found here: https://msdn.microsoft.com/en-us/librar ... s.85).aspx
User avatar
Delta Pythagorean
Posts: 619
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: member just me please

22 Dec 2017, 16:58

jeuneperkersauvage wrote:Or just use https://autohotkey.com/boards/viewtopic.php?f=6&t=18939
Thank you both very much! It's greatly appreciated!

[AHK]......: v2.0-rc.2 | 64-bit
[OS].......: Windows 10.0.19044.2251
[GITHUB]...: github.com/DeltaPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat#3703


You should maybe start to migrate to v2. Practice with small features first!
Remember to use [code] ... [/code] for your multi-line scripts.

Return to “Ask for Help”

Who is online

Users browsing this forum: Descolada, william_ahk and 49 guests