From 1043225508dbad61cc67fa92ef6ed362e724609c Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 02:10:13 +0200 Subject: [PATCH 1/7] WIA Typescript definitions Windows Image Acquisitions --- activex/jscript-extensions.d.ts | 6 + ...crosoft-windows-image-acquisition-tests.ts | 73 ++++ .../microsoft-windows-image-acquisition.d.ts | 380 ++++++++++++++++++ 3 files changed, 459 insertions(+) create mode 100644 activex/jscript-extensions.d.ts create mode 100644 activex/microsoft-windows-image-acquisition-tests.ts create mode 100644 activex/microsoft-windows-image-acquisition.d.ts diff --git a/activex/jscript-extensions.d.ts b/activex/jscript-extensions.d.ts new file mode 100644 index 0000000000..b156983ff1 --- /dev/null +++ b/activex/jscript-extensions.d.ts @@ -0,0 +1,6 @@ +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; + getVarDate: () => VarDate; +} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition-tests.ts b/activex/microsoft-windows-image-acquisition-tests.ts new file mode 100644 index 0000000000..66a9d75a7d --- /dev/null +++ b/activex/microsoft-windows-image-acquisition-tests.ts @@ -0,0 +1,73 @@ +/// + +//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx + + +//Convert a file +var commonDialog = new ActiveXObject('WIA.CommonDialog'); +var img = commonDialog.ShowAcquireImage(); +if (img.FormatID != WIA.FormatID.wiaFormatJPEG) { + var 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 +var dev = commonDialog.ShowSelectDevice(); +if (dev.Type == WIA.WiaDeviceType.CameraDeviceType) { + var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); +} + + +//Display detailed property information +dev = commonDialog.ShowSelectDevice(); +var e = new Enumerator(dev.Properties); //no foreach over ActiveX collections +e.moveFirst(); +while (!e.atEnd()) { + var p = e.item(); + var 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 + ')'; + } + } + } + + 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: '; + } else { + s += ' [valid values include: '; + } + var count = p.SubTypeValues.Count; + for (var i = 1; i <= count; i++) { + s += p.SubTypeValues.Item(i); + if (i < count) { + s += ', '; + } + } + 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 (WScript) { + WScript.Echo(s); + } else if (window) { + window.alert(s); + } +} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition.d.ts b/activex/microsoft-windows-image-acquisition.d.ts new file mode 100644 index 0000000000..c35bb416df --- /dev/null +++ b/activex/microsoft-windows-image-acquisition.d.ts @@ -0,0 +1,380 @@ +// Type definitions for Microsoft Windows Image Acquisition +// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace WIA { + + //Enums + type CommandID = + "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandChangeDocument + | "{E208C170-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandDeleteAllItems + | "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandSynchronize + | "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandTakePicture + | "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandUnloadDocument + const CommandID: { + wiaCommandChangeDocument: CommandID, + wiaCommandDeleteAllItems: CommandID, + wiaCommandSynchronize: CommandID, + wiaCommandTakePicture: CommandID, + wiaCommandUnloadDocument: CommandID + } + + type EventID = + "{A28BBADE-64B6-11D2-A231-00C04FA31809}" //wiaEventDeviceConnected + | "{143E4E83-6497-11D2-A231-00C04FA31809}" //wiaEventDeviceDisconnected + | "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemCreated + | "{1D22A559-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemDeleted + | "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}" //wiaEventScanEmailImage + | "{C00EB793-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanFaxImage + | "{9B2B662C-6185-438C-B68B-E39EE25E71CB}" //wiaEventScanFilmImage + | "{A6C5A715-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanImage + | "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}" //wiaEventScanImage2 + | "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}" //wiaEventScanImage3 + | "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}" //wiaEventScanImage4 + | "{9D095B89-37D6-4877-AFED-62A297DC6DBE}" //wiaEventScanOCRImage + | "{B441F425-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanPrintImage + const EventID: { + wiaEventDeviceConnected: EventID, + wiaEventDeviceDisconnected: EventID, + wiaEventItemCreated: EventID, + wiaEventItemDeleted: EventID, + wiaEventScanEmailImage: EventID, + wiaEventScanFaxImage: EventID, + wiaEventScanFilmImage: EventID, + wiaEventScanImage: EventID, + wiaEventScanImage2: EventID, + wiaEventScanImage3: EventID, + wiaEventScanImage4: EventID, + wiaEventScanOCRImage: EventID, + wiaEventScanPrintImage: EventID + } + + type FormatID = + "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatBMP + | "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatGIF + | "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatJPEG + | "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatPNG + | "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatTIFF + const FormatID: { + wiaFormatBMP: FormatID, + wiaFormatGIF: FormatID, + wiaFormatJPEG: FormatID, + wiaFormatPNG: FormatID, + wiaFormatTIFF: FormatID + } + + type Miscellaneous = + "*" //wiaAnyDeviceID + | "{00000000-0000-0000-0000-000000000000}" //wiaIDUnknown + const Miscellaneous: { + wiaAnyDeviceID: Miscellaneous, + wiaIDUnknown: Miscellaneous + } + + const enum WiaDeviceType { + CameraDeviceType = 2, + ScannerDeviceType = 1, + UnspecifiedDeviceType = 0, + VideoDeviceType = 3 + } + + const enum WiaEventFlag { + ActionEvent = 2, + NotificationEvent = 1 + } + + const enum WiaImageBias { + MaximizeQuality = 131072, + MinimizeSize = 65536 + } + + const enum WiaImageIntent { + ColorIntent = 1, + GrayscaleIntent = 2, + TextIntent = 4, + UnspecifiedIntent = 0 + } + + const enum WiaImagePropertyType { + ByteImagePropertyType = 1001, + LongImagePropertyType = 1004, + RationalImagePropertyType = 1006, + StringImagePropertyType = 1002, + UndefinedImagePropertyType = 1000, + UnsignedIntegerImagePropertyType = 1003, + UnsignedLongImagePropertyType = 1005, + UnsignedRationalImagePropertyType = 1007, + VectorOfBytesImagePropertyType = 1101, + VectorOfLongsImagePropertyType = 1103, + VectorOfRationalsImagePropertyType = 1105, + VectorOfUndefinedImagePropertyType = 1100, + VectorOfUnsignedIntegersImagePropertyType = 1102, + VectorOfUnsignedLongsImagePropertyType = 1104, + VectorOfUnsignedRationalsImagePropertyType = 1106 + } + + const enum WiaItemFlag { + AnalyzeItemFlag = 16, + AudioItemFlag = 32, + BurstItemFlag = 2048, + DeletedItemFlag = 128, + DeviceItemFlag = 64, + DisconnectedItemFlag = 256, + FileItemFlag = 2, + FolderItemFlag = 4, + FreeItemFlag = 0, + GeneratedItemFlag = 16384, + HasAttachmentsItemFlag = 32768, + HPanoramaItemFlag = 512, + ImageItemFlag = 1, + RemovedItemFlag = -2147483648, + RootItemFlag = 8, + StorageItemFlag = 4096, + TransferItemFlag = 8192, + VideoItemFlag = 65536, + VPanoramaItemFlag = 1024 + } + + const enum WiaPropertyType { + BooleanPropertyType = 1, + BytePropertyType = 2, + ClassIDPropertyType = 15, + CurrencyPropertyType = 12, + DatePropertyType = 13, + DoublePropertyType = 11, + ErrorCodePropertyType = 7, + FileTimePropertyType = 14, + HandlePropertyType = 18, + IntegerPropertyType = 3, + LargeIntegerPropertyType = 8, + LongPropertyType = 5, + ObjectPropertyType = 17, + SinglePropertyType = 10, + StringPropertyType = 16, + UnsignedIntegerPropertyType = 4, + UnsignedLargeIntegerPropertyType = 9, + UnsignedLongPropertyType = 6, + UnsupportedPropertyType = 0, + VariantPropertyType = 19, + VectorOfBooleansPropertyType = 101, + VectorOfBytesPropertyType = 102, + VectorOfClassIDsPropertyType = 115, + VectorOfCurrenciesPropertyType = 112, + VectorOfDatesPropertyType = 113, + VectorOfDoublesPropertyType = 111, + VectorOfErrorCodesPropertyType = 107, + VectorOfFileTimesPropertyType = 114, + VectorOfIntegersPropertyType = 103, + VectorOfLargeIntegersPropertyType = 108, + VectorOfLongsPropertyType = 105, + VectorOfSinglesPropertyType = 110, + VectorOfStringsPropertyType = 116, + VectorOfUnsignedIntegersPropertyType = 104, + VectorOfUnsignedLargeIntegersPropertyType = 109, + VectorOfUnsignedLongsPropertyType = 106, + VectorOfVariantsPropertyType = 119 + } + + const enum WiaSubType { + FlagSubType = 3, + ListSubType = 2, + RangeSubType = 1, + UnspecifiedSubType = 0 + } + + //Classes + interface CommonDialog { + ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile + ShowAcquisitionWizard: (Device: Device) => any + ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void + ShowItemProperties: (Item: Item, CancelError?: boolean) => void + ShowPhotoPrintingWizard: (Files: any) => void + ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device + ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items + ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any + } + + interface Device { + Commands: DeviceCommands + DeviceID: string + Events: DeviceEvents + ExecuteCommand: (CommandID: string) => Item + GetItem: (ItemID: string) => Item + Items: Items + Properties: Properties + Type: WiaDeviceType + WiaItem: any /*VT_UNKNOWN*/ + } + + interface DeviceCommand { + CommandID: string + Description: string + Name: string + } + + interface DeviceCommands { + Count: number + Item: (Index: number) => DeviceCommand + } + + interface DeviceEvent { + Description: string + EventID: string + Name: string + Type: WiaEventFlag + } + + interface DeviceEvents { + Count: number + Item: (Index: number) => DeviceEvent + } + + interface DeviceInfo { + Connect: Device + DeviceID: string + Properties: Properties + Type: WiaDeviceType + } + + interface DeviceInfos { + Count: number + Item: (Index: any) => DeviceInfo + } + + interface DeviceManager { + DeviceInfos: DeviceInfos + RegisterEvent: (EventID: string, DeviceID?: string) => void + RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + UnregisterEvent: (EventID: string, DeviceID?: string) => void + UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + } + + interface Filter { + Description: string + FilterID: string + Name: string + Properties: Properties + } + + interface FilterInfo { + Description: string + FilterID: string + Name: string + } + + interface FilterInfos { + Count: number + Item: (Index: any) => FilterInfo + } + + interface Filters { + Add: (FilterID: string, Index?: number) => void + Count: number + Item: (Index: number) => Filter + Remove: (Index: number) => void + } + + interface Formats { + Count: number + Item: (Index: number) => string + } + + interface ImageFile { + ActiveFrame: number + ARGBData: Vector + FileData: Vector + FileExtension: string + FormatID: string + FrameCount: number + Height: number + HorizontalResolution: number + IsAlphaPixelFormat: boolean + IsAnimated: boolean + IsExtendedPixelFormat: boolean + IsIndexedPixelFormat: boolean + LoadFile: (Filename: string) => void + PixelDepth: number + Properties: Properties + SaveFile: (Filename: string) => void + VerticalResolution: number + Width: number + } + + interface ImageProcess { + Apply: (Source: ImageFile) => ImageFile + FilterInfos: FilterInfos + Filters: Filters + } + + interface Item { + Commands: DeviceCommands + ExecuteCommand: (CommandID: string) => Item + Formats: Formats + ItemID: string + Items: Items + Properties: Properties + Transfer: (FormatID?: string) => any + WiaItem: any /*VT_UNKNOWN*/ + } + + interface Items { + Add: (Name: string, Flags: number) => void + Count: number + Item: (Index: number) => Item + Remove: (Index: number) => void + } + + interface Properties { + Count: number + Exists: (Index: any) => boolean + Item: (Index: any) => Property + } + + interface Property { + IsReadOnly: boolean + IsVector: boolean + Name: string + PropertyID: number + SubType: WiaSubType + SubTypeDefault: any + SubTypeMax: number + SubTypeMin: number + SubTypeStep: number + SubTypeValues: Vector + Type: number + Value: any + } + + interface Rational { + Denominator: number + Numerator: number + Value: number + } + + interface Vector { + Add: (Value: any, Index?: number) => void + BinaryData: any + Clear: void + Count: number + Date: VarDate + ImageFile: (Width?: number, Height?: number) => ImageFile + Item: (Index: number) => any //Also has setter with parameters + Picture: (Width?: number, Height?: number) => any + Remove: (Index: number) => any + SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void + String: (Unicode?: boolean) => string + } + +} + +interface ActiveXObject { + new (progID: 'WIA.Rational'): WIA.Rational; + new (progID: 'WIA.Vector'): WIA.Vector; + new (progID: 'WIA.ImageFile'): WIA.ImageFile; + new (progID: 'WIA.ImageProcess'): WIA.ImageProcess; + new (progID: 'WIA.CommonDialog'): WIA.CommonDialog; + new (progID: 'WIA.DeviceManager'): WIA.DeviceManager; +} From d14f5d484f51cce942c4ec6cd13c611e89553f3c Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 02:41:40 +0200 Subject: [PATCH 2/7] WIA Typescript definitions --- ts-activex/jscript-extensions.d.ts | 16 + ts-activex/jscript-extensions.tests.ts | 5 + ...crosoft-windows-image-acquisition-tests.ts | 73 ++++ .../microsoft-windows-image-acquisition.d.ts | 380 ++++++++++++++++++ 4 files changed, 474 insertions(+) create mode 100644 ts-activex/jscript-extensions.d.ts create mode 100644 ts-activex/jscript-extensions.tests.ts create mode 100644 ts-activex/microsoft-windows-image-acquisition-tests.ts create mode 100644 ts-activex/microsoft-windows-image-acquisition.d.ts diff --git a/ts-activex/jscript-extensions.d.ts b/ts-activex/jscript-extensions.d.ts new file mode 100644 index 0000000000..b7291366bf --- /dev/null +++ b/ts-activex/jscript-extensions.d.ts @@ -0,0 +1,16 @@ +// Type definitions for Microsoft JScript extensions +// Project: https://msdn.microsoft.com/en-us/library/yek4tbz0(v=vs.84).aspx +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +//These will become unnecessary with the next version of Typescript + +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; +} + +interface Date { + getVarDate: () => VarDate; +} \ No newline at end of file diff --git a/ts-activex/jscript-extensions.tests.ts b/ts-activex/jscript-extensions.tests.ts new file mode 100644 index 0000000000..1e4fa6a41d --- /dev/null +++ b/ts-activex/jscript-extensions.tests.ts @@ -0,0 +1,5 @@ +/// + +var x: VarDate; +var dte = new Date(x); +x = dte.getVarDate(); \ No newline at end of file diff --git a/ts-activex/microsoft-windows-image-acquisition-tests.ts b/ts-activex/microsoft-windows-image-acquisition-tests.ts new file mode 100644 index 0000000000..66a9d75a7d --- /dev/null +++ b/ts-activex/microsoft-windows-image-acquisition-tests.ts @@ -0,0 +1,73 @@ +/// + +//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx + + +//Convert a file +var commonDialog = new ActiveXObject('WIA.CommonDialog'); +var img = commonDialog.ShowAcquireImage(); +if (img.FormatID != WIA.FormatID.wiaFormatJPEG) { + var 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 +var dev = commonDialog.ShowSelectDevice(); +if (dev.Type == WIA.WiaDeviceType.CameraDeviceType) { + var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); +} + + +//Display detailed property information +dev = commonDialog.ShowSelectDevice(); +var e = new Enumerator(dev.Properties); //no foreach over ActiveX collections +e.moveFirst(); +while (!e.atEnd()) { + var p = e.item(); + var 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 + ')'; + } + } + } + + 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: '; + } else { + s += ' [valid values include: '; + } + var count = p.SubTypeValues.Count; + for (var i = 1; i <= count; i++) { + s += p.SubTypeValues.Item(i); + if (i < count) { + s += ', '; + } + } + 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 (WScript) { + WScript.Echo(s); + } else if (window) { + window.alert(s); + } +} \ No newline at end of file diff --git a/ts-activex/microsoft-windows-image-acquisition.d.ts b/ts-activex/microsoft-windows-image-acquisition.d.ts new file mode 100644 index 0000000000..c35bb416df --- /dev/null +++ b/ts-activex/microsoft-windows-image-acquisition.d.ts @@ -0,0 +1,380 @@ +// Type definitions for Microsoft Windows Image Acquisition +// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace WIA { + + //Enums + type CommandID = + "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandChangeDocument + | "{E208C170-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandDeleteAllItems + | "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandSynchronize + | "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandTakePicture + | "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandUnloadDocument + const CommandID: { + wiaCommandChangeDocument: CommandID, + wiaCommandDeleteAllItems: CommandID, + wiaCommandSynchronize: CommandID, + wiaCommandTakePicture: CommandID, + wiaCommandUnloadDocument: CommandID + } + + type EventID = + "{A28BBADE-64B6-11D2-A231-00C04FA31809}" //wiaEventDeviceConnected + | "{143E4E83-6497-11D2-A231-00C04FA31809}" //wiaEventDeviceDisconnected + | "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemCreated + | "{1D22A559-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemDeleted + | "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}" //wiaEventScanEmailImage + | "{C00EB793-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanFaxImage + | "{9B2B662C-6185-438C-B68B-E39EE25E71CB}" //wiaEventScanFilmImage + | "{A6C5A715-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanImage + | "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}" //wiaEventScanImage2 + | "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}" //wiaEventScanImage3 + | "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}" //wiaEventScanImage4 + | "{9D095B89-37D6-4877-AFED-62A297DC6DBE}" //wiaEventScanOCRImage + | "{B441F425-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanPrintImage + const EventID: { + wiaEventDeviceConnected: EventID, + wiaEventDeviceDisconnected: EventID, + wiaEventItemCreated: EventID, + wiaEventItemDeleted: EventID, + wiaEventScanEmailImage: EventID, + wiaEventScanFaxImage: EventID, + wiaEventScanFilmImage: EventID, + wiaEventScanImage: EventID, + wiaEventScanImage2: EventID, + wiaEventScanImage3: EventID, + wiaEventScanImage4: EventID, + wiaEventScanOCRImage: EventID, + wiaEventScanPrintImage: EventID + } + + type FormatID = + "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatBMP + | "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatGIF + | "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatJPEG + | "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatPNG + | "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatTIFF + const FormatID: { + wiaFormatBMP: FormatID, + wiaFormatGIF: FormatID, + wiaFormatJPEG: FormatID, + wiaFormatPNG: FormatID, + wiaFormatTIFF: FormatID + } + + type Miscellaneous = + "*" //wiaAnyDeviceID + | "{00000000-0000-0000-0000-000000000000}" //wiaIDUnknown + const Miscellaneous: { + wiaAnyDeviceID: Miscellaneous, + wiaIDUnknown: Miscellaneous + } + + const enum WiaDeviceType { + CameraDeviceType = 2, + ScannerDeviceType = 1, + UnspecifiedDeviceType = 0, + VideoDeviceType = 3 + } + + const enum WiaEventFlag { + ActionEvent = 2, + NotificationEvent = 1 + } + + const enum WiaImageBias { + MaximizeQuality = 131072, + MinimizeSize = 65536 + } + + const enum WiaImageIntent { + ColorIntent = 1, + GrayscaleIntent = 2, + TextIntent = 4, + UnspecifiedIntent = 0 + } + + const enum WiaImagePropertyType { + ByteImagePropertyType = 1001, + LongImagePropertyType = 1004, + RationalImagePropertyType = 1006, + StringImagePropertyType = 1002, + UndefinedImagePropertyType = 1000, + UnsignedIntegerImagePropertyType = 1003, + UnsignedLongImagePropertyType = 1005, + UnsignedRationalImagePropertyType = 1007, + VectorOfBytesImagePropertyType = 1101, + VectorOfLongsImagePropertyType = 1103, + VectorOfRationalsImagePropertyType = 1105, + VectorOfUndefinedImagePropertyType = 1100, + VectorOfUnsignedIntegersImagePropertyType = 1102, + VectorOfUnsignedLongsImagePropertyType = 1104, + VectorOfUnsignedRationalsImagePropertyType = 1106 + } + + const enum WiaItemFlag { + AnalyzeItemFlag = 16, + AudioItemFlag = 32, + BurstItemFlag = 2048, + DeletedItemFlag = 128, + DeviceItemFlag = 64, + DisconnectedItemFlag = 256, + FileItemFlag = 2, + FolderItemFlag = 4, + FreeItemFlag = 0, + GeneratedItemFlag = 16384, + HasAttachmentsItemFlag = 32768, + HPanoramaItemFlag = 512, + ImageItemFlag = 1, + RemovedItemFlag = -2147483648, + RootItemFlag = 8, + StorageItemFlag = 4096, + TransferItemFlag = 8192, + VideoItemFlag = 65536, + VPanoramaItemFlag = 1024 + } + + const enum WiaPropertyType { + BooleanPropertyType = 1, + BytePropertyType = 2, + ClassIDPropertyType = 15, + CurrencyPropertyType = 12, + DatePropertyType = 13, + DoublePropertyType = 11, + ErrorCodePropertyType = 7, + FileTimePropertyType = 14, + HandlePropertyType = 18, + IntegerPropertyType = 3, + LargeIntegerPropertyType = 8, + LongPropertyType = 5, + ObjectPropertyType = 17, + SinglePropertyType = 10, + StringPropertyType = 16, + UnsignedIntegerPropertyType = 4, + UnsignedLargeIntegerPropertyType = 9, + UnsignedLongPropertyType = 6, + UnsupportedPropertyType = 0, + VariantPropertyType = 19, + VectorOfBooleansPropertyType = 101, + VectorOfBytesPropertyType = 102, + VectorOfClassIDsPropertyType = 115, + VectorOfCurrenciesPropertyType = 112, + VectorOfDatesPropertyType = 113, + VectorOfDoublesPropertyType = 111, + VectorOfErrorCodesPropertyType = 107, + VectorOfFileTimesPropertyType = 114, + VectorOfIntegersPropertyType = 103, + VectorOfLargeIntegersPropertyType = 108, + VectorOfLongsPropertyType = 105, + VectorOfSinglesPropertyType = 110, + VectorOfStringsPropertyType = 116, + VectorOfUnsignedIntegersPropertyType = 104, + VectorOfUnsignedLargeIntegersPropertyType = 109, + VectorOfUnsignedLongsPropertyType = 106, + VectorOfVariantsPropertyType = 119 + } + + const enum WiaSubType { + FlagSubType = 3, + ListSubType = 2, + RangeSubType = 1, + UnspecifiedSubType = 0 + } + + //Classes + interface CommonDialog { + ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile + ShowAcquisitionWizard: (Device: Device) => any + ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void + ShowItemProperties: (Item: Item, CancelError?: boolean) => void + ShowPhotoPrintingWizard: (Files: any) => void + ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device + ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items + ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any + } + + interface Device { + Commands: DeviceCommands + DeviceID: string + Events: DeviceEvents + ExecuteCommand: (CommandID: string) => Item + GetItem: (ItemID: string) => Item + Items: Items + Properties: Properties + Type: WiaDeviceType + WiaItem: any /*VT_UNKNOWN*/ + } + + interface DeviceCommand { + CommandID: string + Description: string + Name: string + } + + interface DeviceCommands { + Count: number + Item: (Index: number) => DeviceCommand + } + + interface DeviceEvent { + Description: string + EventID: string + Name: string + Type: WiaEventFlag + } + + interface DeviceEvents { + Count: number + Item: (Index: number) => DeviceEvent + } + + interface DeviceInfo { + Connect: Device + DeviceID: string + Properties: Properties + Type: WiaDeviceType + } + + interface DeviceInfos { + Count: number + Item: (Index: any) => DeviceInfo + } + + interface DeviceManager { + DeviceInfos: DeviceInfos + RegisterEvent: (EventID: string, DeviceID?: string) => void + RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + UnregisterEvent: (EventID: string, DeviceID?: string) => void + UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + } + + interface Filter { + Description: string + FilterID: string + Name: string + Properties: Properties + } + + interface FilterInfo { + Description: string + FilterID: string + Name: string + } + + interface FilterInfos { + Count: number + Item: (Index: any) => FilterInfo + } + + interface Filters { + Add: (FilterID: string, Index?: number) => void + Count: number + Item: (Index: number) => Filter + Remove: (Index: number) => void + } + + interface Formats { + Count: number + Item: (Index: number) => string + } + + interface ImageFile { + ActiveFrame: number + ARGBData: Vector + FileData: Vector + FileExtension: string + FormatID: string + FrameCount: number + Height: number + HorizontalResolution: number + IsAlphaPixelFormat: boolean + IsAnimated: boolean + IsExtendedPixelFormat: boolean + IsIndexedPixelFormat: boolean + LoadFile: (Filename: string) => void + PixelDepth: number + Properties: Properties + SaveFile: (Filename: string) => void + VerticalResolution: number + Width: number + } + + interface ImageProcess { + Apply: (Source: ImageFile) => ImageFile + FilterInfos: FilterInfos + Filters: Filters + } + + interface Item { + Commands: DeviceCommands + ExecuteCommand: (CommandID: string) => Item + Formats: Formats + ItemID: string + Items: Items + Properties: Properties + Transfer: (FormatID?: string) => any + WiaItem: any /*VT_UNKNOWN*/ + } + + interface Items { + Add: (Name: string, Flags: number) => void + Count: number + Item: (Index: number) => Item + Remove: (Index: number) => void + } + + interface Properties { + Count: number + Exists: (Index: any) => boolean + Item: (Index: any) => Property + } + + interface Property { + IsReadOnly: boolean + IsVector: boolean + Name: string + PropertyID: number + SubType: WiaSubType + SubTypeDefault: any + SubTypeMax: number + SubTypeMin: number + SubTypeStep: number + SubTypeValues: Vector + Type: number + Value: any + } + + interface Rational { + Denominator: number + Numerator: number + Value: number + } + + interface Vector { + Add: (Value: any, Index?: number) => void + BinaryData: any + Clear: void + Count: number + Date: VarDate + ImageFile: (Width?: number, Height?: number) => ImageFile + Item: (Index: number) => any //Also has setter with parameters + Picture: (Width?: number, Height?: number) => any + Remove: (Index: number) => any + SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void + String: (Unicode?: boolean) => string + } + +} + +interface ActiveXObject { + new (progID: 'WIA.Rational'): WIA.Rational; + new (progID: 'WIA.Vector'): WIA.Vector; + new (progID: 'WIA.ImageFile'): WIA.ImageFile; + new (progID: 'WIA.ImageProcess'): WIA.ImageProcess; + new (progID: 'WIA.CommonDialog'): WIA.CommonDialog; + new (progID: 'WIA.DeviceManager'): WIA.DeviceManager; +} From 1ae946ae466acb2a6f5695980ec68fe4102326a1 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 02:42:37 +0200 Subject: [PATCH 3/7] Revert "WIA Typescript definitions" This reverts commit 1043225508dbad61cc67fa92ef6ed362e724609c. --- activex/jscript-extensions.d.ts | 6 - ...crosoft-windows-image-acquisition-tests.ts | 73 ---- .../microsoft-windows-image-acquisition.d.ts | 380 ------------------ 3 files changed, 459 deletions(-) delete mode 100644 activex/jscript-extensions.d.ts delete mode 100644 activex/microsoft-windows-image-acquisition-tests.ts delete mode 100644 activex/microsoft-windows-image-acquisition.d.ts diff --git a/activex/jscript-extensions.d.ts b/activex/jscript-extensions.d.ts deleted file mode 100644 index b156983ff1..0000000000 --- a/activex/jscript-extensions.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -interface VarDate { } - -interface DateConstructor { - new (vd: VarDate): Date; - getVarDate: () => VarDate; -} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition-tests.ts b/activex/microsoft-windows-image-acquisition-tests.ts deleted file mode 100644 index 66a9d75a7d..0000000000 --- a/activex/microsoft-windows-image-acquisition-tests.ts +++ /dev/null @@ -1,73 +0,0 @@ -/// - -//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx - - -//Convert a file -var commonDialog = new ActiveXObject('WIA.CommonDialog'); -var img = commonDialog.ShowAcquireImage(); -if (img.FormatID != WIA.FormatID.wiaFormatJPEG) { - var 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 -var dev = commonDialog.ShowSelectDevice(); -if (dev.Type == WIA.WiaDeviceType.CameraDeviceType) { - var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); -} - - -//Display detailed property information -dev = commonDialog.ShowSelectDevice(); -var e = new Enumerator(dev.Properties); //no foreach over ActiveX collections -e.moveFirst(); -while (!e.atEnd()) { - var p = e.item(); - var 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 + ')'; - } - } - } - - 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: '; - } else { - s += ' [valid values include: '; - } - var count = p.SubTypeValues.Count; - for (var i = 1; i <= count; i++) { - s += p.SubTypeValues.Item(i); - if (i < count) { - s += ', '; - } - } - 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 (WScript) { - WScript.Echo(s); - } else if (window) { - window.alert(s); - } -} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition.d.ts b/activex/microsoft-windows-image-acquisition.d.ts deleted file mode 100644 index c35bb416df..0000000000 --- a/activex/microsoft-windows-image-acquisition.d.ts +++ /dev/null @@ -1,380 +0,0 @@ -// Type definitions for Microsoft Windows Image Acquisition -// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx -// Definitions by: Zev Spitz -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace WIA { - - //Enums - type CommandID = - "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandChangeDocument - | "{E208C170-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandDeleteAllItems - | "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandSynchronize - | "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandTakePicture - | "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandUnloadDocument - const CommandID: { - wiaCommandChangeDocument: CommandID, - wiaCommandDeleteAllItems: CommandID, - wiaCommandSynchronize: CommandID, - wiaCommandTakePicture: CommandID, - wiaCommandUnloadDocument: CommandID - } - - type EventID = - "{A28BBADE-64B6-11D2-A231-00C04FA31809}" //wiaEventDeviceConnected - | "{143E4E83-6497-11D2-A231-00C04FA31809}" //wiaEventDeviceDisconnected - | "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemCreated - | "{1D22A559-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemDeleted - | "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}" //wiaEventScanEmailImage - | "{C00EB793-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanFaxImage - | "{9B2B662C-6185-438C-B68B-E39EE25E71CB}" //wiaEventScanFilmImage - | "{A6C5A715-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanImage - | "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}" //wiaEventScanImage2 - | "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}" //wiaEventScanImage3 - | "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}" //wiaEventScanImage4 - | "{9D095B89-37D6-4877-AFED-62A297DC6DBE}" //wiaEventScanOCRImage - | "{B441F425-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanPrintImage - const EventID: { - wiaEventDeviceConnected: EventID, - wiaEventDeviceDisconnected: EventID, - wiaEventItemCreated: EventID, - wiaEventItemDeleted: EventID, - wiaEventScanEmailImage: EventID, - wiaEventScanFaxImage: EventID, - wiaEventScanFilmImage: EventID, - wiaEventScanImage: EventID, - wiaEventScanImage2: EventID, - wiaEventScanImage3: EventID, - wiaEventScanImage4: EventID, - wiaEventScanOCRImage: EventID, - wiaEventScanPrintImage: EventID - } - - type FormatID = - "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatBMP - | "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatGIF - | "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatJPEG - | "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatPNG - | "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatTIFF - const FormatID: { - wiaFormatBMP: FormatID, - wiaFormatGIF: FormatID, - wiaFormatJPEG: FormatID, - wiaFormatPNG: FormatID, - wiaFormatTIFF: FormatID - } - - type Miscellaneous = - "*" //wiaAnyDeviceID - | "{00000000-0000-0000-0000-000000000000}" //wiaIDUnknown - const Miscellaneous: { - wiaAnyDeviceID: Miscellaneous, - wiaIDUnknown: Miscellaneous - } - - const enum WiaDeviceType { - CameraDeviceType = 2, - ScannerDeviceType = 1, - UnspecifiedDeviceType = 0, - VideoDeviceType = 3 - } - - const enum WiaEventFlag { - ActionEvent = 2, - NotificationEvent = 1 - } - - const enum WiaImageBias { - MaximizeQuality = 131072, - MinimizeSize = 65536 - } - - const enum WiaImageIntent { - ColorIntent = 1, - GrayscaleIntent = 2, - TextIntent = 4, - UnspecifiedIntent = 0 - } - - const enum WiaImagePropertyType { - ByteImagePropertyType = 1001, - LongImagePropertyType = 1004, - RationalImagePropertyType = 1006, - StringImagePropertyType = 1002, - UndefinedImagePropertyType = 1000, - UnsignedIntegerImagePropertyType = 1003, - UnsignedLongImagePropertyType = 1005, - UnsignedRationalImagePropertyType = 1007, - VectorOfBytesImagePropertyType = 1101, - VectorOfLongsImagePropertyType = 1103, - VectorOfRationalsImagePropertyType = 1105, - VectorOfUndefinedImagePropertyType = 1100, - VectorOfUnsignedIntegersImagePropertyType = 1102, - VectorOfUnsignedLongsImagePropertyType = 1104, - VectorOfUnsignedRationalsImagePropertyType = 1106 - } - - const enum WiaItemFlag { - AnalyzeItemFlag = 16, - AudioItemFlag = 32, - BurstItemFlag = 2048, - DeletedItemFlag = 128, - DeviceItemFlag = 64, - DisconnectedItemFlag = 256, - FileItemFlag = 2, - FolderItemFlag = 4, - FreeItemFlag = 0, - GeneratedItemFlag = 16384, - HasAttachmentsItemFlag = 32768, - HPanoramaItemFlag = 512, - ImageItemFlag = 1, - RemovedItemFlag = -2147483648, - RootItemFlag = 8, - StorageItemFlag = 4096, - TransferItemFlag = 8192, - VideoItemFlag = 65536, - VPanoramaItemFlag = 1024 - } - - const enum WiaPropertyType { - BooleanPropertyType = 1, - BytePropertyType = 2, - ClassIDPropertyType = 15, - CurrencyPropertyType = 12, - DatePropertyType = 13, - DoublePropertyType = 11, - ErrorCodePropertyType = 7, - FileTimePropertyType = 14, - HandlePropertyType = 18, - IntegerPropertyType = 3, - LargeIntegerPropertyType = 8, - LongPropertyType = 5, - ObjectPropertyType = 17, - SinglePropertyType = 10, - StringPropertyType = 16, - UnsignedIntegerPropertyType = 4, - UnsignedLargeIntegerPropertyType = 9, - UnsignedLongPropertyType = 6, - UnsupportedPropertyType = 0, - VariantPropertyType = 19, - VectorOfBooleansPropertyType = 101, - VectorOfBytesPropertyType = 102, - VectorOfClassIDsPropertyType = 115, - VectorOfCurrenciesPropertyType = 112, - VectorOfDatesPropertyType = 113, - VectorOfDoublesPropertyType = 111, - VectorOfErrorCodesPropertyType = 107, - VectorOfFileTimesPropertyType = 114, - VectorOfIntegersPropertyType = 103, - VectorOfLargeIntegersPropertyType = 108, - VectorOfLongsPropertyType = 105, - VectorOfSinglesPropertyType = 110, - VectorOfStringsPropertyType = 116, - VectorOfUnsignedIntegersPropertyType = 104, - VectorOfUnsignedLargeIntegersPropertyType = 109, - VectorOfUnsignedLongsPropertyType = 106, - VectorOfVariantsPropertyType = 119 - } - - const enum WiaSubType { - FlagSubType = 3, - ListSubType = 2, - RangeSubType = 1, - UnspecifiedSubType = 0 - } - - //Classes - interface CommonDialog { - ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile - ShowAcquisitionWizard: (Device: Device) => any - ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void - ShowItemProperties: (Item: Item, CancelError?: boolean) => void - ShowPhotoPrintingWizard: (Files: any) => void - ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device - ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items - ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any - } - - interface Device { - Commands: DeviceCommands - DeviceID: string - Events: DeviceEvents - ExecuteCommand: (CommandID: string) => Item - GetItem: (ItemID: string) => Item - Items: Items - Properties: Properties - Type: WiaDeviceType - WiaItem: any /*VT_UNKNOWN*/ - } - - interface DeviceCommand { - CommandID: string - Description: string - Name: string - } - - interface DeviceCommands { - Count: number - Item: (Index: number) => DeviceCommand - } - - interface DeviceEvent { - Description: string - EventID: string - Name: string - Type: WiaEventFlag - } - - interface DeviceEvents { - Count: number - Item: (Index: number) => DeviceEvent - } - - interface DeviceInfo { - Connect: Device - DeviceID: string - Properties: Properties - Type: WiaDeviceType - } - - interface DeviceInfos { - Count: number - Item: (Index: any) => DeviceInfo - } - - interface DeviceManager { - DeviceInfos: DeviceInfos - RegisterEvent: (EventID: string, DeviceID?: string) => void - RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void - UnregisterEvent: (EventID: string, DeviceID?: string) => void - UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void - } - - interface Filter { - Description: string - FilterID: string - Name: string - Properties: Properties - } - - interface FilterInfo { - Description: string - FilterID: string - Name: string - } - - interface FilterInfos { - Count: number - Item: (Index: any) => FilterInfo - } - - interface Filters { - Add: (FilterID: string, Index?: number) => void - Count: number - Item: (Index: number) => Filter - Remove: (Index: number) => void - } - - interface Formats { - Count: number - Item: (Index: number) => string - } - - interface ImageFile { - ActiveFrame: number - ARGBData: Vector - FileData: Vector - FileExtension: string - FormatID: string - FrameCount: number - Height: number - HorizontalResolution: number - IsAlphaPixelFormat: boolean - IsAnimated: boolean - IsExtendedPixelFormat: boolean - IsIndexedPixelFormat: boolean - LoadFile: (Filename: string) => void - PixelDepth: number - Properties: Properties - SaveFile: (Filename: string) => void - VerticalResolution: number - Width: number - } - - interface ImageProcess { - Apply: (Source: ImageFile) => ImageFile - FilterInfos: FilterInfos - Filters: Filters - } - - interface Item { - Commands: DeviceCommands - ExecuteCommand: (CommandID: string) => Item - Formats: Formats - ItemID: string - Items: Items - Properties: Properties - Transfer: (FormatID?: string) => any - WiaItem: any /*VT_UNKNOWN*/ - } - - interface Items { - Add: (Name: string, Flags: number) => void - Count: number - Item: (Index: number) => Item - Remove: (Index: number) => void - } - - interface Properties { - Count: number - Exists: (Index: any) => boolean - Item: (Index: any) => Property - } - - interface Property { - IsReadOnly: boolean - IsVector: boolean - Name: string - PropertyID: number - SubType: WiaSubType - SubTypeDefault: any - SubTypeMax: number - SubTypeMin: number - SubTypeStep: number - SubTypeValues: Vector - Type: number - Value: any - } - - interface Rational { - Denominator: number - Numerator: number - Value: number - } - - interface Vector { - Add: (Value: any, Index?: number) => void - BinaryData: any - Clear: void - Count: number - Date: VarDate - ImageFile: (Width?: number, Height?: number) => ImageFile - Item: (Index: number) => any //Also has setter with parameters - Picture: (Width?: number, Height?: number) => any - Remove: (Index: number) => any - SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void - String: (Unicode?: boolean) => string - } - -} - -interface ActiveXObject { - new (progID: 'WIA.Rational'): WIA.Rational; - new (progID: 'WIA.Vector'): WIA.Vector; - new (progID: 'WIA.ImageFile'): WIA.ImageFile; - new (progID: 'WIA.ImageProcess'): WIA.ImageProcess; - new (progID: 'WIA.CommonDialog'): WIA.CommonDialog; - new (progID: 'WIA.DeviceManager'): WIA.DeviceManager; -} From 00e95cc6bb9ebbde03ddefc522e31d768b7bf4b4 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:20:45 +0200 Subject: [PATCH 4/7] fix test filename --- ts-activex/jscript-extensions-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 ts-activex/jscript-extensions-tests.ts diff --git a/ts-activex/jscript-extensions-tests.ts b/ts-activex/jscript-extensions-tests.ts new file mode 100644 index 0000000000..1e4fa6a41d --- /dev/null +++ b/ts-activex/jscript-extensions-tests.ts @@ -0,0 +1,5 @@ +/// + +var x: VarDate; +var dte = new Date(x); +x = dte.getVarDate(); \ No newline at end of file From 904225af50f930c4095c825382be184ed45bf10c Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:57:44 +0200 Subject: [PATCH 5/7] Rename jscript-extensions test file --- ts-activex/jscript-extensions.tests.ts | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 ts-activex/jscript-extensions.tests.ts diff --git a/ts-activex/jscript-extensions.tests.ts b/ts-activex/jscript-extensions.tests.ts deleted file mode 100644 index 1e4fa6a41d..0000000000 --- a/ts-activex/jscript-extensions.tests.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// - -var x: VarDate; -var dte = new Date(x); -x = dte.getVarDate(); \ No newline at end of file From 1a600158484cc6f0ad0cb92feb07e06803746fc3 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:58:00 +0200 Subject: [PATCH 6/7] Added semicolons after interface members --- .../microsoft-windows-image-acquisition.d.ts | 232 +++++++++--------- 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/ts-activex/microsoft-windows-image-acquisition.d.ts b/ts-activex/microsoft-windows-image-acquisition.d.ts index c35bb416df..ccae387346 100644 --- a/ts-activex/microsoft-windows-image-acquisition.d.ts +++ b/ts-activex/microsoft-windows-image-acquisition.d.ts @@ -187,185 +187,185 @@ declare namespace WIA { //Classes interface CommonDialog { - ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile - ShowAcquisitionWizard: (Device: Device) => any - ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void - ShowItemProperties: (Item: Item, CancelError?: boolean) => void - ShowPhotoPrintingWizard: (Files: any) => void - ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device - ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items - ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any + ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile; + ShowAcquisitionWizard: (Device: Device) => any; + ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void; + ShowItemProperties: (Item: Item, CancelError?: boolean) => void; + ShowPhotoPrintingWizard: (Files: any) => void; + ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device; + ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items; + ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any; } interface Device { - Commands: DeviceCommands - DeviceID: string - Events: DeviceEvents - ExecuteCommand: (CommandID: string) => Item - GetItem: (ItemID: string) => Item - Items: Items - Properties: Properties - Type: WiaDeviceType - WiaItem: any /*VT_UNKNOWN*/ + Commands: DeviceCommands; + DeviceID: string; + Events: DeviceEvents; + ExecuteCommand: (CommandID: string) => Item; + GetItem: (ItemID: string) => Item; + Items: Items; + Properties: Properties; + Type: WiaDeviceType; + WiaItem: any /*VT_UNKNOWN*/; } interface DeviceCommand { - CommandID: string - Description: string - Name: string + CommandID: string; + Description: string; + Name: string; } interface DeviceCommands { - Count: number - Item: (Index: number) => DeviceCommand + Count: number; + Item: (Index: number) => DeviceCommand; } interface DeviceEvent { - Description: string - EventID: string - Name: string - Type: WiaEventFlag + Description: string; + EventID: string; + Name: string; + Type: WiaEventFlag; } interface DeviceEvents { - Count: number - Item: (Index: number) => DeviceEvent + Count: number; + Item: (Index: number) => DeviceEvent; } interface DeviceInfo { - Connect: Device - DeviceID: string - Properties: Properties - Type: WiaDeviceType + Connect: () => Device; + DeviceID: string; + Properties: Properties; + Type: WiaDeviceType; } interface DeviceInfos { - Count: number - Item: (Index: any) => DeviceInfo + Count: number; + Item: (Index: any) => DeviceInfo; } interface DeviceManager { - DeviceInfos: DeviceInfos - RegisterEvent: (EventID: string, DeviceID?: string) => void - RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void - UnregisterEvent: (EventID: string, DeviceID?: string) => void - UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + DeviceInfos: DeviceInfos; + RegisterEvent: (EventID: string, DeviceID?: string) => void; + RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void; + UnregisterEvent: (EventID: string, DeviceID?: string) => void; + UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void; } interface Filter { - Description: string - FilterID: string - Name: string - Properties: Properties + Description: string; + FilterID: string; + Name: string; + Properties: Properties; } interface FilterInfo { - Description: string - FilterID: string - Name: string + Description: string; + FilterID: string; + Name: string; } interface FilterInfos { - Count: number - Item: (Index: any) => FilterInfo + Count: number; + Item: (Index: any) => FilterInfo; } interface Filters { - Add: (FilterID: string, Index?: number) => void - Count: number - Item: (Index: number) => Filter - Remove: (Index: number) => void + Add: (FilterID: string, Index?: number) => void; + Count: number; + Item: (Index: number) => Filter; + Remove: (Index: number) => void; } interface Formats { - Count: number - Item: (Index: number) => string + Count: number; + Item: (Index: number) => string; } interface ImageFile { - ActiveFrame: number - ARGBData: Vector - FileData: Vector - FileExtension: string - FormatID: string - FrameCount: number - Height: number - HorizontalResolution: number - IsAlphaPixelFormat: boolean - IsAnimated: boolean - IsExtendedPixelFormat: boolean - IsIndexedPixelFormat: boolean - LoadFile: (Filename: string) => void - PixelDepth: number - Properties: Properties - SaveFile: (Filename: string) => void - VerticalResolution: number - Width: number + ActiveFrame: number; + ARGBData: Vector; + FileData: Vector; + FileExtension: string; + FormatID: string; + FrameCount: number; + Height: number; + HorizontalResolution: number; + IsAlphaPixelFormat: boolean; + IsAnimated: boolean; + IsExtendedPixelFormat: boolean; + IsIndexedPixelFormat: boolean; + LoadFile: (Filename: string) => void; + PixelDepth: number; + Properties: Properties; + SaveFile: (Filename: string) => void; + VerticalResolution: number; + Width: number; } interface ImageProcess { - Apply: (Source: ImageFile) => ImageFile - FilterInfos: FilterInfos - Filters: Filters + Apply: (Source: ImageFile) => ImageFile; + FilterInfos: FilterInfos; + Filters: Filters; } interface Item { - Commands: DeviceCommands - ExecuteCommand: (CommandID: string) => Item - Formats: Formats - ItemID: string - Items: Items - Properties: Properties - Transfer: (FormatID?: string) => any - WiaItem: any /*VT_UNKNOWN*/ + Commands: DeviceCommands; + ExecuteCommand: (CommandID: string) => Item; + Formats: Formats; + ItemID: string; + Items: Items; + Properties: Properties; + Transfer: (FormatID?: string) => any; + WiaItem: any /*VT_UNKNOWN*/; } interface Items { - Add: (Name: string, Flags: number) => void - Count: number - Item: (Index: number) => Item - Remove: (Index: number) => void + Add: (Name: string, Flags: number) => void; + Count: number; + Item: (Index: number) => Item; + Remove: (Index: number) => void; } interface Properties { - Count: number - Exists: (Index: any) => boolean - Item: (Index: any) => Property + Count: number; + Exists: (Index: any) => boolean; + Item: (Index: any) => Property; } interface Property { - IsReadOnly: boolean - IsVector: boolean - Name: string - PropertyID: number - SubType: WiaSubType - SubTypeDefault: any - SubTypeMax: number - SubTypeMin: number - SubTypeStep: number - SubTypeValues: Vector - Type: number - Value: any + IsReadOnly: boolean; + IsVector: boolean; + Name: string; + PropertyID: number; + SubType: WiaSubType; + SubTypeDefault: any; + SubTypeMax: number; + SubTypeMin: number; + SubTypeStep: number; + SubTypeValues: Vector; + Type: number; + Value: any; } interface Rational { - Denominator: number - Numerator: number - Value: number + Denominator: number; + Numerator: number; + Value: number; } interface Vector { - Add: (Value: any, Index?: number) => void - BinaryData: any - Clear: void - Count: number - Date: VarDate - ImageFile: (Width?: number, Height?: number) => ImageFile - Item: (Index: number) => any //Also has setter with parameters - Picture: (Width?: number, Height?: number) => any - Remove: (Index: number) => any - SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void - String: (Unicode?: boolean) => string + Add: (Value: any, Index?: number) => void; + BinaryData: any; + Clear: () => void; + Count: number; + Date: VarDate; + ImageFile: (Width?: number, Height?: number) => ImageFile; + Item: (Index: number) => any //Also has setter with parameters; + Picture: (Width?: number, Height?: number) => any; + Remove: (Index: number) => any; + SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void; + String: (Unicode?: boolean) => string; } } From 1eb303df579ac8dd4b5b554a6a09ea599bc17414 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:58:15 +0200 Subject: [PATCH 7/7] Microsoft Scripting Runtime --- .../microsoft-scripting-runtime-tests.ts | 67 ++++++ ts-activex/microsoft-scripting-runtime.d.ts | 206 ++++++++++++++++++ 2 files changed, 273 insertions(+) create mode 100644 ts-activex/microsoft-scripting-runtime-tests.ts create mode 100644 ts-activex/microsoft-scripting-runtime.d.ts diff --git a/ts-activex/microsoft-scripting-runtime-tests.ts b/ts-activex/microsoft-scripting-runtime-tests.ts new file mode 100644 index 0000000000..623b48368a --- /dev/null +++ b/ts-activex/microsoft-scripting-runtime-tests.ts @@ -0,0 +1,67 @@ +/// + + +//source -- https://msdn.microsoft.com/en-us/library/ebkhfaaz.aspx + + +//Generates a string describing the drive type of a given Drive object. +var showDriveType = (drive: Scripting.Drive) => { + switch (drive.DriveType) { + case Scripting.DriveTypeConst.Removable: + return 'Removeable'; + case Scripting.DriveTypeConst.Fixed: + return 'Fixecd'; + case Scripting.DriveTypeConst.Remote: + return 'Network'; + case Scripting.DriveTypeConst.CDRom: + return 'CD-ROM'; + case Scripting.DriveTypeConst.RamDisk: + return 'RAM Disk'; + default: + return 'Unknown'; + } +}; + + +//Generates a string describing the attributes of a file or folder. +var showFileAttributes = (file: Scripting.File) => { + var attr = file.Attributes; + if (attr == 0) { + return 'Normal'; + } + var attributeStrings: string[] = []; + if (attr & Scripting.FileAttribute.Directory) { attributeStrings.push('Directory'); } + if (attr & Scripting.FileAttribute.ReadOnly) { attributeStrings.push('Read-only'); } + if (attr & Scripting.FileAttribute.Hidden) { attributeStrings.push('Hidden'); } + if (attr & Scripting.FileAttribute.System) { attributeStrings.push('System'); } + if (attr & Scripting.FileAttribute.Volume) { attributeStrings.push('Volume'); } + if (attr & Scripting.FileAttribute.Archive) { attributeStrings.push('Archive'); } + if (attr & Scripting.FileAttribute.Alias) { attributeStrings.push('Alias'); } + if (attr & Scripting.FileAttribute.Compressed) { attributeStrings.push('Compressed'); } + return attributeStrings.join(','); +}; + + +//source --https://msdn.microsoft.com/en-us/library/ts2t8ybh(v=vs.84).aspx +var showFreeSpace = (drvPath: string) => { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var d = fso.GetDrive(fso.GetDriveName(drvPath)); + var s = "Drive " + drvPath + " - "; + s += d.VolumeName + "
"; + s += "Free Space: " + d.FreeSpace / 1024 + " Kbytes"; + return (s); +}; + + +//source -- https://msdn.microsoft.com/en-us/library/kaf6yaft(v=vs.84).aspx +var getALine = (filespec: string) => { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false); + + var s = ""; + while (!file.AtEndOfLine) { + s += file.Read(1); + } + file.Close(); + return (s); +} \ No newline at end of file diff --git a/ts-activex/microsoft-scripting-runtime.d.ts b/ts-activex/microsoft-scripting-runtime.d.ts new file mode 100644 index 0000000000..0f2f734818 --- /dev/null +++ b/ts-activex/microsoft-scripting-runtime.d.ts @@ -0,0 +1,206 @@ +// Type definitions for Microsoft Scripting Runtime +// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7.aspx?f=255&MSPPError=-2147217396 +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Scripting { + + //Enums + const enum CompareMethod { + BinaryCompare = 0, + DatabaseCompare = 2, + TextCompare = 1 + } + + const enum DriveTypeConst { + CDRom = 4, + Fixed = 2, + RamDisk = 5, + Remote = 3, + Removable = 1, + UnknownType = 0 + } + + const enum FileAttribute { + Alias = 1024, + Archive = 32, + Compressed = 2048, + Directory = 16, + Hidden = 2, + Normal = 0, + ReadOnly = 1, + System = 4, + Volume = 8 + } + + const enum IOMode { + ForAppending = 8, + ForReading = 1, + ForWriting = 2 + } + + const enum SpecialFolderConst { + SystemFolder = 1, + TemporaryFolder = 2, + WindowsFolder = 0 + } + + const enum StandardStreamTypes { + StdErr = 2, + StdIn = 0, + StdOut = 1 + } + + const enum Tristate { + TristateFalse = 0, + TristateMixed = -2, + TristateTrue = -1, + TristateUseDefault = -2 + } + + //Classes + interface Dictionary { + Add: (Key: any, Item: any) => void; + CompareMode: CompareMethod; + Count: number; + Exists: (Key: any) => boolean; + HashVal: (Key: any) => any; + Item: (Key: any) => any //Also has setter with parameters; + Items: () => any; + Key: (Key: any) => any; + Keys: () => any; + Remove: (Key: any) => void; + RemoveAll: () => void; + } + + interface Drive { + AvailableSpace: any; + DriveLetter: string; + DriveType: DriveTypeConst; + FileSystem: string; + FreeSpace: any; + IsReady: boolean; + Path: string; + RootFolder: Folder; + SerialNumber: number; + ShareName: string; + TotalSize: any; + VolumeName: string; + } + + interface Drives { + Count: number; + Item: (Key: any) => Drive; + } + + interface Encoder { + EncodeScriptFile: (szExt: string, bstrStreamIn: string, cFlags: number, bstrDefaultLang: string) => string; + } + + interface File { + Attributes: FileAttribute; + Copy: (Destination: string, OverWriteFiles?: boolean) => void; + DateCreated: VarDate; + DateLastAccessed: VarDate; + DateLastModified: VarDate; + Delete: (Force?: boolean) => void; + Drive: Drive; + Move: (Destination: string) => void; + Name: string; + OpenAsTextStream: (IOMode?: IOMode, Format?: Tristate) => TextStream; + ParentFolder: Folder; + Path: string; + ShortName: string; + ShortPath: string; + Size: any; + Type: string; + } + + interface Files { + Count: number; + Item: (Key: any) => File; + } + + interface FileSystemObject { + BuildPath: (Path: string, Name: string) => string; + CopyFile: (Source: string, Destination: string, OverWriteFiles?: boolean) => void; + CopyFolder: (Source: string, Destination: string, OverWriteFiles?: boolean) => void; + CreateFolder: (Path: string) => Folder; + CreateTextFile: (FileName: string, Overwrite?: boolean, Unicode?: boolean) => TextStream; + DeleteFile: (FileSpec: string, Force?: boolean) => void; + DeleteFolder: (FolderSpec: string, Force?: boolean) => void; + DriveExists: (DriveSpec: string) => boolean; + Drives: Drives; + FileExists: (FileSpec: string) => boolean; + FolderExists: (FolderSpec: string) => boolean; + GetAbsolutePathName: (Path: string) => string; + GetBaseName: (Path: string) => string; + GetDrive: (DriveSpec: string) => Drive; + GetDriveName: (Path: string) => string; + GetExtensionName: (Path: string) => string; + GetFile: (FilePath: string) => File; + GetFileName: (Path: string) => string; + GetFileVersion: (FileName: string) => string; + GetFolder: (FolderPath: string) => Folder; + GetParentFolderName: (Path: string) => string; + GetSpecialFolder: (SpecialFolder: SpecialFolderConst) => Folder; + GetStandardStream: (StandardStreamType: StandardStreamTypes, Unicode?: boolean) => TextStream; + GetTempName: () => string; + MoveFile: (Source: string, Destination: string) => void; + MoveFolder: (Source: string, Destination: string) => void; + OpenTextFile: (FileName: string, IOMode?: IOMode, Create?: boolean, Format?: Tristate) => TextStream; + } + + interface Folder { + Attributes: FileAttribute; + Copy: (Destination: string, OverWriteFiles?: boolean) => void; + CreateTextFile: (FileName: string, Overwrite?: boolean, Unicode?: boolean) => TextStream; + DateCreated: VarDate; + DateLastAccessed: VarDate; + DateLastModified: VarDate; + Delete: (Force?: boolean) => void; + Drive: Drive; + Files: Files; + IsRootFolder: boolean; + Move: (Destination: string) => void; + Name: string; + ParentFolder: Folder; + Path: string; + ShortName: string; + ShortPath: string; + Size: any; + SubFolders: Folders; + Type: string; + } + + interface Folders { + Add: (Name: string) => Folder; + Count: number; + Item: (Key: any) => Folder; + } + + interface TextStream { + AtEndOfLine: boolean; + AtEndOfStream: boolean; + Close: () => void; + Column: number; + Line: number; + Read: (Characters: number) => string; + ReadAll: () => string; + ReadLine: () => string; + Skip: (Characters: number) => void; + SkipLine: () => void; + Write: (Text: string) => void; + WriteBlankLines: (Lines: number) => void; + WriteLine: (Text?: string) => void; + } + +} + +interface ActiveXObject { + new (progID: 'Scripting.Dictionary'): Scripting.Dictionary; + new (progID: 'Scripting.FileSystemObject'): Scripting.FileSystemObject; + new (progID: 'Scripting.Encoder'): Scripting.Encoder; +}