<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; WSH: получение снимка с веб-камеры]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=4327&amp;type=atom" />
	<updated>2010-04-01T12:15:34Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=4327</id>
		<entry>
			<title type="html"><![CDATA[WSH: получение снимка с веб-камеры]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=34306#p34306" />
			<content type="html"><![CDATA[<p>Получение снимка с веб-камеры, используя объект <strong>WIA.DeviceManager</strong> от Microsoft.</p><p><strong>JScript</strong></p><div class="codebox"><pre><code>function CreateWebCamSnapshot(FilePath)
{
var Device = new ActiveXObject(&quot;WIA.DeviceManager&quot;),
Count = Device.DeviceInfos.Count,
oDevice, Item, Image;

for (var k=1; k&lt;=Count; k++)
    if (Device.DeviceInfos(k).Type == 3)
    {
    try
    {
        oDevice = Device.DeviceInfos(k).Connect();
        Item = oDevice.ExecuteCommand(&quot;{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}&quot;);
        Image = Item.Transfer(&quot;{557CF401-1A04-11D3-9A73-0000F81EF32E}&quot;);
        Image.SaveFile(FilePath);
    }
    catch (e) {}
    }
}

CreateWebCamSnapshot(&quot;C:\\aaa.jpg&quot;);</code></pre></div><p><strong>VBScript</strong><br /></p><div class="codebox"><pre><code>Function CreateWebCamSnapshot(FilePath)
    Dim Device, oDevice, Count, Item, Image, k
    Set Device = CreateObject(&quot;WIA.DeviceManager&quot;)
    Count = Device.DeviceInfos.Count

    On Error Resume Next
    For k=1 To Count
        if Device.DeviceInfos(k).Type = 3 Then
            Set oDevice = Device.DeviceInfos(k).Connect
            Set Item = oDevice.ExecuteCommand(&quot;{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}&quot;)
            Set Image = Item.Transfer(&quot;{557CF401-1A04-11D3-9A73-0000F81EF32E}&quot;)
            Image.SaveFile FilePath
        End if
    Next
End Function

CreateWebCamSnapshot &quot;C:\aaa.jpg&quot;</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-01T12:15:34Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=34306#p34306</id>
		</entry>
</feed>
