<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; HTA: Drag & Drop файлов]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12644&amp;type=atom" />
	<updated>2017-05-14T10:29:03Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12644</id>
		<entry>
			<title type="html"><![CDATA[Re: HTA: Drag & Drop файлов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115832#p115832" />
			<content type="html"><![CDATA[<p>Спасибо.<br />Теперь есть полный комплект для анализа.<br />Оказывается, ещё и засада в совместимости: IE9 ещё не поддерживает файлы, а IE11 уже как-то по-другому реагирует на VBS. То-то в предыдущем примере на JS у меня на VBS вообще ничего не работало.<br />Очень ценная информация, ещё раз большое спасибо.</p>]]></content>
			<author>
				<name><![CDATA[fy73]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=36941</uri>
			</author>
			<updated>2017-05-14T10:29:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115832#p115832</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: HTA: Drag & Drop файлов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115829#p115829" />
			<content type="html"><![CDATA[<p>Наверное, как-то так.<br /></p><div class="codebox"><pre><code>
 &lt;!DOCTYPE HTML&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=10&quot;/&gt;
		&lt;style&gt;
			body, html {
				width: 100%;
				height: 100%;
				margin: 0;
			}
			#table {
				font-family:Tahoma;
				width:100%;
				height:100%;
				border-collapse:collapse;
			}
			
			#table td {
				border:solid 1px black;
			}
			
		&lt;/style&gt;
		&lt;script language=&quot;VBScript&quot;&gt;
			Option Explicit
			
			window.resizeTo 640,480
			
			Function dropContainer_ondrop(objEvent)
				Dim types, files, iFile, iType, file, text
				With objEvent.dataTransfer
					Set files = .files
					Set types = .types
					dropContainer.innerText = &quot;&quot;
					For iType=0 to types.length - 1
						Select Case types.item(iType)
						Case &quot;Text&quot;
							PrintText &quot;You dropped text &quot;&quot;&quot; &amp; .GetData(&quot;Text&quot;) &amp; &quot;&quot;&quot;&quot;
						Case &quot;Url&quot;
							PrintText &quot;You dropped url &quot;&quot;&quot; &amp; .GetData(&quot;Url&quot;) &amp; &quot;&quot;&quot;&quot;
						Case &quot;Files&quot;
							PrintText &quot;You dropped &quot; &amp; files.length &amp; &quot; file(s):&quot;
							For iFile=0 to files.length - 1
								Set file = files.item(iFile)
								PrintText(iFile &amp; &quot;. &quot; &amp; file.name &amp; &quot; (&quot; &amp; file.size &amp; &quot; bytes)&quot;)
							Next
						Case Else
							MsgBox &quot;Unknown format &quot;&quot;&quot; &amp; types.item(iType) &amp; &quot;&quot;&quot;&quot;, vbCritical
						End Select
					Next
				End With
			End Function
			
			Sub PrintText(text)
				dropContainer.insertAdjacentText &quot;beforeend&quot;, text &amp; vbCrlf
			End Sub
		&lt;/script&gt;
		&lt;hta:application 
		scroll=&quot;no&quot;
		/&gt;
		&lt;title&gt;drop test&lt;/title&gt;
	&lt;/head&gt;
	&lt;body 
		ondragenter=&quot;return false;&quot; 
		ondragover=&quot;return false;&quot; 
		ondrop=&quot;return false&quot;&gt; 
		
		&lt;table id=&quot;table&quot;&gt;
			&lt;tr&gt;
				&lt;td&gt;Sample text for drop&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td&gt;&lt;a href=&quot;#&quot;&gt;Sample url for drop&lt;/a&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr style=&quot;height:100%;&quot;&gt;
				&lt;td id=&quot;dropContainer&quot; style=&quot;background: #eee;&quot;&gt;
					drop something here
				&lt;/td&gt;
			&lt;/tr&gt;
		&lt;table&gt;
	&lt;/body&gt;
&lt;/html&gt; 
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2017-05-14T09:15:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115829#p115829</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: HTA: Drag & Drop файлов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115804#p115804" />
			<content type="html"><![CDATA[<p>Пример работает.<br />А VBS его перевести возможно?<br />Что-то перевод в HTML5 так всё изменил, что у меня даже в малости ничего не выходит.</p>]]></content>
			<author>
				<name><![CDATA[fy73]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=36941</uri>
			</author>
			<updated>2017-05-13T13:05:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115804#p115804</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: HTA: Drag & Drop файлов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115786#p115786" />
			<content type="html"><![CDATA[<p>Большое спасибо!<br />Буду экспериментировать.<br />А то я уже начал пытаться запихнуть туда объект WebBrowser и ловить файлы им.</p>]]></content>
			<author>
				<name><![CDATA[fy73]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=36941</uri>
			</author>
			<updated>2017-05-11T11:51:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115786#p115786</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: HTA: Drag & Drop файлов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115783#p115783" />
			<content type="html"><![CDATA[<p><strong>fy73</strong>, думаю Вам нужно добавить тэг <strong>meta</strong> c указанием необходимого движка IE.</p><div class="codebox"><pre><code>
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=...&quot;/&gt;
</code></pre></div><p>Это сказывается и на отрисовку HTML содержимого и на методы, свойства, события объектов в коде JS и VBS.</p><p>Проверил на <strong>Windows 10</strong>. По умолчанию, используется движок <strong>IE 7</strong>. На других системах не проверял.</p><p>Вот такой пример у меня работает с файлами и прочим содержимым:<br /></p><div class="codebox"><pre><code>
&lt;!DOCTYPE html&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=9; IE=8; IE=7; IE=EDGE&quot;/&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			
			function window::onload(){
				alert(&quot;document mode: &quot; + document.documentMode)
			}
			
			function OnDropBody (event) {
				alert (&quot;Please drop the files into the textarea.&quot;);
				return false;
			}

			function OnDropTextarea (event) {
				if (event.dataTransfer) {
					if (event.dataTransfer.files) {
						var target = document.getElementById (&quot;target&quot;);
						target.value = &quot;&quot;;
						for (var i = 0; i &lt; event.dataTransfer.files.length; i++) {
							var file = event.dataTransfer.files[i];
							if (&#039;name&#039; in file) {
								var fileName = file.name;
							}
							else {
								var fileName = file.fileName;
							}
							if (&#039;size&#039; in file) {
								var fileSize = file.size;
							}
							else {
								var fileSize = file.fileSize;
							}

							target.value += (i+1) + &quot;. file -- name: &quot; + fileName + &quot;, size: &quot; + fileSize + &quot; bytes\n&quot;;
						}
					}
					else {
						alert (&quot;Your browser does not support the files property.&quot;);
					}
				}
				else {
					alert (&quot;Your browser does not support the dataTransfer property.&quot;);
				}
				if (event.stopPropagation) {
					event.stopPropagation ();
				}
				else {
					event.cancelBubble = true;
				}
				return false;
			}
		&lt;/script&gt;
	&lt;/head&gt;
	&lt;body ondragenter=&quot;return false;&quot; ondragover=&quot;return false;&quot; ondrop=&quot;return OnDropBody (event);&quot;&gt;
		Please drag some files into this browser window and drop them in the following field:&lt;br /&gt;
		&lt;textarea id=&quot;target&quot; rows=&quot;5&quot; cols=&quot;50&quot; spellcheck=&quot;false&quot; 
			ondragenter=&quot;return false;&quot; ondragover=&quot;return false;&quot; 
			ondrop=&quot;return OnDropTextarea (event);&quot;&gt;
		&lt;/textarea&gt;
		&lt;br /&gt;&lt;br /&gt;
		In Safari, please drag some text within this browser window first and drag files next.
	&lt;/body&gt;
&lt;/html&gt;
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2017-05-11T11:45:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115783#p115783</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: HTA: Drag & Drop файлов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115764#p115764" />
			<content type="html"><![CDATA[<p>Попытался выкрутиться через HTML5.<br />Добавил директиву <strong>&lt;!DOCTYPE html&gt;</strong>, нашёл <a href="https://msdn.microsoft.com/ru-ru/library/hh673539(v=vs.85).aspx">пример</a>, с помощью <a href="http://stackoverflow.com/questions/14209006/how-to-call-custom-event-in-vbscript">другого примера</a> перевёл его в VBS:<br /></p><div class="codebox"><pre><code>	Sub Init(id_div)
		Dim customFn,cEvent,div
		Set div=Document.GetElementById(id_div)
		
		Set customFn=GetRef(&quot;dropHandler&quot;)
		div.addEventListener &quot;OnDrop&quot;,customFn
		Set cEvent=Document.CreateEvent(&quot;Drop&quot;)
		cEvent.InitCustomEvent &quot;OnDrop&quot;,false,false,null
		div.DispatchEvent(cEvent)
		div.RemoveEventListener &quot;OnDrop&quot;,customFn
		
		Set customFn=GetRef(&quot;doNothing&quot;)
		div.addEventListener &quot;OnDragOver&quot;,customFn
		Set cEvent=Document.CreateEvent(&quot;DragOver&quot;)
		cEvent.InitCustomEvent &quot;OnDragOver&quot;,false,false,null
		div.DispatchEvent(cEvent)
		div.RemoveEventListener &quot;OnDragOver&quot;,customFn
	End Sub
</code></pre></div><p>Но на строке <strong>div.addEventListener &quot;OnDrop&quot;,customFn</strong> получаю ошибку &quot;Объект не поддерживает это свойство или метод: &#039;div.addEventListener&#039;&quot;.<br />То есть всё? Невозможно от слова совсем?</p>]]></content>
			<author>
				<name><![CDATA[fy73]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=36941</uri>
			</author>
			<updated>2017-05-10T12:53:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115764#p115764</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[HTA: Drag & Drop файлов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115442#p115442" />
			<content type="html"><![CDATA[<p>Пытался победить самостоятельно задачу перетаскивания файлов на форму HTA, но не смог.<br />В том методе, который я собрал из всевозможных примеров, обрабатываются только текст и ссылки, так как по запросу Window.Event.DataTransfer возвращается объект типа <a href="https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa752703.aspx">IHTMLDataTransfer</a>.<br />При перетаскивании файлов сами события генерируются, но информации о них никакой не возвращается (или я не смог её получить).<br /></p><div class="codebox"><pre><code>&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=Content-Type Content=&quot;text-html; charset=1251&quot;&gt;
		&lt;hta:application
		id=Drop
		applicationName=&#039;Drop&#039;
		maximizeButton=yes
		innerBorder=yes
		border=thick
		scroll=auto
		selection=yes
		contextMenu=yes
		singleinstance=yes
		sysMenu=yes
		version=0.0.1
		&gt;
		&lt;title&gt;Drop&lt;/title&gt;
		&lt;style type=&quot;text/css&quot;&gt;
			.block1
			{
				width: 200px;
				height: 200px;
				background: gray;
				padding: 5px;
				padding-right: 20px;
				border: solid 1px black;
				float: left;
				text-align: center;
				font-size: 50;
			}
			.block2
			{
				width: 200px;
				height: 200px;
				background: gray;
				padding: 5px;
				border: solid 1px black;
				float: left;
				position: relative;
				top: 40px;
				left: -70px;
				text-align: center;
				font-size: 50;
			}
			.info
			{
				width: 450px;
				height: 30px;
				padding: 5px;
				border: solid 1px black;
				float: left;
				position: relative;
				top: 80px;
				left: 5px;
				text-align: center;
			}
		&lt;/style&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;textarea cols=&quot;50&quot; rows=&quot;1&quot;&gt;Текст для перетаскивания&lt;/textarea&gt;
		&lt;br&gt;&lt;a href=&quot;http://forum.script-coding.com/&quot;&gt;Ссылка для перетаскивания&lt;/a&gt;
		&lt;div id=&quot;div1&quot; class=&quot;block1&quot;&gt;div1&lt;/div&gt;
		&lt;div id=&quot;div2&quot; class=&quot;block2&quot;&gt;div2&lt;/div&gt;
		&lt;br&gt;
		&lt;table id=&quot;info&quot; class=&quot;info&quot; border=&quot;1&quot;&gt;
			&lt;tr&gt;&lt;td width=&quot;33%&quot;&gt;&lt;b&gt;div1:&lt;/b&gt;&lt;/td&gt;&lt;td width=&quot;33%&quot; id=&quot;Event1&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td width=&quot;33%&quot; id=&quot;Time1&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
			&lt;tr&gt;&lt;td&gt;&lt;b&gt;div2:&lt;/b&gt;&lt;/td&gt;&lt;td id=&quot;Event2&quot; title=&quot;Последнее событие&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td id=&quot;Time2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td id=&quot;TypeDataTransfer&quot; title=&quot;TypeName(Window.Event.DataTransfer)&quot;&gt;&amp;nbsp;&lt;/td&gt;
				&lt;td id=&quot;TypeURL&quot; title=&quot;TypeName(DataURL), DataURL&quot;&gt;&amp;nbsp;&lt;/td&gt;
				&lt;td id=&quot;TypeText&quot; title=&quot;TypeName(DataTXT), DataTXT&quot;&gt;&amp;nbsp;&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/body&gt;
&lt;/html&gt;
&lt;script language=&quot;VBS&quot;&gt;
	Option Explicit
	Window.ResizeTo 500,500
	Sub GetInfo()
		Dim DataTXT,DataURL
		TypeDataTransfer.InnerHtml=TypeName(Window.Event.DataTransfer)
		DataTXT=Window.Event.DataTransfer.GetData(&quot;Text&quot;)
		DataURL=Window.Event.DataTransfer.GetData(&quot;URL&quot;)
		TypeURL.InnerHtml=TypeName(DataURL) &amp; &quot;, &quot; &amp; DataURL
		TypeText.InnerHtml=TypeName(DataTXT) &amp; &quot;, &quot; &amp; DataTXT
	End Sub
	Sub div1_OnDragEnter()
		Event1.InnerHtml=&quot;OnDragEnter&quot;
		Time1.InnerHtml=Now
		div1.Style.Background=&quot;Cyan&quot;
		Window.Event.ReturnValue=False
		GetInfo
	End Sub
	Sub div1_OnDragLeave()
		Event1.InnerHtml=&quot;OnDragLeave&quot;
		Time1.InnerHtml=Now
		div1.Style.Background=&quot;Gray&quot;
		Window.Event.ReturnValue=False
		GetInfo
	End Sub
	Sub div1_OnDragOver()
		Event1.InnerHtml=&quot;OnDragOver&quot;
		Time1.InnerHtml=Now
		Window.Event.ReturnValue=False
		GetInfo
	End Sub
	Sub div1_OnDrop()
		Event1.InnerHtml=&quot;OnDrop&quot;
		Time1.InnerHtml=Now
		Window.Event.ReturnValue=False
		GetInfo
		div1.Style.Background=&quot;Red&quot;
		SetTimeout &quot;SetGray(1)&quot;, 2000, &quot;VBScript&quot;
	End Sub
	Sub div2_OnDragEnter()
		Event2.InnerHtml=&quot;OnDragEnter&quot;
		Time2.InnerHtml=Now
		div2.Style.Background=&quot;Cyan&quot;
		Window.Event.ReturnValue=False
		GetInfo
	End Sub
	Sub div2_OnDragLeave()
		Event2.InnerHtml=&quot;OnDragLeave&quot;
		Time2.InnerHtml=Now
		div2.Style.Background=&quot;Gray&quot;
		Window.Event.ReturnValue=False
		GetInfo
	End Sub
	Sub div2_OnDragOver()
		Event2.InnerHtml=&quot;OnDragOver&quot;
		Time2.InnerHtml=Now
		Window.Event.ReturnValue=False
		GetInfo
	End Sub
	Sub div2_OnDrop()
		Event2.InnerHtml=&quot;OnDrop&quot;
		Time2.InnerHtml=Now
		Window.Event.ReturnValue=False
		GetInfo
		div2.Style.Background=&quot;Red&quot;
		SetTimeout &quot;SetGray(2)&quot;, 2000, &quot;VBScript&quot;
	End Sub
	Sub SetGray(Num)
		Document.GetElementById(&quot;div&quot; &amp; Num).Style.Background=&quot;Gray&quot;
	End Sub
&lt;/script&gt;</code></pre></div><p>Если знаете рабочий способ, помогите пожалуйста.</p>]]></content>
			<author>
				<name><![CDATA[fy73]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=36941</uri>
			</author>
			<updated>2017-04-28T19:20:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115442#p115442</id>
		</entry>
</feed>
