mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Default properties; extended samples
This commit is contained in:
@@ -1,79 +1,493 @@
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
results.push(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
// source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx
|
||||
{
|
||||
const cd = new ActiveXObject('WIA.CommonDialog');
|
||||
const dm = new ActiveXObject('WIA.DeviceManager');
|
||||
|
||||
// Convert a file
|
||||
let commonDialog = new ActiveXObject('WIA.CommonDialog');
|
||||
let img = commonDialog.ShowAcquireImage();
|
||||
// Download new items as they are created
|
||||
{
|
||||
dm.RegisterEvent(WIA.EventID.wiaEventItemCreated, WIA.Miscellaneous.wiaAnyDeviceID);
|
||||
ActiveXObject.on(dm, 'OnEvent', ['EventID', 'DeviceID', 'ItemID'], x => {
|
||||
const dev = dm.DeviceInfos(x.DeviceID).Connect();
|
||||
const itm = dev.GetItem(x.ItemID);
|
||||
const img = cd.ShowTransfer(itm);
|
||||
const v = img.FileData;
|
||||
// Picture type not available in Javascript
|
||||
});
|
||||
}
|
||||
|
||||
// when DefinitelyTyped supports Typescript 2.4 -- end of July 2017, replace these:
|
||||
let jpegFormatID = '{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}';
|
||||
if (img.FormatID !== jpegFormatID) {
|
||||
const ip = new ActiveXObject('WIA.ImageProcess');
|
||||
ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID);
|
||||
ip.Filters.Item(1).Properties.Item('FormatID').Value = jpegFormatID;
|
||||
img = ip.Apply(img);
|
||||
}
|
||||
// with this:
|
||||
/*if (img.FormatID !== WIA.FormatID.wiaFormatJPEG) {
|
||||
let ip = new ActiveXObject('WIA.ImageProcess');
|
||||
ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID);
|
||||
ip.Filters.Item(1).Properties.Item('FormatID').Value = WIA.FormatID.wiaFormatJPEG;
|
||||
img = ip.Apply(img);
|
||||
}*/
|
||||
|
||||
// Take a picture
|
||||
let dev = commonDialog.ShowSelectDevice();
|
||||
if (dev.Type === WIA.WiaDeviceType.CameraDeviceType) {
|
||||
// when DefinitelyTyped supports Typescript 2.4 -- end of July 2017, replace these:
|
||||
const commandID = '{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}';
|
||||
const itm = dev.ExecuteCommand(commandID);
|
||||
|
||||
// with this:
|
||||
// let itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture);
|
||||
}
|
||||
|
||||
// Display detailed property information
|
||||
dev = commonDialog.ShowSelectDevice();
|
||||
let e = new Enumerator<WIA.Property>(dev.Properties); // no foreach over ActiveX collections
|
||||
e.moveFirst();
|
||||
while (!e.atEnd()) {
|
||||
const p = e.item();
|
||||
let s = `${p.Name} (${p.PropertyID}) = `;
|
||||
if (p.IsVector) {
|
||||
s += '[vector of data]';
|
||||
} else {
|
||||
s += p.Value;
|
||||
if (p.SubType !== WIA.WiaSubType.UnspecifiedSubType) {
|
||||
if (p.Value !== p.SubTypeDefault) {
|
||||
s += ` (Default = ${p.SubTypeDefault})`;
|
||||
}
|
||||
// Convert a file
|
||||
{
|
||||
let img = cd.ShowAcquireImage();
|
||||
if (img && img.FormatID !== WIA.FormatID.wiaFormatJPEG) {
|
||||
const ip = new ActiveXObject('WIA.ImageProcess');
|
||||
ip.Filters.Add(ip.FilterInfos('Convert').FilterID);
|
||||
ip.Filters(1).Properties('FormatID').Value = WIA.FormatID.wiaFormatJPEG;
|
||||
img = ip.Apply(img);
|
||||
}
|
||||
}
|
||||
|
||||
if (p.IsReadOnly) {
|
||||
s += ' [READ ONLY]';
|
||||
} else {
|
||||
switch (p.SubType) {
|
||||
case WIA.WiaSubType.FlagSubType:
|
||||
case WIA.WiaSubType.ListSubType:
|
||||
if (p.SubType === WIA.WiaSubType.FlagSubType) {
|
||||
s += ' [valid flags include: ';
|
||||
// Take a picture
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev && dev.Type === WIA.WiaDeviceType.CameraDeviceType) {
|
||||
const item = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture);
|
||||
}
|
||||
}
|
||||
|
||||
// Display detailed property information
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Properties).forEach(p => {
|
||||
let s = `${p.Name} (${p.PropertyID}) = `;
|
||||
if (p.IsVector) {
|
||||
s += '[vector of data]';
|
||||
} else {
|
||||
s += ' [valid values include: ';
|
||||
}
|
||||
const count = p.SubTypeValues.Count;
|
||||
for (let i = 1; i <= count; i++) {
|
||||
s += p.SubTypeValues.Item(i);
|
||||
if (i < count) {
|
||||
s += ', ';
|
||||
s += p.Value;
|
||||
if (p.SubType !== WIA.WiaSubType.UnspecifiedSubType
|
||||
&& p.Value !== p.SubTypeDefault) {
|
||||
s += ` (Default = ${p.SubTypeDefault})`;
|
||||
}
|
||||
}
|
||||
s += ']';
|
||||
break;
|
||||
case WIA.WiaSubType.RangeSubType:
|
||||
s += ` [valid values in the range from ${p.SubTypeMin} to ${p.SubTypeMax} in increments of ${p.SubTypeStep}]`;
|
||||
break;
|
||||
|
||||
if (p.IsReadOnly) {
|
||||
s += ' [READ ONLY]';
|
||||
} else {
|
||||
switch (p.SubType) {
|
||||
case WIA.WiaSubType.FlagSubType:
|
||||
case WIA.WiaSubType.ListSubType:
|
||||
const count = p.SubTypeValues.Count;
|
||||
const items: string[] = [];
|
||||
for (let i = 1; i <= count; i++) {
|
||||
items.push(p.SubTypeValues(i));
|
||||
}
|
||||
const descr = p.SubType === WIA.WiaSubType.FlagSubType ? 'flags' : 'values';
|
||||
s += ` [valid ${descr} include: ${items.join(',')}]`;
|
||||
break;
|
||||
case WIA.WiaSubType.RangeSubType:
|
||||
s += ` [valid values in the range from ${p.SubTypeMin} to ${p.SubTypeMax} in increments of ${p.SubTypeStep}]`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
WScript.Echo(s);
|
||||
// Determine whether the selected device is a camera
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev && dev.Type === WIA.WiaDeviceType.CameraDeviceType) {
|
||||
WScript.Echo('Selectd device is a camera');
|
||||
}
|
||||
}
|
||||
|
||||
// Count root - level images for transfer
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
const count = collectionToArray(dev.Items).filter(f => {
|
||||
const imageFlag = WIA.WiaItemFlag.ImageItemFlag;
|
||||
return (f.Properties('Item Flags').Value & imageFlag) === imageFlag;
|
||||
}).length;
|
||||
WScript.Echo(`Selected device has ${count} top-level images`);
|
||||
}
|
||||
}
|
||||
|
||||
// Display all imagefile properties
|
||||
{
|
||||
const img = cd.ShowAcquireImage();
|
||||
if (img) {
|
||||
collectionToArray(img.Properties).forEach(p => {
|
||||
let contents = '';
|
||||
if (p.IsVector) {
|
||||
contents = '[vector data not emitted]';
|
||||
} else if (p.Type === WIA.WiaImagePropertyType.RationalImagePropertyType) {
|
||||
contents = `${p.Value.Nunerator}/${p.Value.Denominator}`;
|
||||
} else if (p.Type === WIA.WiaImagePropertyType.StringImagePropertyType) {
|
||||
contents = `"${p.Value}"`;
|
||||
} else {
|
||||
contents = p.Value;
|
||||
}
|
||||
WScript.Echo(`${p.Name} (${p.PropertyID}) = ${contents}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the event type
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
const actionEvent = WIA.WiaEventFlag.ActionEvent;
|
||||
collectionToArray(dev.Events).forEach(e => {
|
||||
const msg = (e.Type & actionEvent) === actionEvent ?
|
||||
`${e.Name} is an Action event` :
|
||||
`${e.Name} is not an Action event`;
|
||||
WScript.Echo(msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Set rational numerator and denominator
|
||||
{
|
||||
const r = new ActiveXObject('WIA.Rational');
|
||||
r.Numerator = 1;
|
||||
r.Denominator = 3;
|
||||
WScript.Echo(`1/3 = ${r.Value}`);
|
||||
r.Numerator = 2;
|
||||
r.Denominator = 6;
|
||||
WScript.Echo(`2/6 = ${r.Value}`);
|
||||
}
|
||||
|
||||
// Create and initialize a vector object
|
||||
{
|
||||
const v: WIA.Vector<number> = new ActiveXObject('WIA.Vector');
|
||||
v.SetFromString('This is a test', true, false);
|
||||
collectionToArray(v).forEach(chr => WScript.Echo(String.fromCharCode(chr)));
|
||||
}
|
||||
|
||||
// Display detailed image information
|
||||
{
|
||||
const img = new ActiveXObject('WIA.ImageFile');
|
||||
img.LoadFile('c:\\windows\\web\\Screen\\img102.jpg');
|
||||
|
||||
let s = `
|
||||
Width = ${img.Width}
|
||||
Height = ${img.Height}
|
||||
Depth = ${img.PixelDepth}
|
||||
Horizontal resolution = ${img.HorizontalResolution}
|
||||
Vertical resolution = ${img.VerticalResolution}
|
||||
Frame count = ${img.FrameCount}}
|
||||
`.trim();
|
||||
|
||||
let arr: string[] = [];
|
||||
|
||||
if (img.IsIndexedPixelFormat) { arr.push('Pixel data contains palette indexes'); }
|
||||
if (img.IsAlphaPixelFormat) { arr.push('Pixel data has alpha information'); }
|
||||
if (img.IsExtendedPixelFormat) { arr.push('Pixel data has extended color information (16 bit/channel)'); }
|
||||
if (img.IsAnimated) { arr.push('Image is animated'); }
|
||||
|
||||
const propertyTests = [40091, 40092, 40093, 40094, 40095]
|
||||
.filter(n => img.Properties.Exists(n))
|
||||
.map(n => {
|
||||
const prp = img.Properties(n);
|
||||
return `${prp.Name} = ${prp.Value.String}`;
|
||||
});
|
||||
arr = arr.concat(propertyTests);
|
||||
|
||||
if (arr.length) {
|
||||
s += '\n' + arr.join('\n');
|
||||
}
|
||||
|
||||
WScript.Echo(s);
|
||||
}
|
||||
|
||||
// Create an imageprocess object and enumerate filters
|
||||
{
|
||||
const ip = new ActiveXObject('WIA.ImageProcess');
|
||||
collectionToArray(ip.FilterInfos).forEach(fi => {
|
||||
const s = [
|
||||
fi.Name,
|
||||
new Array(51).join('='),
|
||||
fi.Description
|
||||
].join('\n');
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
|
||||
// Create an imageprocess object and create one of each available filter
|
||||
{
|
||||
const ip = new ActiveXObject('WIA.ImageProcess');
|
||||
|
||||
const stringValue = (v: any) => {
|
||||
if (typeof v === 'string') { return `"${v}"`; }
|
||||
return v;
|
||||
};
|
||||
|
||||
const listValues = (v: any) => collectionToArray(v).join(', ');
|
||||
|
||||
const listProperties = (filter: WIA.Filter) => {
|
||||
let s = [
|
||||
`${filter.Name} (${filter.FilterID})`,
|
||||
new Array(51).join('='),
|
||||
filter.Description,
|
||||
new Array(51).join('=')
|
||||
].map(line => line + '\n').join('');
|
||||
|
||||
s += collectionToArray(filter.Properties).map(p => {
|
||||
let contents: string;
|
||||
|
||||
switch (typeof p.Value) {
|
||||
// these case clauses replace the IsObject function in VB6/VBScript
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'number':
|
||||
contents = stringValue(p.Value);
|
||||
default:
|
||||
switch (p.SubType) {
|
||||
case WIA.WiaSubType.FlagSubType:
|
||||
contents = ` // [valid values formed by using the OR operator with the following bit flags: ${listValues(p.SubTypeValues)}]`;
|
||||
break;
|
||||
case WIA.WiaSubType.ListSubType:
|
||||
contents = ` // [valid values from the following list: ${listValues(p.SubTypeValues)}]`;
|
||||
break;
|
||||
case WIA.WiaSubType.RangeSubType:
|
||||
contents = ` // [valid values between ${p.SubTypeMin} and ${p.SubTypeMax}, with a step of ${p.SubTypeStep}]`;
|
||||
break;
|
||||
default:
|
||||
contents = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return `ip.Filters(1).Properties("${p.Name}") = ${contents}`;
|
||||
}).join('\n');
|
||||
|
||||
WScript.Echo(s);
|
||||
};
|
||||
|
||||
collectionToArray(ip.FilterInfos).forEach(fi => {
|
||||
ip.Filters.Add(fi.FilterID);
|
||||
listProperties(ip.Filters(1));
|
||||
ip.Filters.Remove(1);
|
||||
});
|
||||
}
|
||||
|
||||
// List the supported transfer formats
|
||||
{
|
||||
const stringFormat = (fld: string) => {
|
||||
switch (fld) {
|
||||
case WIA.FormatID.wiaFormatBMP: return 'BMP';
|
||||
case WIA.FormatID.wiaFormatPNG: return 'PNG';
|
||||
case WIA.FormatID.wiaFormatGIF: return 'GIF';
|
||||
case WIA.FormatID.wiaFormatJPEG: return 'JPEG';
|
||||
case WIA.FormatID.wiaFormatTIFF: return 'TIFF';
|
||||
default: return 'Unknown';
|
||||
}
|
||||
};
|
||||
|
||||
const dev = cd.ShowSelectDevice();
|
||||
const items = dev && cd.ShowSelectItems(dev, WIA.WiaImageIntent.UnspecifiedIntent, WIA.WiaImageBias.MaximizeQuality, true);
|
||||
if (items) {
|
||||
WScript.Echo(collectionToArray(items(1).Formats).map(stringFormat).join(', '));
|
||||
}
|
||||
}
|
||||
|
||||
// Enumerate supported commands in commands collection
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev && collectionToArray(dev.Commands).some(dc => dc.CommandID === WIA.CommandID.wiaCommandTakePicture)) {
|
||||
WScript.Echo('Selected device supports the TakePicture command');
|
||||
}
|
||||
}
|
||||
|
||||
// Enumerate root - level items and display their names
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Items).forEach(item => {
|
||||
let s: string = item.Properties("Item Name").Value;
|
||||
if (item.Properties.Exists("Item Time Stamp")) {
|
||||
const v: WIA.Vector = item.Properties("Item Time Stamp").Value;
|
||||
if (v.Count === 8) { s += ` (${v.Date})`; }
|
||||
}
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the number of items returned by ShowSelectItems
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
const items = dev && cd.ShowSelectItems(dev, WIA.WiaImageIntent.UnspecifiedIntent, WIA.WiaImageBias.MaximizeQuality, true);
|
||||
if (items) {
|
||||
WScript.Echo(`You selected ${items.Count} items`);
|
||||
}
|
||||
}
|
||||
|
||||
// Enumerate all the supported events for the selected device
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
const msg = collectionToArray(dev.Events)
|
||||
.map(e => `\n${e.Name} (${e.EventID}): ${e.Description}`)
|
||||
.join('');
|
||||
WScript.Echo('The selected device supports the following events: ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
// List all available devices by name and deviceid
|
||||
collectionToArray(dm.DeviceInfos).forEach(di => {
|
||||
const name: string = di.Properties("Name").Value;
|
||||
WScript.Echo(`${name} (${di.DeviceID})`);
|
||||
});
|
||||
|
||||
// Display all the properties for the selected device
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Properties).forEach(p => {
|
||||
const name = `${p.Name} (${p.PropertyID})`;
|
||||
let contents: string;
|
||||
if (p.IsVector) {
|
||||
contents = '[vector of data]';
|
||||
} else if (p.Type === WIA.WiaPropertyType.StringPropertyType) {
|
||||
contents = `"${p.Value}"`;
|
||||
} else {
|
||||
contents = p.Value;
|
||||
}
|
||||
WScript.Echo(`${name} = ${contents}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Enumerate the supported commands
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
const items = dev && cd.ShowSelectItems(dev, WIA.WiaImageIntent.UnspecifiedIntent, WIA.WiaImageBias.MaximizeQuality, true);
|
||||
if (items) {
|
||||
const msg = collectionToArray(items(1).Commands)
|
||||
.map(c => `${c.Name}: ${c.Description}\n`)
|
||||
.join('');
|
||||
WScript.Echo(`The selected item supports the following commands:\n${msg}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Create an imagefile object that contains a blank page
|
||||
{
|
||||
const c = 0xFF0000FF;
|
||||
const v: WIA.Vector<number> = new ActiveXObject('WIA.Vector');
|
||||
for (let i = 0; i < 4; i++) {
|
||||
v.Add(c);
|
||||
}
|
||||
const img = v.ImageFile(2, 2);
|
||||
img.SaveFile('C:\\test.' + img.FileExtension);
|
||||
}
|
||||
|
||||
interface WshArgumentsBase<TKey = number | string> {
|
||||
Item(index: TKey): string;
|
||||
(index: TKey): string;
|
||||
length: number;
|
||||
Count(): number;
|
||||
}
|
||||
|
||||
interface WshArguments extends WshArgumentsBase { // not sure if WshArguments takes a string as well, or only a number
|
||||
Named: WshArgumentsBase<string>;
|
||||
Unnamed: WshArgumentsBase<number>;
|
||||
ShowUsage(): void;
|
||||
}
|
||||
|
||||
// Implement a windows script host script that runs automatically
|
||||
{
|
||||
const args = collectionToArray(WScript.Arguments as WshArguments)
|
||||
.map(arg => arg.toLowerCase());
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
case 2:
|
||||
const command = `${WScript.FullName} "${WScript.ScriptFullName}" connect`;
|
||||
const name = 'QuickTransfer';
|
||||
const title = 'Quick Scripting Transfer';
|
||||
const icon = `${WScript.FullName}, 0`;
|
||||
const eventID = WIA.EventID.wiaEventDeviceConnected;
|
||||
const deviceID = args.length === 2 ? args[1] : WIA.Miscellaneous.wiaAnyDeviceID;
|
||||
|
||||
if (args[0] === 'register') {
|
||||
WScript.Echo('Registering event handler');
|
||||
dm.RegisterPersistentEvent(command, name, title, icon, eventID, deviceID);
|
||||
WScript.Quit();
|
||||
} else if (args[0] === 'unregister') {
|
||||
WScript.Echo('Unregistering event handler');
|
||||
dm.UnregisterPersistentEvent(command, name, title, icon, eventID, deviceID);
|
||||
WScript.Quit();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (args[0] === 'connect') {
|
||||
const deviceID = args[1].substr(12);
|
||||
const device = dm.DeviceInfos(deviceID).Connect();
|
||||
collectionToArray(device.Items).forEach(item => {
|
||||
const img = item.Transfer();
|
||||
img.SaveFile(`C:\\${item.Properties('Item Name').Value}.${img.FileExtension}`);
|
||||
|
||||
// Uncomment the following lines to remove the picture from the camera after transfer
|
||||
for (let i = 1; i < device.Items.Count; i++) {
|
||||
const item2 = device.Items(i);
|
||||
if (item2.ItemID !== item.ItemID) { continue; }
|
||||
try {
|
||||
// some cameras don't support deleting a picture
|
||||
device.Items.Remove(i);
|
||||
} catch (error) {
|
||||
WScript.Echo(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
WScript.Quit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
const usage = `
|
||||
Usage:
|
||||
|
||||
To register, type:
|
||||
|
||||
${WScript.ScriptName} register [<device id>]
|
||||
|
||||
To unregister, type:
|
||||
|
||||
${WScript.ScriptName} unregister [<device id>]
|
||||
|
||||
Available device ids:
|
||||
${collectionToArray(dm.DeviceInfos)
|
||||
.map(device => `${device.DeviceID} '${device.Properties("Name").Value}'`)
|
||||
.join('\n')}
|
||||
`.trim();
|
||||
|
||||
WScript.Echo(usage);
|
||||
}
|
||||
|
||||
// Count the number of child items available for transfer
|
||||
{
|
||||
const device = cd.ShowSelectDevice();
|
||||
const items = device && cd.ShowSelectItems(device, WIA.WiaImageIntent.UnspecifiedIntent, WIA.WiaImageBias.MaximizeQuality, true);
|
||||
const item = items && items(1);
|
||||
if (item) {
|
||||
const count = collectionToArray(item.Items).filter(childItem => {
|
||||
const flags = childItem.Properties('Item Flags').Value as number;
|
||||
return (flags & WIA.WiaItemFlag.TransferItemFlag) === WIA.WiaItemFlag.TransferItemFlag;
|
||||
}).length;
|
||||
WScript.Echo(`Selected device has ${count} child items that can be transferred.`);
|
||||
}
|
||||
}
|
||||
|
||||
// Use a vector object
|
||||
{
|
||||
const v: WIA.Vector<number | string> = new ActiveXObject('WIA.Vector');
|
||||
v.Add(1);
|
||||
v.Add(42);
|
||||
v.Add(3);
|
||||
v.Remove(1);
|
||||
v.Remove(2);
|
||||
WScript.Echo(`v(1) = ${v(1)}`);
|
||||
v.Clear();
|
||||
v.Add('This');
|
||||
v.Add('is');
|
||||
v.Add('Cool');
|
||||
v.Remove(1);
|
||||
v.Remove(2);
|
||||
WScript.Echo(`v(1) = ${v(1)}`);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+208
-148
@@ -2,22 +2,22 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630368(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Typescript Version: 2.4
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
declare namespace WIA {
|
||||
/** String versions of globally unique identifiers (GUIDs) that identify common Device and Item commands. */
|
||||
// uncomment when DefinitelyTyped supports Typescript 2.4 (end of July 2017)
|
||||
/*const enum CommandID {
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum CommandID {
|
||||
wiaCommandChangeDocument = '{04E725B0-ACAE-11D2-A093-00C04F72DC3C}',
|
||||
wiaCommandDeleteAllItems = '{E208C170-ACAD-11D2-A093-00C04F72DC3C}',
|
||||
wiaCommandSynchronize = '{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}',
|
||||
wiaCommandTakePicture = '{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}',
|
||||
wiaCommandUnloadDocument = '{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}'
|
||||
}*/
|
||||
wiaCommandUnloadDocument = '{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}',
|
||||
}
|
||||
|
||||
/** String versions of globally unique identifiers (GUIDs) that identify DeviceManager events. */
|
||||
// uncomment when DefinitelyTyped supports Typescript 2.4 (end of July 2017)
|
||||
/*const enum EventID {
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum EventID {
|
||||
wiaEventDeviceConnected = '{A28BBADE-64B6-11D2-A231-00C04FA31809}',
|
||||
wiaEventDeviceDisconnected = '{143E4E83-6497-11D2-A231-00C04FA31809}',
|
||||
wiaEventItemCreated = '{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}',
|
||||
@@ -30,64 +30,69 @@ declare namespace WIA {
|
||||
wiaEventScanImage3 = '{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}',
|
||||
wiaEventScanImage4 = '{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}',
|
||||
wiaEventScanOCRImage = '{9D095B89-37D6-4877-AFED-62A297DC6DBE}',
|
||||
wiaEventScanPrintImage = '{B441F425-8C6E-11D2-977A-0000F87A926F}'
|
||||
}*/
|
||||
wiaEventScanPrintImage = '{B441F425-8C6E-11D2-977A-0000F87A926F}',
|
||||
}
|
||||
|
||||
/** String versions of globally unique identifiers (GUIDs) that indicate the file format of an image. */
|
||||
// uncomment when DefinitelyTyped supports Typescript 2.4 (end of July 2017)
|
||||
/*const enum FormatID {
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum FormatID {
|
||||
wiaFormatBMP = '{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}',
|
||||
wiaFormatGIF = '{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}',
|
||||
wiaFormatJPEG = '{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}',
|
||||
wiaFormatPNG = '{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}',
|
||||
wiaFormatTIFF = '{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}'
|
||||
}*/
|
||||
wiaFormatTIFF = '{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}',
|
||||
}
|
||||
|
||||
/** Miscellaneous string constants */
|
||||
// uncomment when DefinitelyTyped supports Typescript 2.4 (end of July 2017)
|
||||
/*const enum Miscellaneous {
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum Miscellaneous {
|
||||
wiaAnyDeviceID = '*',
|
||||
wiaIDUnknown = '{00000000-0000-0000-0000-000000000000}'
|
||||
}*/
|
||||
wiaIDUnknown = '{00000000-0000-0000-0000-000000000000}',
|
||||
}
|
||||
|
||||
/**
|
||||
* The WiaDeviceType enumeration specifies the type of device attached to a user's computer. Use the Type property on the DeviceInfo object or the Device
|
||||
* object to obtain these values from the device.
|
||||
* object to obtain these values from the device.
|
||||
*/
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaDeviceType {
|
||||
CameraDeviceType = 2,
|
||||
ScannerDeviceType = 1,
|
||||
UnspecifiedDeviceType = 0,
|
||||
VideoDeviceType = 3
|
||||
VideoDeviceType = 3,
|
||||
}
|
||||
|
||||
/**
|
||||
* A DeviceEvent's type is composed of bits from the WiaEventFlags enumeration. You can test a DeviceEvent's type by using the AND operation with DeviceEv
|
||||
* ent.Type and a member from the WiaEventFlags enumeration.
|
||||
* A DeviceEvent's type is composed of bits from the WiaEventFlags enumeration. You can test a DeviceEvent's type by using the AND operation with
|
||||
* DeviceEvent.Type and a member from the WiaEventFlags enumeration.
|
||||
*/
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaEventFlag {
|
||||
ActionEvent = 2,
|
||||
NotificationEvent = 1
|
||||
NotificationEvent = 1,
|
||||
}
|
||||
|
||||
/** The WiaImageBias enumeration helps specify what type of data the image is intended to represent. */
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaImageBias {
|
||||
MaximizeQuality = 131072,
|
||||
MinimizeSize = 65536
|
||||
MinimizeSize = 65536,
|
||||
}
|
||||
|
||||
/** The WiaImageIntent enumeration helps specify what type of data the image is intended to represent. */
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaImageIntent {
|
||||
ColorIntent = 1,
|
||||
GrayscaleIntent = 2,
|
||||
TextIntent = 4,
|
||||
UnspecifiedIntent = 0
|
||||
UnspecifiedIntent = 0,
|
||||
}
|
||||
|
||||
/**
|
||||
* The WiaImagePropertyType enumeration specifies the type of the value of an image property. Image properties can be found in the Properties collection o
|
||||
* f an ImageFile object.
|
||||
* The WiaImagePropertyType enumeration specifies the type of the value of an image property. Image properties can be found in the Properties collection
|
||||
* of an ImageFile object.
|
||||
*/
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaImagePropertyType {
|
||||
ByteImagePropertyType = 1001,
|
||||
LongImagePropertyType = 1004,
|
||||
@@ -103,13 +108,14 @@ declare namespace WIA {
|
||||
VectorOfUndefinedImagePropertyType = 1100,
|
||||
VectorOfUnsignedIntegersImagePropertyType = 1102,
|
||||
VectorOfUnsignedLongsImagePropertyType = 1104,
|
||||
VectorOfUnsignedRationalsImagePropertyType = 1106
|
||||
VectorOfUnsignedRationalsImagePropertyType = 1106,
|
||||
}
|
||||
|
||||
/**
|
||||
* An Item's type is composed of bits from the WiaItemFlags enumeration. You can test an Item's type by using the AND operation with Item.Properties("Item
|
||||
* Flags") and a member from the WiaItemFlags enumeration.
|
||||
* An Item's type is composed of bits from the WiaItemFlags enumeration. You can test an Item's type by using the AND operation with
|
||||
* Item.Properties("Item Flags") and a member from the WiaItemFlags enumeration.
|
||||
*/
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaItemFlag {
|
||||
AnalyzeItemFlag = 16,
|
||||
AudioItemFlag = 32,
|
||||
@@ -129,13 +135,14 @@ declare namespace WIA {
|
||||
StorageItemFlag = 4096,
|
||||
TransferItemFlag = 8192,
|
||||
VideoItemFlag = 65536,
|
||||
VPanoramaItemFlag = 1024
|
||||
VPanoramaItemFlag = 1024,
|
||||
}
|
||||
|
||||
/**
|
||||
* The WiaPropertyType enumeration specifies the type of the value of an item property. Item properties can be found in the Properties collection of a Dev
|
||||
* ice or Item object.
|
||||
* The WiaPropertyType enumeration specifies the type of the value of an item property. Item properties can be found in the Properties collection of a
|
||||
* Device or Item object.
|
||||
*/
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaPropertyType {
|
||||
BooleanPropertyType = 1,
|
||||
BytePropertyType = 2,
|
||||
@@ -173,28 +180,32 @@ declare namespace WIA {
|
||||
VectorOfUnsignedIntegersPropertyType = 104,
|
||||
VectorOfUnsignedLargeIntegersPropertyType = 109,
|
||||
VectorOfUnsignedLongsPropertyType = 106,
|
||||
VectorOfVariantsPropertyType = 119
|
||||
VectorOfVariantsPropertyType = 119,
|
||||
}
|
||||
|
||||
/**
|
||||
* The WiaSubType enumeration specifies more detail about the property value. Use the SubType property on the Property object to obtain these values for t
|
||||
* he property.
|
||||
* The WiaSubType enumeration specifies more detail about the property value. Use the SubType property on the Property object to obtain these values for
|
||||
* the property.
|
||||
*/
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WiaSubType {
|
||||
FlagSubType = 3,
|
||||
ListSubType = 2,
|
||||
RangeSubType = 1,
|
||||
UnspecifiedSubType = 0
|
||||
UnspecifiedSubType = 0,
|
||||
}
|
||||
|
||||
/**
|
||||
* The CommonDialog control is an invisible-at-runtime control that contains all the methods that display a User Interface. A CommonDialog control can be
|
||||
* created using "WIA.CommonDialog" in a call to CreateObject or by dropping a CommonDialog on a form.
|
||||
* created using "WIA.CommonDialog" in a call to CreateObject or by dropping a CommonDialog on a form.
|
||||
*/
|
||||
interface CommonDialog {
|
||||
class CommonDialog {
|
||||
private constructor();
|
||||
private 'WIA.CommonDialog_typekey': CommonDialog;
|
||||
|
||||
/**
|
||||
* Displays one or more dialog boxes that enable the user to acquire an image from a hardware device for image acquisition and returns an ImageFile object
|
||||
* on success, otherwise Nothing
|
||||
* Displays one or more dialog boxes that enable the user to acquire an image from a hardware device for image acquisition and returns an ImageFile
|
||||
* object on success, otherwise Nothing
|
||||
* @param WIA.WiaDeviceType [DeviceType=0]
|
||||
* @param WIA.WiaImageIntent [Intent=0]
|
||||
* @param WIA.WiaImageBias [Bias=131072]
|
||||
@@ -203,11 +214,11 @@ declare namespace WIA {
|
||||
* @param boolean [UseCommonUI=true]
|
||||
* @param boolean [CancelError=false]
|
||||
*/
|
||||
ShowAcquireImage(
|
||||
DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean): ImageFile;
|
||||
ShowAcquireImage(DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean,
|
||||
CancelError?: boolean): ImageFile | null;
|
||||
|
||||
/** Launches the Windows Scanner and Camera Wizard and returns Nothing. Future versions may return a collection of ImageFile objects. */
|
||||
ShowAcquisitionWizard(Device: Device): any;
|
||||
ShowAcquisitionWizard(Device: Device): null;
|
||||
|
||||
/**
|
||||
* Displays the properties dialog box for the specified Device
|
||||
@@ -222,38 +233,41 @@ declare namespace WIA {
|
||||
ShowItemProperties(Item: Item, CancelError?: boolean): void;
|
||||
|
||||
/** Launches the Photo Printing Wizard with the absolute path of a specific file or Vector of absolute paths to files */
|
||||
ShowPhotoPrintingWizard(Files: any): void;
|
||||
ShowPhotoPrintingWizard(Files: string | Vector<string>): void;
|
||||
|
||||
/**
|
||||
* Displays a dialog box that enables the user to select a hardware device for image acquisition. Returns the selected Device object on success, otherwise
|
||||
* Nothing
|
||||
* Displays a dialog box that enables the user to select a hardware device for image acquisition. Returns the selected Device object on success,
|
||||
* otherwise Nothing
|
||||
* @param WIA.WiaDeviceType [DeviceType=0]
|
||||
* @param boolean [AlwaysSelectDevice=false]
|
||||
* @param boolean [CancelError=false]
|
||||
*/
|
||||
ShowSelectDevice(DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean): Device;
|
||||
ShowSelectDevice(DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean): Device | null;
|
||||
|
||||
/**
|
||||
* Displays a dialog box that enables the user to select an item for transfer from a hardware device for image acquisition. Returns the selection as an It
|
||||
* ems collection on success, otherwise Nothing
|
||||
* Displays a dialog box that enables the user to select an item for transfer from a hardware device for image acquisition. Returns the selection as an
|
||||
* Items collection on success, otherwise Nothing
|
||||
* @param WIA.WiaImageIntent [Intent=0]
|
||||
* @param WIA.WiaImageBias [Bias=131072]
|
||||
* @param boolean [SingleSelect=true]
|
||||
* @param boolean [UseCommonUI=true]
|
||||
* @param boolean [CancelError=false]
|
||||
*/
|
||||
ShowSelectItems(Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean): Items;
|
||||
ShowSelectItems(Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean): Items | null;
|
||||
|
||||
/**
|
||||
* Displays a progress dialog box while transferring the specified Item to the local machine. See Item.Transfer for additional information.
|
||||
* @param string [FormatID='{00000000-0000-0000-0000-000000000000}']
|
||||
* @param boolean [CancelError=false]
|
||||
*/
|
||||
ShowTransfer(Item: Item, FormatID?: string, CancelError?: boolean): any;
|
||||
ShowTransfer(Item: Item, FormatID?: string, CancelError?: boolean): ImageFile;
|
||||
}
|
||||
|
||||
/** The Device object represents an active connection to an imaging device. */
|
||||
interface Device {
|
||||
class Device {
|
||||
private constructor();
|
||||
private 'WIA.Device_typekey': Device;
|
||||
|
||||
/** A collection of all commands for this imaging device */
|
||||
readonly Commands: DeviceCommands;
|
||||
|
||||
@@ -264,8 +278,8 @@ declare namespace WIA {
|
||||
readonly Events: DeviceEvents;
|
||||
|
||||
/**
|
||||
* Issues the command specified by CommandID to the imaging device. CommandIDs are device dependent. Valid CommandIDs for this Device are contained in the
|
||||
* Commands collection.
|
||||
* Issues the command specified by CommandID to the imaging device. CommandIDs are device dependent. Valid CommandIDs for this Device are contained in
|
||||
* the Commands collection.
|
||||
*/
|
||||
ExecuteCommand(CommandID: string): Item;
|
||||
|
||||
@@ -280,13 +294,13 @@ declare namespace WIA {
|
||||
|
||||
/** Returns the Type of Device */
|
||||
readonly Type: WiaDeviceType;
|
||||
|
||||
/** Returns the underlying IWiaItem interface for this Device object */
|
||||
readonly WiaItem: any;
|
||||
}
|
||||
|
||||
/** The DeviceCommand object describes a CommandID that can be used when calling ExecuteCommand on a Device or Item object. */
|
||||
interface DeviceCommand {
|
||||
class DeviceCommand {
|
||||
private constructor();
|
||||
private 'WIA.DeviceCommand_typekey': DeviceCommand;
|
||||
|
||||
/** Returns the commandID for this Command */
|
||||
readonly CommandID: string;
|
||||
|
||||
@@ -298,8 +312,8 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The DeviceCommands object is a collection of all the supported DeviceCommands for an imaging device. See the Commands property of a Device or Item obje
|
||||
* ct for more details on determining the collection of supported device commands.
|
||||
* The DeviceCommands object is a collection of all the supported DeviceCommands for an imaging device. See the Commands property of a Device or Item
|
||||
* object for more details on determining the collection of supported device commands.
|
||||
*/
|
||||
interface DeviceCommands {
|
||||
/** Returns the number of members in the collection */
|
||||
@@ -307,10 +321,16 @@ declare namespace WIA {
|
||||
|
||||
/** Returns the specified item in the collection by position */
|
||||
Item(Index: number): DeviceCommand;
|
||||
|
||||
/** Returns the specified item in the collection by position */
|
||||
(Index: number): DeviceCommand;
|
||||
}
|
||||
|
||||
/** The DeviceEvent object describes an EventID that can be used when calling RegisterEvent or RegisterPersistentEvent on a DeviceManager object. */
|
||||
interface DeviceEvent {
|
||||
class DeviceEvent {
|
||||
private constructor();
|
||||
private 'WIA.DeviceEvent_typekey': DeviceEvent;
|
||||
|
||||
/** Returns the event Description */
|
||||
readonly Description: string;
|
||||
|
||||
@@ -325,8 +345,8 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The DeviceEvents object is a collection of all the supported DeviceEvent for an imaging device. See the Events property of a Device object for more det
|
||||
* ails on determining the collection of supported device events.
|
||||
* The DeviceEvents object is a collection of all the supported DeviceEvent for an imaging device. See the Events property of a Device object for more
|
||||
* details on determining the collection of supported device events.
|
||||
*/
|
||||
interface DeviceEvents {
|
||||
/** Returns the number of members in the collection */
|
||||
@@ -334,13 +354,19 @@ declare namespace WIA {
|
||||
|
||||
/** Returns the specified item in the collection by position */
|
||||
Item(Index: number): DeviceEvent;
|
||||
|
||||
/** Returns the specified item in the collection by position */
|
||||
(Index: number): DeviceEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* The DeviceInfo object is a container that describes the unchanging (static) properties of an imaging device that is currently connected to the computer
|
||||
* .
|
||||
* The DeviceInfo object is a container that describes the unchanging (static) properties of an imaging device that is currently connected to the
|
||||
* computer.
|
||||
*/
|
||||
interface DeviceInfo {
|
||||
class DeviceInfo {
|
||||
private constructor();
|
||||
private 'WIA.DeviceInfo_typekey': DeviceInfo;
|
||||
|
||||
/** Establish a connection with this device and return a Device object */
|
||||
Connect(): Device;
|
||||
|
||||
@@ -355,59 +381,68 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The DeviceInfos object is a collection of all the imaging devices currently connected to the computer. See the DeviceInfos property on the DeviceManage
|
||||
* r object for detail on accessing the DeviceInfos object.
|
||||
* The DeviceInfos object is a collection of all the imaging devices currently connected to the computer. See the DeviceInfos property on the
|
||||
* DeviceManager object for detail on accessing the DeviceInfos object.
|
||||
*/
|
||||
interface DeviceInfos {
|
||||
/** Returns the number of members in the collection */
|
||||
readonly Count: number;
|
||||
|
||||
/** Returns the specified item in the collection either by position or Device ID */
|
||||
Item(Index: any): DeviceInfo;
|
||||
Item(Index: number | string): DeviceInfo;
|
||||
|
||||
/** Returns the specified item in the collection either by position or Device ID */
|
||||
(Index: number | string): DeviceInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* The DeviceManager control is an invisible-at-runtime control that manages the imaging devices connected to the computer. A DeviceManager control can be
|
||||
* created using "WIA.DeviceManager" in a call to CreateObject or by dropping a DeviceManager on a form.
|
||||
* The DeviceManager control is an invisible-at-runtime control that manages the imaging devices connected to the computer. A DeviceManager control can
|
||||
* be created using "WIA.DeviceManager" in a call to CreateObject or by dropping a DeviceManager on a form.
|
||||
*/
|
||||
interface DeviceManager {
|
||||
class DeviceManager {
|
||||
private constructor();
|
||||
private 'WIA.DeviceManager_typekey': DeviceManager;
|
||||
|
||||
/** A collection of all imaging devices connected to this computer */
|
||||
readonly DeviceInfos: DeviceInfos;
|
||||
|
||||
/**
|
||||
* Registers the specified EventID for the specified DeviceID. If DeviceID is "*" then OnEvent will be called whenever the event specified occurs for any
|
||||
* device. Otherwise, OnEvent will only be called if the event specified occurs on the device specified.
|
||||
* device. Otherwise, OnEvent will only be called if the event specified occurs on the device specified.
|
||||
* @param string [DeviceID='*']
|
||||
*/
|
||||
RegisterEvent(EventID: string, DeviceID?: string): void;
|
||||
|
||||
/**
|
||||
* Registers the specified Command to launch when the specified EventID for the specified DeviceID occurs. Command can be either a ClassID or the full pat
|
||||
* h name and the appropriate command-line arguments needed to invoke the application.
|
||||
* Registers the specified Command to launch when the specified EventID for the specified DeviceID occurs. Command can be either a ClassID or the full
|
||||
* path name and the appropriate command-line arguments needed to invoke the application.
|
||||
* @param string [DeviceID='*']
|
||||
*/
|
||||
RegisterPersistentEvent(Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string): void;
|
||||
|
||||
/**
|
||||
* Unregisters the specified EventID for the specified DeviceID. UnregisterEvent should only be called for EventID and DeviceID for which you called Regis
|
||||
* terEvent.
|
||||
* Unregisters the specified EventID for the specified DeviceID. UnregisterEvent should only be called for EventID and DeviceID for which you called
|
||||
* RegisterEvent.
|
||||
* @param string [DeviceID='*']
|
||||
*/
|
||||
UnregisterEvent(EventID: string, DeviceID?: string): void;
|
||||
|
||||
/**
|
||||
* Unregisters the specified Command for the specified EventID for the specified DeviceID. UnregisterPersistentEvent should only be called for the Command
|
||||
* , Name, Description, Icon, EventID and DeviceID for which you called RegisterPersistentEvent.
|
||||
* Unregisters the specified Command for the specified EventID for the specified DeviceID. UnregisterPersistentEvent should only be called for the
|
||||
* Command, Name, Description, Icon, EventID and DeviceID for which you called RegisterPersistentEvent.
|
||||
* @param string [DeviceID='*']
|
||||
*/
|
||||
UnregisterPersistentEvent(Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Filter object represents a unit of modification on an ImageFile. To use a Filter, add it to the Filters collection, then set the filter's propertie
|
||||
* s and finally use the Apply method of the ImageProcess object to filter an ImageFile.
|
||||
* The Filter object represents a unit of modification on an ImageFile. To use a Filter, add it to the Filters collection, then set the filter's
|
||||
* properties and finally use the Apply method of the ImageProcess object to filter an ImageFile.
|
||||
*/
|
||||
interface Filter {
|
||||
class Filter {
|
||||
private constructor();
|
||||
private 'WIA.Filter_typekey': Filter;
|
||||
|
||||
/** Returns a Description of what the filter does */
|
||||
readonly Description: string;
|
||||
|
||||
@@ -422,10 +457,13 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The FilterInfo object is a container that describes a Filter object without requiring a Filter to be Added to the process chain. See the FilterInfos pr
|
||||
* operty on the ImageProcess object for details on accessing FilterInfo objects.
|
||||
* The FilterInfo object is a container that describes a Filter object without requiring a Filter to be Added to the process chain. See the FilterInfos
|
||||
* property on the ImageProcess object for details on accessing FilterInfo objects.
|
||||
*/
|
||||
interface FilterInfo {
|
||||
class FilterInfo {
|
||||
private constructor();
|
||||
private 'WIA.FilterInfo_typekey': FilterInfo;
|
||||
|
||||
/** Returns a technical Description of what the filter does and how to use it in a filter chain */
|
||||
readonly Description: string;
|
||||
|
||||
@@ -437,15 +475,18 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The FilterInfos object is a collection of all the available FilterInfo objects. See the FilterInfos property on the ImageProcess object for detail on a
|
||||
* ccessing the FilterInfos object.
|
||||
* The FilterInfos object is a collection of all the available FilterInfo objects. See the FilterInfos property on the ImageProcess object for detail on
|
||||
* accessing the FilterInfos object.
|
||||
*/
|
||||
interface FilterInfos {
|
||||
/** Returns the number of members in the collection */
|
||||
readonly Count: number;
|
||||
|
||||
/** Returns the specified item in the collection either by position or name */
|
||||
Item(Index: any): FilterInfo;
|
||||
Item(Index: number | string): FilterInfo;
|
||||
|
||||
/** Returns the specified item in the collection either by position or name */
|
||||
(Index: number | string): FilterInfo;
|
||||
}
|
||||
|
||||
/** The Filters object is a collection of the Filters that will be applied to an ImageFile when you call the Apply method on the ImageProcess object. */
|
||||
@@ -464,11 +505,14 @@ declare namespace WIA {
|
||||
|
||||
/** Removes the designated filter */
|
||||
Remove(Index: number): void;
|
||||
|
||||
/** Returns the specified item in the collection by position or FilterID */
|
||||
(Index: number): Filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Formats object is a collection of supported FormatIDs that you can use when calling Transfer on an Item object or ShowTransfer on a CommonDialog ob
|
||||
* ject for this Item.
|
||||
* The Formats object is a collection of supported FormatIDs that you can use when calling Transfer on an Item object or ShowTransfer on a CommonDialog
|
||||
* object for this Item.
|
||||
*/
|
||||
interface Formats {
|
||||
/** Returns the number of members in the collection */
|
||||
@@ -476,13 +520,19 @@ declare namespace WIA {
|
||||
|
||||
/** Returns the specified item in the collection by position */
|
||||
Item(Index: number): string;
|
||||
|
||||
/** Returns the specified item in the collection by position */
|
||||
(Index: number): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ImageFile object is a container for images transferred to your computer when you call Transfer or ShowTransfer. It also supports image files throug
|
||||
* h LoadFile. An ImageFile object can be created using "WIA.ImageFile" in a call to CreateObject.
|
||||
* The ImageFile object is a container for images transferred to your computer when you call Transfer or ShowTransfer. It also supports image files
|
||||
* through LoadFile. An ImageFile object can be created using "WIA.ImageFile" in a call to CreateObject.
|
||||
*/
|
||||
interface ImageFile {
|
||||
class ImageFile {
|
||||
private constructor();
|
||||
private 'WIA.ImageFile_typekey': ImageFile;
|
||||
|
||||
/** Returns/Sets the current frame in the image */
|
||||
ActiveFrame: number;
|
||||
|
||||
@@ -539,7 +589,10 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/** The ImageProcess object manages the filter chain. An ImageProcess object can be created using "WIA.ImageProcess" in a call to CreateObject. */
|
||||
interface ImageProcess {
|
||||
class ImageProcess {
|
||||
private constructor();
|
||||
private 'WIA.ImageProcess_typekey': ImageProcess;
|
||||
|
||||
/** Takes the specified ImageFile and returns the new ImageFile with all the filters applied on success */
|
||||
Apply(Source: ImageFile): ImageFile;
|
||||
|
||||
@@ -551,10 +604,13 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Item object is a container for an item on an imaging device object. See the Items property on the Device or Item object for details on accessing It
|
||||
* em objects.
|
||||
* The Item object is a container for an item on an imaging device object. See the Items property on the Device or Item object for details on accessing
|
||||
* Item objects.
|
||||
*/
|
||||
interface Item {
|
||||
class Item {
|
||||
private constructor();
|
||||
private 'WIA.Item_typekey': Item;
|
||||
|
||||
/** A collection of all commands for this item */
|
||||
readonly Commands: DeviceCommands;
|
||||
|
||||
@@ -574,17 +630,15 @@ declare namespace WIA {
|
||||
readonly Properties: Properties;
|
||||
|
||||
/**
|
||||
* Returns an ImageFile object, in this version, in the format specified in FormatID if supported, otherwise using the preferred format for this imaging d
|
||||
* evice. Future versions may return a collection of ImageFile objects.
|
||||
* Returns an ImageFile object, in this version, in the format specified in FormatID if supported, otherwise using the preferred format for this imaging
|
||||
* device. Future versions may return a collection of ImageFile objects.
|
||||
* @param string [FormatID='{00000000-0000-0000-0000-000000000000}']
|
||||
*/
|
||||
Transfer(FormatID?: string): any;
|
||||
|
||||
/** Returns the underlying IWiaItem interface for this Item object */
|
||||
readonly WiaItem: any;
|
||||
Transfer(FormatID?: string): ImageFile;
|
||||
}
|
||||
|
||||
/** The Items object contains a collection of Item objects. See the Items property on the Device or Item object for details on accessing the Items object. */
|
||||
// tslint:disable-next-line interface-name
|
||||
interface Items {
|
||||
/** Adds a new Item with the specified Name and Flags. The Flags value is created by using the OR operation with members of the WiaItemFlags enumeration. */
|
||||
Add(Name: string, Flags: number): void;
|
||||
@@ -597,28 +651,37 @@ declare namespace WIA {
|
||||
|
||||
/** Removes the designated Item */
|
||||
Remove(Index: number): void;
|
||||
|
||||
/** Returns the specified item in the collection by position */
|
||||
(Index: number): Item;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Properties object is a collection of all the Property objects associated with a given Device, DeviceInfo, Filter, ImageFile or Item object. See the
|
||||
* Properties property on any of these objects for detail on accessing the Properties object.
|
||||
* The Properties object is a collection of all the Property objects associated with a given Device, DeviceInfo, Filter, ImageFile or Item object. See
|
||||
* the Properties property on any of these objects for detail on accessing the Properties object.
|
||||
*/
|
||||
interface Properties {
|
||||
/** Returns the number of members in the collection */
|
||||
readonly Count: number;
|
||||
|
||||
/** Indicates whether the specified Property exists in the collection */
|
||||
Exists(Index: any): boolean;
|
||||
Exists(Index: number | string): boolean;
|
||||
|
||||
/** Returns the specified item in the collection either by position or name. */
|
||||
Item(Index: any): Property;
|
||||
Item(Index: number | string): Property;
|
||||
|
||||
/** Returns the specified item in the collection either by position or name. */
|
||||
(Index: number | string): Property;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Property object is a container for a property associated with a Device, DeviceInfo, Filter, ImageFile or Item object. See the Properties property o
|
||||
* n any of these objects for details on accessing Property objects.
|
||||
* The Property object is a container for a property associated with a Device, DeviceInfo, Filter, ImageFile or Item object. See the Properties property
|
||||
* on any of these objects for details on accessing Property objects.
|
||||
*/
|
||||
interface Property {
|
||||
class Property {
|
||||
private constructor();
|
||||
private 'WIA.Property_typekey': Property;
|
||||
|
||||
/** Indicates whether the Property Value is read only */
|
||||
readonly IsReadOnly: boolean;
|
||||
|
||||
@@ -657,10 +720,13 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Rational object is a container for the rational values found in Exif tags. It is a supported element type of the Vector object and may be created u
|
||||
* sing "WIA.Rational" in a call to CreateObject.
|
||||
* The Rational object is a container for the rational values found in Exif tags. It is a supported element type of the Vector object and may be created
|
||||
* using "WIA.Rational" in a call to CreateObject.
|
||||
*/
|
||||
interface Rational {
|
||||
class Rational {
|
||||
private constructor();
|
||||
private 'WIA.Rational_typekey': Rational;
|
||||
|
||||
/** Returns/Sets the Rational Value Denominator */
|
||||
Denominator: number;
|
||||
|
||||
@@ -672,19 +738,19 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Vector object is a collection of values of the same type. It is used throughout the library in many different ways. The Vector object may be create
|
||||
* d using "WIA.Vector" in a call to CreateObject.
|
||||
* The Vector object is a collection of values of the same type. It is used throughout the library in many different ways. The Vector object may be
|
||||
* created using "WIA.Vector" in a call to CreateObject.
|
||||
*/
|
||||
interface Vector {
|
||||
interface Vector<TItem = any> {
|
||||
/**
|
||||
* If Index is not zero, Inserts a new element into the Vector collection before the specified Index. If Index is zero, Appends a new element to the Vecto
|
||||
* r collection.
|
||||
* If Index is not zero, Inserts a new element into the Vector collection before the specified Index. If Index is zero, Appends a new element to the
|
||||
* Vector collection.
|
||||
* @param number [Index=0]
|
||||
*/
|
||||
Add(Value: any, Index?: number): void;
|
||||
Add(Value: TItem, Index?: number): void;
|
||||
|
||||
/** Returns/Sets the Vector of Bytes as an array of bytes */
|
||||
BinaryData: any;
|
||||
BinaryData: SafeArray;
|
||||
|
||||
/** Removes all elements. */
|
||||
Clear(): void;
|
||||
@@ -696,30 +762,30 @@ declare namespace WIA {
|
||||
Date: VarDate;
|
||||
|
||||
/**
|
||||
* Used to get the Thumbnail property of an ImageFile which is an image file, The thumbnail property of an Item which is RGB data, or creating an ImageFil
|
||||
* e from raw ARGB data. Returns an ImageFile object on success. See the Picture method for more details.
|
||||
* Used to get the Thumbnail property of an ImageFile which is an image file, The thumbnail property of an Item which is RGB data, or creating an
|
||||
* ImageFile from raw ARGB data. Returns an ImageFile object on success. See the Picture method for more details.
|
||||
* @param number [Width=0]
|
||||
* @param number [Height=0]
|
||||
*/
|
||||
ImageFile(Width?: number, Height?: number): ImageFile;
|
||||
|
||||
/** Returns/Sets the specified item in the vector by position */
|
||||
Item(Index: number): any;
|
||||
/** Returns the specified item in the vector by position */
|
||||
Item(Index: number): TItem;
|
||||
|
||||
/**
|
||||
* If the Vector of Bytes contains an image file, then Width and Height are ignored. Otherwise a Vector of Bytes must be RGB data and a Vector of Longs mu
|
||||
* st be ARGB data. Returns a Picture object on success. See the ImageFile method for more details.
|
||||
* If the Vector of Bytes contains an image file, then Width and Height are ignored. Otherwise a Vector of Bytes must be RGB data and a Vector of Longs
|
||||
* must be ARGB data. Returns a Picture object on success. See the ImageFile method for more details.
|
||||
* @param number [Width=0]
|
||||
* @param number [Height=0]
|
||||
*/
|
||||
Picture(Width?: number, Height?: number): any;
|
||||
|
||||
/** Removes the designated element and returns it if successful */
|
||||
Remove(Index: number): any;
|
||||
Remove(Index: number): TItem | null;
|
||||
|
||||
/**
|
||||
* Stores the string Value into the Vector of Bytes including the NULL terminator. Value may be truncated unless Resizable is True. The string will be sto
|
||||
* red as an ANSI string unless Unicode is True, in which case it will be stored as a Unicode string.
|
||||
* Stores the string Value into the Vector of Bytes including the NULL terminator. Value may be truncated unless Resizable is True. The string will be
|
||||
* stored as an ANSI string unless Unicode is True, in which case it will be stored as a Unicode string.
|
||||
* @param boolean [Resizable=true]
|
||||
* @param boolean [Unicode=true]
|
||||
*/
|
||||
@@ -730,30 +796,24 @@ declare namespace WIA {
|
||||
* @param boolean [Unicode=true]
|
||||
*/
|
||||
String(Unicode?: boolean): string;
|
||||
|
||||
/** Returns the specified item in the vector by position */
|
||||
(Index: number): TItem;
|
||||
}
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
on(obj: WIA.DeviceManager, event: 'OnEvent', argNames: ['EventID', 'DeviceID', 'ItemID'], handler: (
|
||||
this: WIA.DeviceManager, parameter: {
|
||||
EventID: string, DeviceID: string, ItemID: string}) => void): void;
|
||||
set(obj: WIA.Vector, propertyName: 'Item', parameterTypes: [number], newValue: any): void;
|
||||
new(progid: 'WIA.CommonDialog'): WIA.CommonDialog;
|
||||
new(progid: 'WIA.DeviceManager'): WIA.DeviceManager;
|
||||
new(progid: 'WIA.ImageFile'): WIA.ImageFile;
|
||||
new(progid: 'WIA.ImageProcess'): WIA.ImageProcess;
|
||||
new(progid: 'WIA.Rational'): WIA.Rational;
|
||||
new(progid: 'WIA.Vector'): WIA.Vector;
|
||||
this: WIA.DeviceManager, parameter: { readonly EventID: string, readonly DeviceID: string, readonly ItemID: string }) => void): void;
|
||||
set<TItem>(obj: WIA.Vector<TItem>, propertyName: 'Item', parameterTypes: [number], newValue: TItem): void;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: WIA.DeviceCommands): WIA.DeviceCommand;
|
||||
new(col: WIA.DeviceEvents): WIA.DeviceEvent;
|
||||
new(col: WIA.DeviceInfos): WIA.DeviceInfo;
|
||||
new(col: WIA.FilterInfos): WIA.FilterInfo;
|
||||
new(col: WIA.Filters): WIA.Filter;
|
||||
new(col: WIA.Formats): string;
|
||||
new(col: WIA.Items): WIA.Item;
|
||||
new(col: WIA.Properties): WIA.Property;
|
||||
new(col: WIA.Vector): any;
|
||||
interface ActiveXObjectNameMap {
|
||||
'WIA.CommonDialog': WIA.CommonDialog;
|
||||
'WIA.DeviceManager': WIA.DeviceManager;
|
||||
'WIA.ImageFile': WIA.ImageFile;
|
||||
'WIA.ImageProcess': WIA.ImageProcess;
|
||||
'WIA.Rational': WIA.Rational;
|
||||
'WIA.Vector': WIA.Vector;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user