<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Окно проводника]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=17719</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17719&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Окно проводника».]]></description>
		<lastBuildDate>Tue, 04 Apr 2023 18:12:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157478#p157478</link>
			<description><![CDATA[<p><a href="https://www.autohotkey.com/boards/viewtopic.php?t=53136#p231879">https://www.autohotkey.com/boards/viewt … 36#p231879</a><br />Тут все опции расписаны, осталось всё в кучу собрать.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 04 Apr 2023 18:12:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157478#p157478</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157477#p157477</link>
			<description><![CDATA[<p>Спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 04 Apr 2023 18:07:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157477#p157477</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157452#p157452</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Про настройки видов пока ничего.</p></blockquote></div><p>Ну как же ничего.<br />Из ссылки из второго поста:<br /></p><div class="codebox"><pre><code>try if ((FileDialogCustomize := ComObjQuery(FileDialog, &quot;{e6fdd21a-163f-4975-9c8c-a69f1ba37034}&quot;))) {</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 03 Apr 2023 12:09:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157452#p157452</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157444#p157444</link>
			<description><![CDATA[<p>Начал вспоминать, нашёл исходник, нужен был SetFolder. Про настройки видов пока ничего.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>

if ((fde := IFileDialogEvents_new())) {  
	MsgBox % SelectFolder(fde, A_TEMP)
	ObjRelease(fde)
} 

+Esc:: ExitApp

IFileDialogEvents_new()
{
	vtbl := IFileDialogEvents_Vtbl()
	; VarSetCapacity apparently tries to emulate the peculiarities of stack allocation so use GlobalAlloc here
	fde := DllCall(&quot;GlobalAlloc&quot;, &quot;UInt&quot;, 0x0000, &quot;Ptr&quot;, A_PtrSize + 4, &quot;Ptr&quot;) ; A_PtrSize to store the pointer to the vtable struct + sizeof unsigned int to store this object&#039;s refcount
	if (!fde)
		return 0

	NumPut(vtbl, fde+0,, &quot;Ptr&quot;) ; place pointer to vtable in beginning of the IFileDialogEvents structure (you know how all this works from the other side)
	NumPut(1, fde+0, A_PtrSize, &quot;UInt&quot;) ; Start with a refcount of one (thanks, just me)

	return fde
}

IFileDialogEvents_Vtbl(ByRef vtblSize := 0)
{
	/* This vtable approach is quite rigid and unflexible in its approach. 
		I mean, ideally, you&#039;d want each object to have its own set of methods that are called.
		With this, however, nope - same methods, just a different &quot;this&quot;.
	
		I leave fixing that part up to you. I imagine it involves each object getting its own
		vtable (you could leave all the callback pointers inside the IFileDialogEvents struct after the vtable pointer)
		instead of sharing this one, with the functions to be called for each object determined at creation. Or something like that.
	*/
	static vtable ; This mustn&#039;t be freed automatically when it goes out of scope
	if (!VarSetCapacity(vtable)) {
		; Three IUnknown methods that must be implemented, along with the many methods IFileDialogEvents adds on top
		extfuncs := [&quot;QueryInterface&quot;, &quot;AddRef&quot;, &quot;Release&quot;, &quot;OnFileOk&quot;, &quot;OnFolderChanging&quot;, &quot;OnFolderChange&quot;, &quot;OnSelectionChange&quot;, &quot;OnShareViolation&quot;, &quot;OnTypeChange&quot;, &quot;OnOverwrite&quot;]

		; Create IFileDialogEventsVtbl struct
		VarSetCapacity(vtable, extfuncs.Length() * A_PtrSize)

		for i, name in extfuncs
			NumPut(RegisterCallback(&quot;IFileDialogEvents_&quot; . name), vtable, (i-1) * A_PtrSize)
	}
	if (IsByRef(vtblSize))
		vtblSize := VarSetCapacity(vtable)
	return &amp;vtable
}

; Called on a &quot;ComObjQuery&quot;
IFileDialogEvents_QueryInterface(this_, riid, ppvObject)
{
	static IID_IUnknown, IID_IFileDialogEvents
	if (!VarSetCapacity(IID_IUnknown))
		VarSetCapacity(IID_IUnknown, 16), VarSetCapacity(IID_IFileDialogEvents, 16)
		,DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;WStr&quot;, &quot;{00000000-0000-0000-C000-000000000046}&quot;, &quot;Ptr&quot;, &amp;IID_IUnknown)
		,DllCall(&quot;ole32\CLSIDFromString&quot;, &quot;WStr&quot;, &quot;{973510db-7d7f-452b-8975-74a85828d354}&quot;, &quot;Ptr&quot;, &amp;IID_IFileDialogEvents)

	; If someone calls our QI asking for IUnknown or IFileDialogEvents, then respond by:
	if (DllCall(&quot;ole32\IsEqualGUID&quot;, &quot;Ptr&quot;, riid, &quot;Ptr&quot;, &amp;IID_IFileDialogEvents) || DllCall(&quot;ole32\IsEqualGUID&quot;, &quot;Ptr&quot;, riid, &quot;Ptr&quot;, &amp;IID_IUnknown)) {
		NumPut(this_, ppvObject+0, &quot;Ptr&quot;) ; filling in the pointer to a pointer with the address of this object
		IFileDialogEvents_AddRef(this_)
		return 0 ; S_OK
	}

	; Else
	NumPut(0, ppvObject+0, &quot;Ptr&quot;) ; no object for the caller
	return 0x80004002 ; E_NOINTERFACE
}

; Called on an &quot;ObjAddRef&quot;
IFileDialogEvents_AddRef(this_)
{
	; get and increment our reference count member inside the IFileDialogEvents struct
	NumPut((_refCount := NumGet(this_+0, A_PtrSize, &quot;UInt&quot;) + 1), this_+0, A_PtrSize, &quot;UInt&quot;)
	return _refCount ; new refcount must be returned
}

; Called on an &quot;ObjRelease&quot;
IFileDialogEvents_Release(this_) {
	_refCount := NumGet(this_+0, A_PtrSize, &quot;UInt&quot;) ; read current refcount from IFileDialogEvents struct
	if (_refCount &gt; 0) {
		_refCount -= 1 ; decrease it
		NumPut(_refCount, this_+0, A_PtrSize, &quot;UInt&quot;) ; store it
		if (_refCount == 0) ; if it&#039;s zero, then
			DllCall(&quot;GlobalFree&quot;, &quot;Ptr&quot;, this_, &quot;Ptr&quot;) ; it&#039;s time for this object to free itself
	}
	return _refCount ; new refcount must be returned
}

IFileDialogEvents_OnFileOk(this_, pfd)
{
IFileDialogEvents_OnSelectionChange(this_, pfd)
return 1
	return 0x80004001 ; E_NOTIMPL (&quot;[IFileDialogEvents] methods that are not implemented should return E_NOTIMPL.&quot;)
}

IFileDialogEvents_OnFolderChanging(this_, pfd, psiFolder)
{
	return 0x80004001 ; E_NOTIMPL
}

IFileDialogEvents_OnFolderChange(this_, pfd)
{
	return 0x80004001 ; E_NOTIMPL
}

IFileDialogEvents_OnSelectionChange(this_, pfd)
{
	if (DllCall(NumGet(NumGet(pfd+0)+14*A_PtrSize), &quot;Ptr&quot;, pfd, &quot;Ptr*&quot;, psi) &gt;= 0) { ; IFileDialog::GetCurrentSelection
         GetDisplayName := NumGet(NumGet(psi + 0, &quot;UPtr&quot;), A_PtrSize * 5, &quot;UPtr&quot;)
         If !DllCall(GetDisplayName, &quot;Ptr&quot;, psi, &quot;UInt&quot;, 0x80028000, &quot;PtrP&quot;, StrPtr) { ; SIGDN_DESKTOPABSOLUTEPARSING
            SelectedFolder := StrGet(StrPtr, &quot;UTF-16&quot;), DllCall(&quot;Ole32.dll\CoTaskMemFree&quot;, &quot;Ptr&quot;, StrPtr)
			ToolTip % SelectedFolder
		 }
		ObjRelease(psi)
	}
	return 0 ; S_OK
}

IFileDialogEvents_OnShareViolation(this_, pfd, psi, pResponse)
{
	return 0x80004001 ; E_NOTIMPL
}

IFileDialogEvents_OnTypeChange(this_, pfd)
{
	return 0x80004001 ; E_NOTIMPL
}

IFileDialogEvents_OnOverwrite(this_, pfd, psi, pResponse)
{
	return 0x80004001 ; E_NOTIMPL
}

; ---

SelectFolder(fde := 0, StartFolder := &quot;&quot;) {
   ; Common Item Dialog -&gt; https://msdn.microsoft.com/en-us/library/bb776913%28v=vs.85%29.aspx
   ; IFileDialog        -&gt; https://msdn.microsoft.com/en-us/library/bb775966%28v=vs.85%29.aspx
   ; IShellItem         -&gt; https://msdn.microsoft.com/en-us/library/bb761140%28v=vs.85%29.aspx
   Static OsVersion := DllCall(&quot;GetVersion&quot;, &quot;UChar&quot;)
   Static Show := A_PtrSize * 3
   Static SetOptions := A_PtrSize * 9
   Static SetFolder := A_PtrSize * 12
   Static GetResult := A_PtrSize * 20
   
   SelectedFolder := &quot;&quot;
   If (OsVersion &lt; 6) { ; IFileDialog requires Win Vista+
      FileSelectFolder, SelectedFolder
      Return SelectedFolder
   }
   If !(FileDialog := ComObjCreate(&quot;{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}&quot;, &quot;{42f85136-db7e-439c-85f1-e4075d135fc8}&quot;))
      Return &quot;&quot;
	  ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions
   VTBL := NumGet(FileDialog + 0, &quot;UPtr&quot;)
   DllCall(NumGet(VTBL + SetOptions, &quot;UPtr&quot;), &quot;Ptr&quot;, FileDialog, &quot;UInt&quot;, 0x00000008, &quot;UInt&quot;) ; FOS_NOCHANGEDIR | FOS_PICKFOLDERS
    
	DllCall(NumGet(VTBL + SetFolder, &quot;UPtr&quot;), &quot;Ptr&quot;, FileDialog, &quot;Ptr&quot;, GetShellItem(pItem := StartFolder), &quot;UInt&quot;)  
	ObjRelease(pItem)
	
	if (fde) {
		DllCall(NumGet(NumGet(FileDialog+0)+7*A_PtrSize), &quot;Ptr&quot;, FileDialog, &quot;Ptr&quot;, fde, &quot;UInt*&quot;, dwCookie := 0)
	}

	showSucceeded := DllCall(NumGet(VTBL + Show, &quot;UPtr&quot;), &quot;Ptr&quot;, FileDialog, &quot;Ptr&quot;, 0) &gt;= 0

	if (dwCookie)
		DllCall(NumGet(NumGet(FileDialog+0)+8*A_PtrSize), &quot;Ptr&quot;, FileDialog, &quot;UInt&quot;, dwCookie)

   If (showSucceeded) {
	   If !DllCall(NumGet(VTBL + GetResult, &quot;UPtr&quot;), &quot;Ptr&quot;, FileDialog, &quot;PtrP&quot;, ShellItem, &quot;UInt&quot;) {
         GetDisplayName := NumGet(NumGet(ShellItem + 0, &quot;UPtr&quot;), A_PtrSize * 5, &quot;UPtr&quot;)
         If !DllCall(GetDisplayName, &quot;Ptr&quot;, ShellItem, &quot;UInt&quot;, 0x80028000, &quot;PtrP&quot;, StrPtr) ; SIGDN_DESKTOPABSOLUTEPARSING
            SelectedFolder := StrGet(StrPtr, &quot;UTF-16&quot;), DllCall(&quot;Ole32.dll\CoTaskMemFree&quot;, &quot;Ptr&quot;, StrPtr)
         ObjRelease(ShellItem)
      }
   }

   ObjRelease(FileDialog)
   Return SelectedFolder
}

GetShellItem(Item) {
   VarSetCapacity(IID, 16, 0)
   DllCall(&quot;Ole32.dll\IIDFromString&quot;, &quot;WStr&quot;, &quot;{43826d1e-e718-42ee-bc55-a1e261c37bfe}&quot;, &quot;Ptr&quot;, &amp;IID, &quot;UInt&quot;)
   DllCall(&quot;Shell32.dll\SHCreateItemFromParsingName&quot;, &quot;WStr&quot;, Item, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, &amp;IID, &quot;PtrP&quot;, pShellItem, &quot;UInt&quot;)
   Return pShellItem
}
</code></pre></div></div></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 02 Apr 2023 14:09:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157444#p157444</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157443#p157443</link>
			<description><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Там просто стоит опция FOS_PICKFOLDERS.</p></blockquote></div><p>Ого, заработало.<br /></p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>У него интерфейс расписан практически со всеми пояснениями.</p></blockquote></div><p>Да уж, там в какие то дебри надо лезть. Например нужно SetDefaultFolder, так понял нужен её индекс. У SetOptions указано 9, но откуда он взялся? Помню ты как то объяснял, что в исходниках надо копать.</p><p>Про настройки видов так тебя понял, что совсем сложно. Дерево скрыть, вид файлов и.т.п.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 02 Apr 2023 09:53:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157443#p157443</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157442#p157442</link>
			<description><![CDATA[<p>Там просто стоит опция FOS_PICKFOLDERS.<br />У него интерфейс расписан практически со всеми пояснениями.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 02 Apr 2023 08:50:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157442#p157442</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157441#p157441</link>
			<description><![CDATA[<p>У него про папки только.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 02 Apr 2023 08:24:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157441#p157441</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157440#p157440</link>
			<description><![CDATA[<p>Я имел в виду, что раз у него написано, то и париться не о чем. А esc проще всего блокировать при активном диалоге.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 02 Apr 2023 08:04:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157440#p157440</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157439#p157439</link>
			<description><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>написание интерфейса</p></blockquote></div><p>А него что написано, или ты как то по другому пишешь?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 02 Apr 2023 07:37:49 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157439#p157439</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157438#p157438</link>
			<description><![CDATA[<p>Нет, я имел в виду написание интерфейса, хотя и это не сложно, если есть внятная документация.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 02 Apr 2023 07:13:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157438#p157438</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157437#p157437</link>
			<description><![CDATA[<p>Ещё мешает закрытие по ESC, отлов WM_DESTROY не помогает.<br /></p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Почему не будем?<br />Просто там надо подзапариться с ком интерфейсами, хотя об этом уже позаботился qwerty12.</p></blockquote></div><p>А ты тут имел ввиду что его пример сложно переделать под SelectFile?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 02 Apr 2023 04:56:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157437#p157437</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157436#p157436</link>
			<description><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>А вот со вторым вопросом, похоже, придется таки разбираться с созданием ком интерфейсов:</p></blockquote></div><p>О, типа возможно любые опции выбирать. Нормальный вариант был бы. Можно в интерфейс свой добавить например, рамки обрезать, setparent, и считай как новый контрол.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 01 Apr 2023 21:02:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157436#p157436</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157435#p157435</link>
			<description><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Так в коде же написано куда ее пихать</p></blockquote></div><p>Плохи дела).<br /><a href="https://www.youtube.com/watch?v=L0g-rWPVC-I">https://www.youtube.com/watch?v=L0g-rWPVC-I</a></p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 01 Apr 2023 20:36:09 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157435#p157435</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157434#p157434</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Никак с lpstrInitialDir не разберусь, это стартовая папка</p></blockquote></div><p>Так в коде же написано куда ее пихать:<br /></p><div class="codebox"><pre><code>initialDir := A_Desktop
title := &quot;Open&quot;
NumPut(&amp;initialDir, OPENFILENAMEW, A_PtrSize*(10 + (A_PtrSize == 4)), &quot;Ptr&quot;) ; lpstrInitialDir</code></pre></div><p>А вот со вторым вопросом, похоже, придется таки разбираться с созданием ком интерфейсов:<br /><a href="https://tannerhelland.com/2013/01/16/hooking-modern-windows-common-dialogs-notes.html">https://tannerhelland.com/2013/01/16/ho … notes.html</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sat, 01 Apr 2023 18:21:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157434#p157434</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Окно проводника]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=157433#p157433</link>
			<description><![CDATA[<p>Никак с lpstrInitialDir не разберусь, это стартовая папка, мне даже _Struct не помог).<br />Ещё хотел выяснить как изменить стиль окна, вроде бывает с деревом слева, но добавления флагов не сработало.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 01 Apr 2023 17:13:31 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=157433#p157433</guid>
		</item>
	</channel>
</rss>
