<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Работа с буфером обмена (clipboard)]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=4324&amp;type=atom" />
	<updated>2011-09-07T16:07:15Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=4324</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=51294#p51294" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Lucky пишет:</cite><blockquote><p>Есть примеры копирования текста в буфер обмена и наоборот - получение.</p><div class="codebox"><pre><code>&#039;Копирование текста в буфер обмена
strCopy = &quot;Этот текст будет скопирован в буфера обмена&quot;
Set objIE = CreateObject(&quot;InternetExplorer.Application&quot;)
objIE.Navigate(&quot;about:blank&quot;)
objIE.document.parentWindow.clipboardData.setData &quot;text&quot;, strCopy
objIE.Quit</code></pre></div></blockquote></div><p>Вещь интересная, а вот если имеется, например, 3 строки, которые нужно скопировать, как сделать так, чтоб эти строки вставлялись по горячим клавишам?<br />Например: Ctrl+1-1-я строка, Ctrl+2-2-я строка, Ctrl+3-3-я строка.</p>]]></content>
			<author>
				<name><![CDATA[Redger]]></name>
			</author>
			<updated>2011-09-07T16:07:15Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=51294#p51294</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=50339#p50339" />
			<content type="html"><![CDATA[<p>Хочу поместить текст в буфер обмена:<br /></p><div class="codebox"><pre><code>WScript.CreateObject(&quot;HTMLFile&quot;).parentWindow.clipboardData.setData(&quot;text&quot;, &quot;Текст для вставки в буфер&quot;);</code></pre></div><p>Но чё-то не работает. Как исправить?</p>]]></content>
			<author>
				<name><![CDATA[Крепыш]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=20359</uri>
			</author>
			<updated>2011-08-02T14:47:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=50339#p50339</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=44289#p44289" />
			<content type="html"><![CDATA[<p>Реализация HTA-диалога взята, разумеется, на этом форуме.<br />Весь код:</p><div class="codebox"><pre><code>Option Explicit
&#039;глобальные переменные
Dim ExitDo, oHTA, Document, strHTML, appName
appName = &quot;autoClipboard&quot;
Sub HTA_OnUnload
    ExitDo = True
End Sub
&#039;получаем окно
Set oHTA = GetOHTA (260, 260, appName, &quot;#E0E0E0&quot;)
Set Document = oHTA.document

Function ClosingWindow
End Function
&#039;==================================================================================================
&#039;MAIN
&#039;==================================================================================================
&#039; формируем строку HTML-кода
strHTML = &quot;&lt;style type=&#039;text/css&#039;&gt;&quot;
strHTML = &quot;P{ font-family: Geneva, Arial, Helvetica, sans-serif; }&quot;
strHTML = &quot;&lt;/style&gt;&quot;
strHTML = strHTML &amp; &quot;&lt;P&gt;Обработчик события копирования текста  с автовставкой в word-документ&lt;/P&gt;&quot;
&#039;strHTML = strHTML &amp; &quot;&lt;BR&gt;&quot;
strHTML = strHTML &amp; &quot;&lt;BUTTON id=start&gt;START&lt;/BUTTON&gt;&amp;nbsp;&amp;nbsp;&quot;
strHTML = strHTML &amp; &quot;&lt;BUTTON id=stop&gt;PAUSE&lt;/BUTTON&gt;&amp;nbsp;&amp;nbsp;&quot;
strHTML = strHTML &amp; &quot;&lt;BR&gt;&quot;
strHTML = strHTML &amp; &quot;&lt;P id=appStatus&gt;Status: not running&lt;/P&gt;&quot;
strHTML = strHTML &amp; &quot;&lt;P&gt;&lt;/P&gt;&quot;
strHTML = strHTML &amp; &quot;&lt;BUTTON id=exit&gt;EXIT&lt;/BUTTON&gt;&amp;nbsp;&amp;nbsp;&quot;
strHTML = strHTML &amp; &quot;&lt;BR&gt;&quot;
strHTML = strHTML &amp; &quot;&lt;INPUT TYPE=CHECKBOX id=closeWord&gt;close word document&quot;

&#039; записываем HTML-код в тело документа
Document.getElementsByTagName(&quot;body&quot;)(0).innerHTML = strHTML
&#039;==================================================================================================
Dim HTMLFile, MSWord, NewDoc, ProcessStatus, ProcessActive, CurrentClipboardText, CloseWordStatus
Set HTMLFile = WScript.CreateObject(&quot;HTMLFile&quot;)
Set MSWord = CreateObject(&quot;Word.Application&quot;)
Set NewDoc = MSWord.Documents.Add()
NewDoc.Activate()
MSWord.Selection.TypeText(&quot;Do not close the document while the &quot; &amp; appName &amp; &quot; is work!&quot;)
MSWord.Selection.TypeParagraph()
MSWord.Selection.TypeText(&quot;Не закрывайте этот документ во время работы &quot; &amp; appName &amp; &quot;!&quot;)
MSWord.Selection.TypeParagraph()
MSWord.Selection.TypeParagraph()
MSWord.Visible = True &#039;показываем документ
ProcessStatus = True
ProcessActive = False
CurrentClipboardText = &quot;&quot;
CloseWordStatus = &quot;&quot;

Function PastClipboard
    Do While ProcessStatus
        If ProcessActive Then
            On Error Resume Next &#039;если обработчик попадает в момент копирования в буфер - происходит ошибка данных (null), пропускаем ее
                If Not (HTMLFile.parentWindow.clipboardData.getData(&quot;text&quot;) = CurrentClipboardText) Then
                    If CurrentClipboardText = &quot;&quot; Then &#039;в первый заход из буфера ничего не вставляем
                        CurrentClipboardText = HTMLFile.parentWindow.clipboardData.getData(&quot;text&quot;)
                    Else
                        CurrentClipboardText = HTMLFile.parentWindow.clipboardData.getData(&quot;text&quot;)
                        NewDoc.Activate()
                        MSWord.Selection.Paste()
                        MSWord.Selection.TypeParagraph()
                    End If
                End If
&#039;            If Err.Number&lt;&gt;0 Then
                &#039;&lt;обработка ошибки&gt;
                &#039;MsgBox Err.Description
&#039;            End If
&#039;            On Error GoTo 0 &#039;обнуление объекта Err
        End If
        WScript.Sleep 100
    Loop
    MsgBox  appName &amp; &quot;: handler stopped&quot;
End Function

&#039; назначение событий кнопкам
Sub StartProcess
    If ProcessStatus Then
        If Not ProcessActive Then
            CurrentClipboardText = &quot;&quot;
            ProcessActive = True
            Document.parentWindow.appStatus.innerHTML = &quot;Status: running&quot;
        End If
    End If
End Sub
Document.parentWindow.start.onclick = GetRef(&quot;StartProcess&quot;)

Sub StopProcess
    If ProcessActive Then
        ProcessActive = False
        Document.parentWindow.appStatus.innerHTML = &quot;Status: pause&quot;
    End If
End Sub
Document.parentWindow.stop.onclick = GetRef(&quot;StopProcess&quot;)

Sub ClossApp
    ProcessStatus = False
    Document.parentWindow.close
End Sub
Document.parentWindow.exit.onclick = GetRef(&quot;ClossApp&quot;)

Sub CloseWord
    CloseWordStatus = Document.parentWindow.closeWord.value
End Sub
Document.parentWindow.closeWord.onclick = GetRef(&quot;CloseWord&quot;)

Function ClosingWindow &#039;переопределяем ф-цию ClosingWindow
    ProcessStatus = False
    If Not CloseWordStatus = &quot;&quot; Then
        NewDoc.Close 0 &#039; Word.WdSaveOptions.wdDoNotSaveChanges
        MSWord.Quit(False)
    End If
End Function

PastClipboard &#039;запускаем обработчик
&#039;==================================================================================================
&#039;END MAIN
&#039;==================================================================================================
Do &#039; ожидание закрытия окна HTA
    WScript.Sleep 100
    If ExitDo Then &#039;обрабатываем событие закрытия окна программы
        ClosingWindow
    End If
Loop Until ExitDo
&#039;==================================================================================================
&#039;==================================================================================================
&#039;APP WINDOW
Function GetOHTA( Width, Height, Title, BgColor )
    Dim oDict, oHTA
    Set oDict = CreateObject(&quot;Scripting.Dictionary&quot;)
    oDict.Add &quot;CONTEXTMENU&quot;, &quot;no&quot;
    oDict.Add &quot;INNERBORDER&quot;, &quot;no&quot;
    oDict.Add &quot;SCROLL&quot;, &quot;no&quot;
    oDict.Add &quot;BORDER&quot;, &quot;dialog&quot;
    oDict.Add &quot;BORDERSTYLE&quot;, &quot;raised&quot;
    oDict.Add &quot;MAXIMIZEBUTTON&quot;, &quot;no&quot;
    oDict.Add &quot;MINIMIZEBUTTON&quot;, &quot;no&quot;
    Set oHTA = GetHTADialog(oDict)
    If oHTA Is Nothing Then
        WScript.Echo &quot;Не удалось получить связь с окном HTA.&quot;
        WScript.Quit
    End If
    &#039; назначаем обработчик события выгрузки (закрытия) формы
    oHTA.document.body.onunload = GetRef(&quot;HTA_OnUnload&quot;)
    &#039; задаём размеры формы
    oHTA.document.parentWindow.resizeTo Width, Height
    &#039;oHTA.document.parentWindow.resizeTo 350, 320
    &#039; задаём заголовок окна
    oHTA.document.title = Title
    &#039; задаём цвет фона
    oHTA.document.getElementsByTagName(&quot;body&quot;)(0).bgcolor = BgColor
    &#039;возвращаем
    Set GetOHTA = oHTA
End Function
&#039;==================================================================================================
Function GetHTADialog(ByRef Params)
    Dim oFSO, oWshShell, oWindows, oTextStream, oWnd, oWindow
    Dim sHTAFileName, ID, N
    
    Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
    Set oWshShell = CreateObject(&quot;WScript.Shell&quot;)
    Set oWindows = CreateObject(&quot;Shell.Application&quot;).Windows
    
    &#039; формирование имени будущего файла HTA
    sHTAFileName = oWshShell.ExpandEnvironmentStrings(&quot;%TEMP%&quot;) &amp; &quot;\&quot; &amp; oFSO.GetTempName() &amp; &quot;.hta&quot;
    &#039; создание файла HTA
    Set oTextStream = oFSO.CreateTextFile(sHTAFileName, True)
    &#039; заполнение файла HTA
    With oTextStream
        .WriteLine &quot;&lt;HTML&gt;&lt;HEAD&gt;&quot;
        .WriteLine &quot;&lt;OBJECT classid=&quot;&quot;clsid:8856F961-340A-11D0-A96B-00C04FD705A2&quot;&quot;&quot;
        .WriteLine &quot;    id=&quot;&quot;WebBrowserTemplate&quot;&quot; width=&quot;&quot;0&quot;&quot; height=&quot;&quot;0&quot;&quot;&gt;&lt;/OBJECT&gt;&quot;
        .WriteLine &quot;&lt;OBJECT id=&quot;&quot;MSScriptControl&quot;&quot; style=&quot;&quot;display:none&quot;&quot; classid=&quot;&quot;clsid:0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC&quot;&quot;&gt;&quot;
        .WriteLine &quot;    &lt;PARAM name=&quot;&quot;AllowUI&quot;&quot; value=1&gt;&lt;PARAM name=&quot;&quot;UseSafeSubSet&quot;&quot; value=1&gt;&lt;/OBJECT&gt;&quot;
        .WriteLine &quot;&lt;TITLE&gt;&lt;/TITLE&gt;&quot;
        .WriteLine &quot;&lt;SCRIPT language=vbscript&gt;&quot;
        .WriteLine &quot;If IsObject(window) Then&quot;
        .WriteLine &quot;    window.attachevent &quot;&quot;onload&quot;&quot;, GetRef(&quot;&quot;Main&quot;&quot;)&quot;
        .WriteLine &quot;    document.attachevent &quot;&quot;onkeydown&quot;&quot;, GetRef(&quot;&quot;Document_onkeydown_event&quot;&quot;)&quot;
        .WriteLine &quot;End If&quot;
        .WriteLine &quot;Sub Main&quot;
        .WriteLine &quot;    CommandLine = Document.all.tags(&quot;&quot;APPLICATION&quot;&quot;)(0).CommandLine&quot;
        .WriteLine &quot;    Pos = InstrRev(CommandLine, &quot;&quot; &quot;&quot;)&quot;
        .WriteLine &quot;    CommandLine = Mid(CommandLine, Pos + 1, Len(CommandLine) - Pos)&quot;
        .WriteLine &quot;    If CommandLine = &quot;&quot;&quot;&quot; Then Exit Sub&quot;
        .WriteLine &quot;    Set WebBrowser = Document.GetElementById(&quot;&quot;WebBrowserTemplate&quot;&quot;)&quot;
        .WriteLine &quot;    WebBrowser.RegisterAsBrowser = True&quot;
        .WriteLine &quot;    WebBrowser.style.display = &quot;&quot;none&quot;&quot;&quot;
        .WriteLine &quot;    WebBrowser.RegisterAsDropTarget = False&quot;
        .WriteLine &quot;    WebBrowser.Visible = False&quot;
        .WriteLine &quot;    WebBrowser.PutProperty &quot;&quot;ID&quot;&quot;, Clng(CommandLine)&quot;
        .WriteLine &quot;    WebBrowser.PutProperty &quot;&quot;HWND&quot;&quot;, MSScriptControl.SiteHwnd&quot;
        .WriteLine &quot;End Sub&quot;
        .WriteLine &quot;Function Document_onkeydown_event&quot;
        .WriteLine &quot;    If window.event.keycode = 27 Then window.close()&quot; &#039; закрытие по Esc
        .WriteLine &quot;    If window.event.keycode = 116 Then Document_onkeydown_event = false&quot; &#039; блокировка F5 (refresh)
        .WriteLine &quot;End Function&quot;
        .WriteLine &quot;&lt;/SCRIPT&gt;&quot;
        .WriteLine &quot;&lt;HTA:APPLICATION&quot;
        .WriteLine &quot;APPLICATIONNAME=&quot;&quot;&quot; &amp; Params.Item(&quot;APPLICATIONNAME&quot;) &amp; &quot;&quot;&quot;&quot;
        If Params.Exists(&quot;BORDER&quot;) Then
            .WriteLine &quot;BORDER=&quot;&quot;&quot; &amp; Params.Item(&quot;BORDER&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;BORDER=&quot;&quot;thick&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;BORDERSTYLE&quot;) Then
            .WriteLine &quot;BORDERSTYLE=&quot;&quot;&quot; &amp; Params.Item(&quot;BORDERSTYLE&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;BORDERSTYLE=&quot;&quot;normal&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;CAPTION&quot;) Then
            .WriteLine &quot;CAPTION=&quot;&quot;&quot; &amp; Params.Item(&quot;CAPTION&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;CAPTION=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;CONTEXTMENU&quot;) Then
            .WriteLine &quot;CONTEXTMENU=&quot;&quot;&quot; &amp; Params.Item(&quot;CONTEXTMENU&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;CONTEXTMENU=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;ICON&quot;) Then
            .WriteLine &quot;ICON=&quot;&quot;&quot; &amp; Params.Item(&quot;ICON&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;ICON=&quot;&quot;System Application Icon&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;INNERBORDER&quot;) Then
            .WriteLine &quot;INNERBORDER=&quot;&quot;&quot; &amp; Params.Item(&quot;INNERBORDER&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;INNERBORDER=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;MAXIMIZEBUTTON&quot;) Then
            .WriteLine &quot;MAXIMIZEBUTTON=&quot;&quot;&quot; &amp; Params.Item(&quot;MAXIMIZEBUTTON&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;MAXIMIZEBUTTON=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;MINIMIZEBUTTON&quot;) Then
            .WriteLine &quot;MINIMIZEBUTTON=&quot;&quot;&quot; &amp; Params.Item(&quot;MINIMIZEBUTTON&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;MINIMIZEBUTTON=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;NAVIGABLE&quot;) Then
            .WriteLine &quot;NAVIGABLE=&quot;&quot;&quot; &amp; Params.Item(&quot;NAVIGABLE&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;NAVIGABLE=&quot;&quot;no&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;SCROLL&quot;) Then
            .WriteLine &quot;SCROLL=&quot;&quot;&quot; &amp; Params.Item(&quot;SCROLL&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;SCROLL=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;SCROLLFLAT&quot;) Then
            .WriteLine &quot;SCROLLFLAT=&quot;&quot;&quot; &amp; Params.Item(&quot;SCROLLFLAT&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;SCROLLFLAT=&quot;&quot;no&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;SELECTION&quot;) Then
            .WriteLine &quot;SELECTION=&quot;&quot;&quot; &amp; Params.Item(&quot;SELECTION&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;SELECTION=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;SHOWINTASKBAR&quot;) Then
            .WriteLine &quot;SHOWINTASKBAR=&quot;&quot;&quot; &amp; Params.Item(&quot;SHOWINTASKBAR&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;SHOWINTASKBAR=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;SINGLEINSTANCE&quot;) Then
            .WriteLine &quot;SINGLEINSTANCE=&quot;&quot;&quot; &amp; Params.Item(&quot;SINGLEINSTANCE&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;SINGLEINSTANCE=&quot;&quot;no&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;SYSMENU&quot;) Then
            .WriteLine &quot;SYSMENU=&quot;&quot;&quot; &amp; Params.Item(&quot;SYSMENU&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;SYSMENU=&quot;&quot;yes&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;VERSION&quot;) Then
            .WriteLine &quot;VERSION=&quot;&quot;&quot; &amp; Params.Item(&quot;VERSION&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;VERSION=&quot;&quot;1.0&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;WINDOWSTATE&quot;) Then
            .WriteLine &quot;WINDOWSTATE=&quot;&quot;&quot; &amp; Params.Item(&quot;WINDOWSTATE&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;WINDOWSTATE=&quot;&quot;normal&quot;&quot;&quot;
        End If
        If Params.Exists(&quot;ID&quot;) Then
            .WriteLine &quot;ID=&quot;&quot;&quot; &amp; Params.Item(&quot;ID&quot;) &amp; &quot;&quot;&quot;&quot;
        Else
            .WriteLine &quot;ID=&quot;&quot;oHTA&quot;&quot;&quot;
        End If
        .WriteLine &quot;/&gt;&quot;
        .WriteLine &quot;&lt;/HEAD&gt;&lt;BODY&gt;&lt;/BODY&gt;&lt;/HTML&gt;&quot;
        .Close
    End With
    Randomize
    ID = Clng(Rnd * 100000)
    oWshShell.Run sHTAFileName &amp; &quot; &quot; &amp; ID
    &#039; поиск окна HTA
    Set oWnd = Nothing
    For N = 1 to 5000
        For Each oWindow in oWindows
            If oWindow.GetProperty(&quot;ID&quot;) = ID Then
                Set oWnd = oWindow
                Exit For
            End If
        Next
        If Not oWnd Is Nothing Then Exit For
        WScript.Sleep 100
    Next
    &#039; удаление файла HTA
    oFSO.DeleteFile sHTAFileName, True
    &#039; возвращаем ссылку на окно HTA
    Set GetHTADialog = oWnd
End Function</code></pre></div>]]></content>
			<author>
				<name><![CDATA[LeshikSan]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26243</uri>
			</author>
			<updated>2011-01-22T19:51:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=44289#p44289</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=44211#p44211" />
			<content type="html"><![CDATA[<p><strong>LeshikSan</strong>, давайте тогда ещё код HTA, ибо из приведённого кода видно, что функция «PastClipboard()» нигде не вызывается.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-01-21T19:11:23Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=44211#p44211</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=44189#p44189" />
			<content type="html"><![CDATA[<p>У меня получилось так:</p><div class="codebox"><pre><code>Dim HTMLFile, MSWord, NewDoc, ProcessStatus, ProcessActive, CurrentClipboardText
Set HTMLFile = WScript.CreateObject(&quot;HTMLFile&quot;)
Set MSWord = CreateObject(&quot;Word.Application&quot;)
Set NewDoc = MSWord.Documents.Add()
NewDoc.Activate()
MSWord.Visible = True &#039;показываем документ
ProcessStatus = True
ProcessActive = False
CurrentClipboardText = &quot;&quot;

Function PastClipboard
    Do While ProcessStatus
        If ProcessActive Then
            On Error Resume Next
            If Not (HTMLFile.parentWindow.clipboardData.getData(&quot;text&quot;) = CurrentClipboardText) Then
                If CurrentClipboardText = &quot;&quot; Then &#039;в первый заход из буфера ничего не вставляем
                    CurrentClipboardText = HTMLFile.parentWindow.clipboardData.getData(&quot;text&quot;)
                Else
                    CurrentClipboardText = HTMLFile.parentWindow.clipboardData.getData(&quot;text&quot;)
                    NewDoc.Activate()
                    MSWord.Selection.Paste()
                    MSWord.Selection.TypeParagraph()
                End If
            End If
        End If
        WScript.Sleep 100
    Loop
    MsgBox  &quot;handler stopped&quot;
End Function</code></pre></div><p>Переменные ProcessActive и ProcessStatus меняю через кнопки HTA-диалога, что позволяет включать/отключать прослушиватель и выходить из цикла.</p>]]></content>
			<author>
				<name><![CDATA[LeshikSan]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26243</uri>
			</author>
			<updated>2011-01-21T12:32:23Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=44189#p44189</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=44059#p44059" />
			<content type="html"><![CDATA[<p>Можно-ли на VBS реализовать такую тему:<br />- из файла запускается скрипт, который создает новый Word и устанавливает прослушиватель буфера обмена: все что копируется в буфер (вобщем-то нужен только текст с форматированием) автоматически вставляется в этот документ.<br />- повторный запуск файла скрипта удаляет этот прослушиватель.<br />Буду очень признателен за помощь!</p>]]></content>
			<author>
				<name><![CDATA[LeshikSan]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26243</uri>
			</author>
			<updated>2011-01-19T15:18:41Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=44059#p44059</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=44058#p44058" />
			<content type="html"><![CDATA[<p>Можно-ли на VBS реализовать такую тему:<br />- из файла запускается скрипт, который создает новый</p>]]></content>
			<author>
				<name><![CDATA[LeshikSan]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26243</uri>
			</author>
			<updated>2011-01-19T15:15:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=44058#p44058</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=34330#p34330" />
			<content type="html"><![CDATA[<p>Учитывая, что данная возможность приспособлена только для текстовых данных, то стоит работать с текстовым режимом.</p>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2010-04-01T19:18:06Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=34330#p34330</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=34329#p34329" />
			<content type="html"><![CDATA[<p>Спасибо! Работает как надо...<br />А как быть насчет других типов данных? Я пробую так:</p><div class="codebox"><pre><code>clipboard=WScript.CreateObject(&quot;HTMLFile&quot;).parentWindow.clipboardData.getData(&quot;text&quot;)

Set oADOStream = CreateObject(&quot;ADODB.Stream&quot;)
oADOStream.Mode = 3 &#039;разрешение на чтение и запись
oADOStream.Type = 1 &#039;тип данных - Binary
oADOStream.Open
oADOStream.Write clipboard
oADOStream.SaveToFile &quot;img.jpg&quot;, 2</code></pre></div><p>но в ответ 7-мая строка говорит: &quot;Аргументы имеют неверный тип, выходят за пределы допустимого диапазона или вступают в конфликт друг с другом&quot;. Есть идеи как сохранить в файл?</p>]]></content>
			<author>
				<name><![CDATA[Lucky]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25698</uri>
			</author>
			<updated>2010-04-01T18:30:20Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=34329#p34329</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=34298#p34298" />
			<content type="html"><![CDATA[<p>Надо так:<br /></p><div class="codebox"><pre><code>function GetClipboardData()
{
    return WScript.CreateObject(&quot;HTMLFile&quot;).parentWindow.clipboardData.getData(&quot;text&quot;);
}

WScript.Echo(GetClipboardData());</code></pre></div>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2010-04-01T10:55:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=34298#p34298</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Работа с буфером обмена (clipboard)]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=34288#p34288" />
			<content type="html"><![CDATA[<p>Есть примеры копирования текста в буфер обмена и наоборот - получение.</p><div class="codebox"><pre><code>&#039;Копирование текста в буфер обмена
strCopy = &quot;Этот текст будет скопирован в буфера обмена&quot;
Set objIE = CreateObject(&quot;InternetExplorer.Application&quot;)
objIE.Navigate(&quot;about:blank&quot;)
objIE.document.parentWindow.clipboardData.setData &quot;text&quot;, strCopy
objIE.Quit</code></pre></div><div class="codebox"><pre><code>&#039;Получение текста из буфера обмена
strClipboard = &quot;&quot;
Set objIE = CreateObject(&quot;InternetExplorer.Application&quot;)
objIE.Navigate(&quot;about:blank&quot;)
strClipboard = objIE.document.parentWindow.clipboardData.getData(&quot;text&quot;)
objIE.Quit
msgbox strClipboard &#039;показать содержимое буфера обмена</code></pre></div><p>Хотелось бы маневрировать не только текстовыми данными, но и картинкой, файлами... Возможно ли такое?</p><p>P.S: Нельзя ли как-нибудь обойти назойливый запрос разрешения?<br />&nbsp; &nbsp; &nbsp; &nbsp;Может есть еще другие объекты и методы работы с clipboard?</p>]]></content>
			<author>
				<name><![CDATA[Lucky]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25698</uri>
			</author>
			<updated>2010-04-01T07:59:48Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=34288#p34288</id>
		</entry>
</feed>
