From ed48fab28e2f91d244fbc2b1fa3034fe5a54fa02 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Sun, 25 Jun 2017 23:03:34 +0200 Subject: [PATCH] Updated existing activex definitions --- .../activex-adodb-tests.ts} | 12 + .../index.d.ts | 433 +++++++---- types/activex-adodb/package.json | 1 + .../tsconfig.json | 13 +- types/activex-adodb/tslint.json | 1 + types/activex-scripting-runtime/index.d.ts | 205 ------ .../activex-scripting-tests.ts | 64 ++ .../activex-scripting.ts} | 0 types/activex-scripting/index.d.ts | 513 +++++++++++++ types/activex-scripting/package.json | 1 + .../tsconfig.json | 13 +- types/activex-scripting/tslint.json | 1 + .../activex-wia-tests.ts} | 6 +- types/activex-wia/index.d.ts | 697 ++++++++++++++++++ types/activex-wia/package.json | 1 + .../tsconfig.json | 13 +- types/activex-wia/tslint.json | 1 + .../index.d.ts | 379 ---------- 18 files changed, 1598 insertions(+), 756 deletions(-) rename types/{activex-data-objects/activex-data-objects-tests.ts => activex-adodb/activex-adodb-tests.ts} (69%) rename types/{activex-data-objects => activex-adodb}/index.d.ts (52%) create mode 100644 types/activex-adodb/package.json rename types/{activex-data-objects => activex-adodb}/tsconfig.json (55%) create mode 100644 types/activex-adodb/tslint.json delete mode 100644 types/activex-scripting-runtime/index.d.ts create mode 100644 types/activex-scripting/activex-scripting-tests.ts rename types/{activex-scripting-runtime/activex-scripting-runtime-tests.ts => activex-scripting/activex-scripting.ts} (100%) create mode 100644 types/activex-scripting/index.d.ts create mode 100644 types/activex-scripting/package.json rename types/{activex-scripting-runtime => activex-scripting}/tsconfig.json (54%) create mode 100644 types/activex-scripting/tslint.json rename types/{activex-windows-image-acquisition/activex-windows-image-acquisition-tests.ts => activex-wia/activex-wia-tests.ts} (95%) create mode 100644 types/activex-wia/index.d.ts create mode 100644 types/activex-wia/package.json rename types/{activex-windows-image-acquisition => activex-wia}/tsconfig.json (53%) create mode 100644 types/activex-wia/tslint.json delete mode 100644 types/activex-windows-image-acquisition/index.d.ts diff --git a/types/activex-data-objects/activex-data-objects-tests.ts b/types/activex-adodb/activex-adodb-tests.ts similarity index 69% rename from types/activex-data-objects/activex-data-objects-tests.ts rename to types/activex-adodb/activex-adodb-tests.ts index 6298298a48..341bf83108 100644 --- a/types/activex-data-objects/activex-data-objects-tests.ts +++ b/types/activex-adodb/activex-adodb-tests.ts @@ -1,3 +1,15 @@ +let obj0 = new ActiveXObject('ADODB.Command'); + +let obj1 = new ActiveXObject('ADODB.Connection'); + +let obj2 = new ActiveXObject('ADODB.Parameter'); + +let obj3 = new ActiveXObject('ADODB.Record'); + +let obj4 = new ActiveXObject('ADODB.Recordset'); + +let obj5 = new ActiveXObject('ADODB.Stream'); + //open connection to an Excel file var pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx'; var conn = new ActiveXObject('ADODB.Connection'); diff --git a/types/activex-data-objects/index.d.ts b/types/activex-adodb/index.d.ts similarity index 52% rename from types/activex-data-objects/index.d.ts rename to types/activex-adodb/index.d.ts index d3ccf7a6c7..8d6190363a 100644 --- a/types/activex-data-objects/index.d.ts +++ b/types/activex-adodb/index.d.ts @@ -1,8 +1,7 @@ -// Type definitions for Microsoft ActiveX Data Objects -// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms675532(v=vs.85).aspx -// Definitions by: Zev Spitz +// Type definitions for ADODB - +// Project: https://msdn.microsoft.com/en-us/library/jj249010.aspx +// Defintions by: Zev Spitz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare namespace ADODB { //Enums @@ -598,237 +597,391 @@ declare namespace ADODB { //Interfaces interface Command { ActiveConnection: Connection; - Cancel: () => void; - CommandStream: any /*VT_UNKNOWN*/; + Cancel(): void; + CommandStream: any; CommandText: string; CommandTimeout: number; CommandType: CommandTypeEnum; - CreateParameter: (Name?: string, Type?: DataTypeEnum, Direction?: ParameterDirectionEnum, Size?: number, Value?: any) => Parameter; + + /** + * @param string [Name=''] + * @param ADODB.DataTypeEnum [Type=0] + * @param ADODB.ParameterDirectionEnum [Direction=1] + * @param number [Size=0] + */ + CreateParameter(Name?: string, Type?: DataTypeEnum, Direction?: ParameterDirectionEnum, Size?: number, Value?: any): Parameter; Dialect: string; - Execute: (RecordsAffected?: any, Parameters?: any, Options?: number) => Recordset; + + /** @param number [Options=-1] */ + Execute(RecordsAffected?: any, Parameters?: any[], Options?: number): Recordset; Name: string; NamedParameters: boolean; - Parameters: Parameters; + readonly Parameters: Parameters; Prepared: boolean; - Properties: Properties; - State: number; + readonly Properties: Properties; + readonly State: number; } interface Connection { Attributes: number; - BeginTrans: () => number; - Cancel: () => void; - Close: () => void; + BeginTrans(): number; + Cancel(): void; + Close(): void; CommandTimeout: number; - CommitTrans: () => void; + CommitTrans(): void; ConnectionString: string; ConnectionTimeout: number; CursorLocation: CursorLocationEnum; DefaultDatabase: string; - Errors: Errors; - Execute: (CommandText: string, RecordsAffected: any, Options?: number) => Recordset; + readonly Errors: Errors; + + /** @param number [Options=-1] */ + Execute(CommandText: string, RecordsAffected: any, Options?: number): Recordset; IsolationLevel: IsolationLevelEnum; Mode: ConnectModeEnum; - Open: (ConnectionString?: string, UserID?: string, Password?: string, Options?: number) => void; - OpenSchema: (Schema: SchemaEnum, Restrictions?: any, SchemaID?: any) => Recordset; - Properties: Properties; + + /** + * @param string [ConnectionString=''] + * @param string [UserID=''] + * @param string [Password=''] + * @param number [Options=-1] + */ + Open(ConnectionString?: string, UserID?: string, Password?: string, Options?: number): void; + OpenSchema(Schema: SchemaEnum, Restrictions?: any, SchemaID?: any): Recordset; + readonly Properties: Properties; Provider: string; - RollbackTrans: () => void; - State: number; - Version: string; + RollbackTrans(): void; + readonly State: number; + readonly Version: string; } interface Error { - Description: string; - HelpContext: number; - HelpFile: string; - NativeError: number; - Number: number; - Source: string; - SQLState: string; + readonly Description: string; + readonly HelpContext: number; + readonly HelpFile: string; + readonly NativeError: number; + readonly Number: number; + readonly Source: string; + readonly SQLState: string; } interface Errors { - Clear: () => void; - Count: number; - Item: (Index: any) => Error; - Refresh: () => void; + Clear(): void; + readonly Count: number; + Item(Index: any): Error; + Refresh(): void; } interface Field { - ActualSize: number; - AppendChunk: (Data: any) => void; + readonly ActualSize: number; + AppendChunk(Data: any): void; Attributes: number; - DataFormat: any /*VT_UNKNOWN*/; + DataFormat: any; DefinedSize: number; - GetChunk: (Length: number) => any; - Name: string; + GetChunk(Length: number): any; + readonly Name: string; NumericScale: number; - OriginalValue: any; + readonly OriginalValue: any; Precision: number; - Properties: Properties; - Status: number; + readonly Properties: Properties; + readonly Status: number; Type: DataTypeEnum; - UnderlyingValue: any; + readonly UnderlyingValue: any; Value: any; } interface Fields { - _Append: (Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum) => void; - Append: (Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum, FieldValue?: any) => void; - CancelUpdate: () => void; - Count: number; - Delete: (Index: any) => void; - Item: (Index: any) => Field; - Refresh: () => void; - Resync: (ResyncValues?: ResyncEnum) => void; - Update: () => void; + + /** + * @param number [DefinedSize=0] + * @param ADODB.FieldAttributeEnum [Attrib=-1] + */ + _Append(Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum): void; + + /** + * @param number [DefinedSize=0] + * @param ADODB.FieldAttributeEnum [Attrib=-1] + */ + Append(Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum, FieldValue?: any): void; + CancelUpdate(): void; + readonly Count: number; + Delete(Index: any): void; + Item(Index: any): Field; + Refresh(): void; + + /** @param ADODB.ResyncEnum [ResyncValues=2] */ + Resync(ResyncValues?: ResyncEnum): void; + Update(): void; } interface Parameter { - AppendChunk: (Val: any) => void; + AppendChunk(Val: any): void; Attributes: number; Direction: ParameterDirectionEnum; Name: string; NumericScale: number; Precision: number; - Properties: Properties; + readonly Properties: Properties; Size: number; Type: DataTypeEnum; Value: any; } interface Parameters { - Append: (Object: any /*VT_DISPATCH*/) => void; - Count: number; - Delete: (Index: any) => void; - Item: (Index: any) => Parameter; - Refresh: () => void; + Append(Object: any): void; + readonly Count: number; + Delete(Index: any): void; + Item(Index: any): Parameter; + Refresh(): void; } interface Properties { - Count: number; - Item: (Index: any) => Property; - Refresh: () => void; + readonly Count: number; + Item(Index: any): Property; + Refresh(): void; } interface Property { Attributes: number; - Name: string; - Type: DataTypeEnum; + readonly Name: string; + readonly Type: DataTypeEnum; Value: any; } interface Record { ActiveConnection: any; - Cancel: () => void; - Close: () => void; - CopyRecord: (Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: CopyRecordOptionsEnum, Async?: boolean) => string; - DeleteRecord: (Source?: string, Async?: boolean) => void; - Fields: Fields; - GetChildren: () => Recordset; + Cancel(): void; + Close(): void; + + /** + * @param string [Source=''] + * @param string [Destination=''] + * @param string [UserName=''] + * @param string [Password=''] + * @param ADODB.CopyRecordOptionsEnum [Options=-1] + * @param boolean [Async=false] + */ + CopyRecord(Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: CopyRecordOptionsEnum, Async?: boolean): string; + + /** + * @param string [Source=''] + * @param boolean [Async=false] + */ + DeleteRecord(Source?: string, Async?: boolean): void; + readonly Fields: Fields; + GetChildren(): Recordset; Mode: ConnectModeEnum; - MoveRecord: (Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: MoveRecordOptionsEnum, Async?: boolean) => string; - Open: (Source: any, ActiveConnection: any, Mode?: ConnectModeEnum, CreateOptions?: RecordCreateOptionsEnum, Options?: RecordOpenOptionsEnum, UserName?: string, Password?: string) => void; - ParentURL: string; - Properties: Properties; - RecordType: RecordTypeEnum; + + /** + * @param string [Source=''] + * @param string [Destination=''] + * @param string [UserName=''] + * @param string [Password=''] + * @param ADODB.MoveRecordOptionsEnum [Options=-1] + * @param boolean [Async=false] + */ + MoveRecord(Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: MoveRecordOptionsEnum, Async?: boolean): string; + + /** + * @param ADODB.ConnectModeEnum [Mode=0] + * @param ADODB.RecordCreateOptionsEnum [CreateOptions=-1] + * @param ADODB.RecordOpenOptionsEnum [Options=-1] + * @param string [UserName=''] + * @param string [Password=''] + */ + Open(Source: any, ActiveConnection: any, Mode?: ConnectModeEnum, CreateOptions?: RecordCreateOptionsEnum, Options?: RecordOpenOptionsEnum, UserName?: string, Password?: string): void; + readonly ParentURL: string; + readonly Properties: Properties; + readonly RecordType: RecordTypeEnum; Source: any; - State: ObjectStateEnum; + readonly State: ObjectStateEnum; } interface Recordset { - _xClone: () => Recordset; - _xResync: (AffectRecords?: AffectEnum) => void; - _xSave: (FileName?: string, PersistFormat?: PersistFormatEnum) => void; + _xClone(): Recordset; + + /** @param ADODB.AffectEnum [AffectRecords=3] */ + _xResync(AffectRecords?: AffectEnum): void; + + /** + * @param string [FileName=''] + * @param ADODB.PersistFormatEnum [PersistFormat=0] + */ + _xSave(FileName?: string, PersistFormat?: PersistFormatEnum): void; AbsolutePage: PositionEnum; AbsolutePosition: PositionEnum; - ActiveCommand: any /*VT_DISPATCH*/; - ActiveConnection: any /*VT_DISPATCH*/; - AddNew: (FieldList?: any, Values?: any) => void; - BOF: boolean; + readonly ActiveCommand: any; + ActiveConnection: any; + AddNew(FieldList?: any, Values?: any): void; + readonly BOF: boolean; Bookmark: any; CacheSize: number; - Cancel: () => void; - CancelBatch: (AffectRecords?: AffectEnum) => void; - CancelUpdate: () => void; - Clone: (LockType?: LockTypeEnum) => Recordset; - Close: () => void; - Collect: (Index: any) => any; //Also has setter with parameters - CompareBookmarks: (Bookmark1: any, Bookmark2: any) => CompareEnum; + Cancel(): void; + + /** @param ADODB.AffectEnum [AffectRecords=3] */ + CancelBatch(AffectRecords?: AffectEnum): void; + CancelUpdate(): void; + + /** @param ADODB.LockTypeEnum [LockType=-1] */ + Clone(LockType?: LockTypeEnum): Recordset; + Close(): void; + Collect(Index: any): any; + CompareBookmarks(Bookmark1: any, Bookmark2: any): CompareEnum; CursorLocation: CursorLocationEnum; CursorType: CursorTypeEnum; DataMember: string; - DataSource: any /*VT_UNKNOWN*/; - Delete: (AffectRecords?: AffectEnum) => void; - EditMode: EditModeEnum; - EOF: boolean; - Fields: Fields; + DataSource: any; + + /** @param ADODB.AffectEnum [AffectRecords=1] */ + Delete(AffectRecords?: AffectEnum): void; + readonly EditMode: EditModeEnum; + readonly EOF: boolean; + readonly Fields: Fields; Filter: any; - Find: (Criteria: string, SkipRecords?: number, SearchDirection?: SearchDirectionEnum, Start?: any) => void; - GetRows: (Rows?: number, Start?: any, Fields?: any) => any; - GetString: (StringFormat?: StringFormatEnum, NumRows?: number, ColumnDelimeter?: string, RowDelimeter?: string, NullExpr?: string) => string; + + /** + * @param number [SkipRecords=0] + * @param ADODB.SearchDirectionEnum [SearchDirection=1] + */ + Find(Criteria: string, SkipRecords?: number, SearchDirection?: SearchDirectionEnum, Start?: any): void; + + /** @param number [Rows=-1] */ + GetRows(Rows?: number, Start?: any, Fields?: any): any; + + /** + * @param ADODB.StringFormatEnum [StringFormat=2] + * @param number [NumRows=-1] + * @param string [ColumnDelimeter=''] + * @param string [RowDelimeter=''] + * @param string [NullExpr=''] + */ + GetString(StringFormat?: StringFormatEnum, NumRows?: number, ColumnDelimeter?: string, RowDelimeter?: string, NullExpr?: string): string; Index: string; LockType: LockTypeEnum; MarshalOptions: MarshalOptionsEnum; MaxRecords: number; - Move: (NumRecords: number, Start?: any) => void; - MoveFirst: () => void; - MoveLast: () => void; - MoveNext: () => void; - MovePrevious: () => void; - NextRecordset: (RecordsAffected?: any) => Recordset; - Open: (Source: any, ActiveConnection: any, CursorType?: CursorTypeEnum, LockType?: LockTypeEnum, Options?: number) => void; - PageCount: number; + Move(NumRecords: number, Start?: any): void; + MoveFirst(): void; + MoveLast(): void; + MoveNext(): void; + MovePrevious(): void; + NextRecordset(RecordsAffected?: any): Recordset; + + /** + * @param ADODB.CursorTypeEnum [CursorType=-1] + * @param ADODB.LockTypeEnum [LockType=-1] + * @param number [Options=-1] + */ + Open(Source: any, ActiveConnection: any, CursorType?: CursorTypeEnum, LockType?: LockTypeEnum, Options?: number): void; + readonly PageCount: number; PageSize: number; - Properties: Properties; - RecordCount: number; - Requery: (Options?: number) => void; - Resync: (AffectRecords?: AffectEnum, ResyncValues?: ResyncEnum) => void; - Save: (Destination: any, PersistFormat?: PersistFormatEnum) => void; - Seek: (KeyValues: any, SeekOption?: SeekEnum) => void; + readonly Properties: Properties; + readonly RecordCount: number; + + /** @param number [Options=-1] */ + Requery(Options?: number): void; + + /** + * @param ADODB.AffectEnum [AffectRecords=3] + * @param ADODB.ResyncEnum [ResyncValues=2] + */ + Resync(AffectRecords?: AffectEnum, ResyncValues?: ResyncEnum): void; + + /** @param ADODB.PersistFormatEnum [PersistFormat=0] */ + Save(Destination: any, PersistFormat?: PersistFormatEnum): void; + + /** @param ADODB.SeekEnum [SeekOption=1] */ + Seek(KeyValues: any, SeekOption?: SeekEnum): void; Sort: string; - Source: any /*VT_DISPATCH*/; - State: number; - Status: number; + Source: any; + readonly State: number; + readonly Status: number; StayInSync: boolean; - Supports: (CursorOptions: CursorOptionEnum) => boolean; - Update: (Fields?: any, Values?: any) => void; - UpdateBatch: (AffectRecords?: AffectEnum) => void; + Supports(CursorOptions: CursorOptionEnum): boolean; + Update(Fields?: any, Values?: any): void; + + /** @param ADODB.AffectEnum [AffectRecords=3] */ + UpdateBatch(AffectRecords?: AffectEnum): void; } interface Stream { - Cancel: () => void; + Cancel(): void; Charset: string; - Close: () => void; - CopyTo: (DestStream: Stream, CharNumber?: number) => void; - EOS: boolean; - Flush: () => void; + Close(): void; + + /** @param number [CharNumber=-1] */ + CopyTo(DestStream: Stream, CharNumber?: number): void; + readonly EOS: boolean; + Flush(): void; LineSeparator: LineSeparatorEnum; - LoadFromFile: (FileName: string) => void; + LoadFromFile(FileName: string): void; Mode: ConnectModeEnum; - Open: (Source: any, Mode?: ConnectModeEnum, Options?: StreamOpenOptionsEnum, UserName?: string, Password?: string) => void; + + /** + * @param ADODB.ConnectModeEnum [Mode=0] + * @param ADODB.StreamOpenOptionsEnum [Options=-1] + * @param string [UserName=''] + * @param string [Password=''] + */ + Open(Source: any, Mode?: ConnectModeEnum, Options?: StreamOpenOptionsEnum, UserName?: string, Password?: string): void; Position: number; - Read: (NumBytes?: number) => any; - ReadText: (NumChars?: number) => string; - SaveToFile: (FileName: string, Options?: SaveOptionsEnum) => void; - SetEOS: () => void; - Size: number; - SkipLine: () => void; - State: ObjectStateEnum; + + /** @param number [NumBytes=-1] */ + Read(NumBytes?: number): any; + + /** @param number [NumChars=-1] */ + ReadText(NumChars?: number): string; + + /** @param ADODB.SaveOptionsEnum [Options=1] */ + SaveToFile(FileName: string, Options?: SaveOptionsEnum): void; + SetEOS(): void; + readonly Size: number; + SkipLine(): void; + readonly State: ObjectStateEnum; Type: StreamTypeEnum; - Write: (Buffer: any) => void; - WriteText: (Data: string, Options?: StreamWriteEnum) => void; + Write(Buffer: any): void; + + /** @param ADODB.StreamWriteEnum [Options=0] */ + WriteText(Data: string, Options?: StreamWriteEnum): void; } } +//Global interfaces interface ActiveXObject { - new (progID: 'ADODB.Connection'): ADODB.Connection; - new (progID: 'ADODB.Record'): ADODB.Record; - new (progID: 'ADODB.Stream'): ADODB.Stream; - new (progID: 'ADODB.Command'): ADODB.Command; - new (progID: 'ADODB.Recordset'): ADODB.Recordset; - new (progID: 'ADODB.Parameter'): ADODB.Parameter; + on(obj: ADODB.Connection, eventName: 'BeginTransComplete', eventArgs: ['TransactionLevel', 'pError', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {TransactionLevel: number, pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'CommitTransComplete', eventArgs: ['pError', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'ConnectComplete', eventArgs: ['pError', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'Disconnect', eventArgs: ['adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {adStatus: ADODB.EventStatusEnum, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'ExecuteComplete', eventArgs: ['RecordsAffected', 'pError', 'adStatus', 'pCommand', 'pRecordset', 'pConnection'], handler: (this: ADODB.Connection, parameter: {RecordsAffected: number, pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pCommand: ADODB.Command, pRecordset: ADODB.Recordset, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'InfoMessage', eventArgs: ['pError', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'RollbackTransComplete', eventArgs: ['pError', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'WillConnect', eventArgs: ['ConnectionString', 'UserID', 'Password', 'Options', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {ConnectionString: string, UserID: string, Password: string, Options: number, adStatus: ADODB.EventStatusEnum, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Connection, eventName: 'WillExecute', eventArgs: ['Source', 'CursorType', 'LockType', 'Options', 'adStatus', 'pCommand', 'pRecordset', 'pConnection'], handler: (this: ADODB.Connection, parameter: {Source: string, CursorType: ADODB.CursorTypeEnum, LockType: ADODB.LockTypeEnum, Options: number, adStatus: ADODB.EventStatusEnum, pCommand: ADODB.Command, pRecordset: ADODB.Recordset, pConnection: ADODB.Connection}) => void): void; + on(obj: ADODB.Recordset, eventName: 'EndOfRecordset', eventArgs: ['fMoreData', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {fMoreData: boolean, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'FetchComplete', eventArgs: ['pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'FetchProgress', eventArgs: ['Progress', 'MaxProgress', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {Progress: number, MaxProgress: number, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'FieldChangeComplete', eventArgs: ['cFields', 'Fields', 'pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {cFields: number, Fields: any, pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'MoveComplete', eventArgs: ['adReason', 'pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {adReason: ADODB.EventReasonEnum, pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'RecordChangeComplete', eventArgs: ['adReason', 'cRecords', 'pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {adReason: ADODB.EventReasonEnum, cRecords: number, pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'RecordsetChangeComplete', eventArgs: ['adReason', 'pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {adReason: ADODB.EventReasonEnum, pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'WillChangeField', eventArgs: ['cFields', 'Fields', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {cFields: number, Fields: any, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'WillChangeRecord', eventArgs: ['adReason', 'cRecords', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {adReason: ADODB.EventReasonEnum, cRecords: number, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'WillChangeRecordset', eventArgs: ['adReason', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {adReason: ADODB.EventReasonEnum, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + on(obj: ADODB.Recordset, eventName: 'WillMove', eventArgs: ['adReason', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {adReason: ADODB.EventReasonEnum, adStatus: ADODB.EventStatusEnum, pRecordset: ADODB.Recordset}) => void): void; + set(obj: ADODB.Recordset, propertyName: 'Collect', parameterTypes: [any], newValue: any): void; + new(progid: 'ADODB.Command'): ADODB.Command; + new(progid: 'ADODB.Connection'): ADODB.Connection; + new(progid: 'ADODB.Parameter'): ADODB.Parameter; + new(progid: 'ADODB.Record'): ADODB.Record; + new(progid: 'ADODB.Recordset'): ADODB.Recordset; + new(progid: 'ADODB.Stream'): ADODB.Stream; +} + +interface EnumeratorConstructor { + new(col: ADODB.Errors): ADODB.Error; + new(col: ADODB.Fields): ADODB.Field; + new(col: ADODB.Parameters): ADODB.Parameter; + new(col: ADODB.Properties): ADODB.Property; } diff --git a/types/activex-adodb/package.json b/types/activex-adodb/package.json new file mode 100644 index 0000000000..d798f99261 --- /dev/null +++ b/types/activex-adodb/package.json @@ -0,0 +1 @@ +{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file diff --git a/types/activex-data-objects/tsconfig.json b/types/activex-adodb/tsconfig.json similarity index 55% rename from types/activex-data-objects/tsconfig.json rename to types/activex-adodb/tsconfig.json index aa81742f09..22b6f9e045 100644 --- a/types/activex-data-objects/tsconfig.json +++ b/types/activex-adodb/tsconfig.json @@ -1,14 +1,9 @@ + { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6", - "dom", - "scripthost" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, + "lib": ["scripthost"], + "strict": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,6 +14,6 @@ }, "files": [ "index.d.ts", - "activex-data-objects-tests.ts" + "activex-adodb-tests.ts" ] } \ No newline at end of file diff --git a/types/activex-adodb/tslint.json b/types/activex-adodb/tslint.json new file mode 100644 index 0000000000..1d0e17119e --- /dev/null +++ b/types/activex-adodb/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint / dt.json" } \ No newline at end of file diff --git a/types/activex-scripting-runtime/index.d.ts b/types/activex-scripting-runtime/index.d.ts deleted file mode 100644 index 54065e1bd7..0000000000 --- a/types/activex-scripting-runtime/index.d.ts +++ /dev/null @@ -1,205 +0,0 @@ -// Type definitions for Microsoft Scripting Runtime -// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7.aspx -// 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 - } - - //Interfaces - 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; -} - diff --git a/types/activex-scripting/activex-scripting-tests.ts b/types/activex-scripting/activex-scripting-tests.ts new file mode 100644 index 0000000000..6b460f6347 --- /dev/null +++ b/types/activex-scripting/activex-scripting-tests.ts @@ -0,0 +1,64 @@ +//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/types/activex-scripting-runtime/activex-scripting-runtime-tests.ts b/types/activex-scripting/activex-scripting.ts similarity index 100% rename from types/activex-scripting-runtime/activex-scripting-runtime-tests.ts rename to types/activex-scripting/activex-scripting.ts diff --git a/types/activex-scripting/index.d.ts b/types/activex-scripting/index.d.ts new file mode 100644 index 0000000000..55bf6bd661 --- /dev/null +++ b/types/activex-scripting/index.d.ts @@ -0,0 +1,513 @@ +// Type definitions for Scripting - +// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7.aspx +// Defintions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare namespace Scripting { + + //Enums + const enum __MIDL___MIDL_itf_scrrun_0000_0000_0001 { + Alias = 1024, + Archive = 32, + Compressed = 2048, + Directory = 16, + Hidden = 2, + Normal = 0, + ReadOnly = 1, + System = 4, + Volume = 8 + } + + const enum __MIDL___MIDL_itf_scrrun_0001_0001_0001 { + CDRom = 4, + Fixed = 2, + RamDisk = 5, + Remote = 3, + Removable = 1, + UnknownType = 0 + } + + const enum __MIDL___MIDL_itf_scrrun_0001_0001_0002 { + SystemFolder = 1, + TemporaryFolder = 2, + WindowsFolder = 0 + } + + const enum __MIDL___MIDL_itf_scrrun_0001_0001_0003 { + StdErr = 2, + StdIn = 0, + StdOut = 1 + } + + 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 + } + + //Interfaces + /** Scripting.Dictionary */ + interface Dictionary { + + /** Add a new key and item to the dictionary. */ + Add(Key: any, Item: any): void; + + /** Set or get the string comparison method. */ + CompareMode: CompareMethod; + + /** Get the number of items in the dictionary. */ + readonly Count: number; + + /** Determine if a given key is in the dictionary. */ + Exists(Key: any): boolean; + HashVal(Key: any): any; + + /** Set or get the item for a given key */ + Item(Key: any): any; + + /** Get an array containing all items in the dictionary. */ + Items(): any; + + /** Change a key to a different key. */ + Key(Key: any): any; + + /** Get an array containing all keys in the dictionary. */ + Keys(): any; + + /** Remove a given key from the dictionary. */ + Remove(Key: any): void; + + /** Remove all information from the dictionary. */ + RemoveAll(): void; + } + + /** Drive Object */ + interface Drive { + + /** Get available space */ + readonly AvailableSpace: any; + + /** Drive letter */ + readonly DriveLetter: string; + + /** Drive type */ + readonly DriveType: DriveTypeConst; + + /** Filesystem type */ + readonly FileSystem: string; + + /** Get drive free space */ + readonly FreeSpace: any; + + /** Check if disk is available */ + readonly IsReady: boolean; + + /** Path */ + readonly Path: string; + + /** Root folder */ + readonly RootFolder: Folder; + + /** Serial number */ + readonly SerialNumber: number; + + /** Share name */ + readonly ShareName: string; + + /** Get total drive size */ + readonly TotalSize: any; + + /** Name of volume */ + VolumeName: string; + } + + /** Collection of drives associated with drive letters */ + interface Drives { + + /** Number of drives */ + readonly Count: number; + + /** Get drive */ + Item(Key: any): Drive; + } + + /** Script Encoder Object */ + interface Encoder { + + /** Call the Encoder determined by szExt, passing bstrStreamIn and optional arguments */ + EncodeScriptFile(szExt: string, bstrStreamIn: string, cFlags: number, bstrDefaultLang: string): string; + } + + /** File object */ + interface File { + + /** File attributes */ + Attributes: FileAttribute; + + /** + * Copy this file + * @param boolean [OverWriteFiles=true] + */ + Copy(Destination: string, OverWriteFiles?: boolean): void; + + /** Date file was created */ + readonly DateCreated: VarDate; + + /** Date file was last accessed */ + readonly DateLastAccessed: VarDate; + + /** Date file was last modified */ + readonly DateLastModified: VarDate; + + /** + * Delete this file + * @param boolean [Force=false] + */ + Delete(Force?: boolean): void; + + /** Get drive that contains file */ + readonly Drive: Drive; + + /** Move this file */ + Move(Destination: string): void; + + /** Get name of file */ + Name: string; + + /** + * Open a file as a TextStream + * @param Scripting.IOMode [IOMode=1] + * @param Scripting.Tristate [Format=0] + */ + OpenAsTextStream(IOMode?: IOMode, Format?: Tristate): TextStream; + + /** Get folder that contains file */ + readonly ParentFolder: Folder; + + /** Path to the file */ + readonly Path: string; + + /** Short name */ + readonly ShortName: string; + + /** Short path */ + readonly ShortPath: string; + + /** File size */ + readonly Size: any; + + /** Type description */ + readonly Type: string; + } + + /** Collection of files in a folder */ + interface Files { + + /** Number of folders */ + readonly Count: number; + + /** Get file */ + Item(Key: any): File; + } + + /** FileSystem Object */ + interface FileSystemObject { + + /** Generate a path from an existing path and a name */ + BuildPath(Path: string, Name: string): string; + + /** + * Copy a file + * @param boolean [OverWriteFiles=true] + */ + CopyFile(Source: string, Destination: string, OverWriteFiles?: boolean): void; + + /** + * Copy a folder + * @param boolean [OverWriteFiles=true] + */ + CopyFolder(Source: string, Destination: string, OverWriteFiles?: boolean): void; + + /** Create a folder */ + CreateFolder(Path: string): Folder; + + /** + * Create a file as a TextStream + * @param boolean [Overwrite=true] + * @param boolean [Unicode=false] + */ + CreateTextFile(FileName: string, Overwrite?: boolean, Unicode?: boolean): TextStream; + + /** + * Delete a file + * @param boolean [Force=false] + */ + DeleteFile(FileSpec: string, Force?: boolean): void; + + /** + * Delete a folder + * @param boolean [Force=false] + */ + DeleteFolder(FolderSpec: string, Force?: boolean): void; + + /** Check if a drive or a share exists */ + DriveExists(DriveSpec: string): boolean; + + /** Get drives collection */ + readonly Drives: Drives; + + /** Check if a file exists */ + FileExists(FileSpec: string): boolean; + + /** Check if a path exists */ + FolderExists(FolderSpec: string): boolean; + + /** Return the canonical representation of the path */ + GetAbsolutePathName(Path: string): string; + + /** Return base name from a path */ + GetBaseName(Path: string): string; + + /** Get drive or UNC share */ + GetDrive(DriveSpec: string): Drive; + + /** Return drive from a path */ + GetDriveName(Path: string): string; + + /** Return extension from path */ + GetExtensionName(Path: string): string; + + /** Get file */ + GetFile(FilePath: string): File; + + /** Return the file name from a path */ + GetFileName(Path: string): string; + + /** Retrieve the file version of the specified file into a string */ + GetFileVersion(FileName: string): string; + + /** Get folder */ + GetFolder(FolderPath: string): Folder; + + /** Return path to the parent folder */ + GetParentFolderName(Path: string): string; + + /** Get location of various system folders */ + GetSpecialFolder(SpecialFolder: SpecialFolderConst): Folder; + + /** + * Retrieve the standard input, output or error stream + * @param boolean [Unicode=false] + */ + GetStandardStream(StandardStreamType: StandardStreamTypes, Unicode?: boolean): TextStream; + + /** Generate name that can be used to name a temporary file */ + GetTempName(): string; + + /** Move a file */ + MoveFile(Source: string, Destination: string): void; + + /** Move a folder */ + MoveFolder(Source: string, Destination: string): void; + + /** + * Open a file as a TextStream + * @param Scripting.IOMode [IOMode=1] + * @param boolean [Create=false] + * @param Scripting.Tristate [Format=0] + */ + OpenTextFile(FileName: string, IOMode?: IOMode, Create?: boolean, Format?: Tristate): TextStream; + } + + /** Folder object */ + interface Folder { + + /** Folder attributes */ + Attributes: FileAttribute; + + /** + * Copy this folder + * @param boolean [OverWriteFiles=true] + */ + Copy(Destination: string, OverWriteFiles?: boolean): void; + + /** + * Create a file as a TextStream + * @param boolean [Overwrite=true] + * @param boolean [Unicode=false] + */ + CreateTextFile(FileName: string, Overwrite?: boolean, Unicode?: boolean): TextStream; + + /** Date folder was created */ + readonly DateCreated: VarDate; + + /** Date folder was last accessed */ + readonly DateLastAccessed: VarDate; + + /** Date folder was last modified */ + readonly DateLastModified: VarDate; + + /** + * Delete this folder + * @param boolean [Force=false] + */ + Delete(Force?: boolean): void; + + /** Get drive that contains folder */ + readonly Drive: Drive; + + /** Get files collection */ + readonly Files: Files; + + /** True if folder is root */ + readonly IsRootFolder: boolean; + + /** Move this folder */ + Move(Destination: string): void; + + /** Get name of folder */ + Name: string; + + /** Get parent folder */ + readonly ParentFolder: Folder; + + /** Path to folder */ + readonly Path: string; + + /** Short name */ + readonly ShortName: string; + + /** Short path */ + readonly ShortPath: string; + + /** Sum of files and subfolders */ + readonly Size: any; + + /** Get folders collection */ + readonly SubFolders: Folders; + + /** Type description */ + readonly Type: string; + } + + /** Collection of subfolders in a folder */ + interface Folders { + + /** Create a new folder */ + Add(Name: string): Folder; + + /** Number of folders */ + readonly Count: number; + + /** Get folder */ + Item(Key: any): Folder; + } + + /** TextStream object */ + interface TextStream { + + /** Is the current position at the end of a line? */ + readonly AtEndOfLine: boolean; + + /** Is the current position at the end of the stream? */ + readonly AtEndOfStream: boolean; + + /** Close a text stream */ + Close(): void; + + /** Current column number */ + readonly Column: number; + + /** Current line number */ + readonly Line: number; + + /** Read a specific number of characters into a string */ + Read(Characters: number): string; + + /** Read the entire stream into a string */ + ReadAll(): string; + + /** Read an entire line into a string */ + ReadLine(): string; + + /** Skip a specific number of characters */ + Skip(Characters: number): void; + + /** Skip a line */ + SkipLine(): void; + + /** Write a string to the stream */ + Write(Text: string): void; + + /** Write a number of blank lines to the stream */ + WriteBlankLines(Lines: number): void; + + /** + * Write a string and an end of line to the stream + * @param string [Text=''] + */ + WriteLine(Text?: string): void; + } + +} + +//Global interfaces +interface ActiveXObject { + set(obj: Scripting.Dictionary, propertyName: 'Item', parameterTypes: [any], newValue: any): void; + new(progid: 'Scripting.Dictionary'): Scripting.Dictionary; + new(progid: 'Scripting.Encoder'): Scripting.Encoder; + new(progid: 'Scripting.FileSystemObject'): Scripting.FileSystemObject; +} + +interface EnumeratorConstructor { + new(col: Scripting.Dictionary): any; + new(col: Scripting.Drives): Scripting.Drive; + new(col: Scripting.Files): Scripting.File; + new(col: Scripting.Folders): Scripting.Folder; +} + diff --git a/types/activex-scripting/package.json b/types/activex-scripting/package.json new file mode 100644 index 0000000000..d798f99261 --- /dev/null +++ b/types/activex-scripting/package.json @@ -0,0 +1 @@ +{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file diff --git a/types/activex-scripting-runtime/tsconfig.json b/types/activex-scripting/tsconfig.json similarity index 54% rename from types/activex-scripting-runtime/tsconfig.json rename to types/activex-scripting/tsconfig.json index f5e74f9dd6..badf87e17e 100644 --- a/types/activex-scripting-runtime/tsconfig.json +++ b/types/activex-scripting/tsconfig.json @@ -1,14 +1,9 @@ + { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6", - "dom", - "scripthost" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, + "lib": ["scripthost"], + "strict": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,6 +14,6 @@ }, "files": [ "index.d.ts", - "activex-scripting-runtime-tests.ts" + "activex-scripting-tests.ts" ] } \ No newline at end of file diff --git a/types/activex-scripting/tslint.json b/types/activex-scripting/tslint.json new file mode 100644 index 0000000000..1d0e17119e --- /dev/null +++ b/types/activex-scripting/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint / dt.json" } \ No newline at end of file diff --git a/types/activex-windows-image-acquisition/activex-windows-image-acquisition-tests.ts b/types/activex-wia/activex-wia-tests.ts similarity index 95% rename from types/activex-windows-image-acquisition/activex-windows-image-acquisition-tests.ts rename to types/activex-wia/activex-wia-tests.ts index 549bb4433f..e775ec9239 100644 --- a/types/activex-windows-image-acquisition/activex-windows-image-acquisition-tests.ts +++ b/types/activex-wia/activex-wia-tests.ts @@ -63,9 +63,5 @@ while (!e.atEnd()) { } } - if (WScript) { - WScript.Echo(s); - } else if (window) { - window.alert(s); - } + WScript.Echo(s); } \ No newline at end of file diff --git a/types/activex-wia/index.d.ts b/types/activex-wia/index.d.ts new file mode 100644 index 0000000000..d79adff2a4 --- /dev/null +++ b/types/activex-wia/index.d.ts @@ -0,0 +1,697 @@ +// Type definitions for WIA - +// Project: +// Defintions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare namespace WIA { + + //Enums + /** String versions of globally unique identifiers (GUIDs) that identify common Device and Item commands. */ + 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}' + } + + /** String versions of globally unique identifiers (GUIDs) that identify DeviceManager events. */ + const enum EventID { + wiaEventDeviceConnected = '{A28BBADE-64B6-11D2-A231-00C04FA31809}', + wiaEventDeviceDisconnected = '{143E4E83-6497-11D2-A231-00C04FA31809}', + wiaEventItemCreated = '{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}', + wiaEventItemDeleted = '{1D22A559-E14F-11D2-B326-00C04F68CE61}', + wiaEventScanEmailImage = '{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}', + wiaEventScanFaxImage = '{C00EB793-8C6E-11D2-977A-0000F87A926F}', + wiaEventScanFilmImage = '{9B2B662C-6185-438C-B68B-E39EE25E71CB}', + wiaEventScanImage = '{A6C5A715-8C6E-11D2-977A-0000F87A926F}', + wiaEventScanImage2 = '{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}', + wiaEventScanImage3 = '{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}', + wiaEventScanImage4 = '{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}', + wiaEventScanOCRImage = '{9D095B89-37D6-4877-AFED-62A297DC6DBE}', + wiaEventScanPrintImage = '{B441F425-8C6E-11D2-977A-0000F87A926F}' + } + + /** String versions of globally unique identifiers (GUIDs) that indicate the file format of an image. */ + 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}' + } + + /** Miscellaneous string constants */ + const enum Miscellaneous { + wiaAnyDeviceID = '*', + 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. */ + const enum WiaDeviceType { + CameraDeviceType = 2, + ScannerDeviceType = 1, + UnspecifiedDeviceType = 0, + 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 DeviceEvent.Type and a member from the WiaEventFlags enumeration. */ + const enum WiaEventFlag { + ActionEvent = 2, + NotificationEvent = 1 + } + + /** The WiaImageBias enumeration helps specify what type of data the image is intended to represent. */ + const enum WiaImageBias { + MaximizeQuality = 131072, + MinimizeSize = 65536 + } + + /** The WiaImageIntent enumeration helps specify what type of data the image is intended to represent. */ + const enum WiaImageIntent { + ColorIntent = 1, + GrayscaleIntent = 2, + TextIntent = 4, + UnspecifiedIntent = 0 + } + + /** 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. */ + 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 + } + + /** 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. */ + 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 + } + + /** 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. */ + 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 + } + + /** 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. */ + const enum WiaSubType { + FlagSubType = 3, + ListSubType = 2, + RangeSubType = 1, + UnspecifiedSubType = 0 + } + + //Interfaces + /** 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. */ + interface 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 + * @param WIA.WiaDeviceType [DeviceType=0] + * @param WIA.WiaImageIntent [Intent=0] + * @param WIA.WiaImageBias [Bias=131072] + * @param string [FormatID='{00000000-0000-0000-0000-000000000000}'] + * @param boolean [AlwaysSelectDevice=false] + * @param boolean [UseCommonUI=true] + * @param boolean [CancelError=false] + */ + ShowAcquireImage(DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean): ImageFile; + + /** Launches the Windows Scanner and Camera Wizard and returns Nothing. Future versions may return a collection of ImageFile objects. */ + ShowAcquisitionWizard(Device: Device): any; + + /** + * Displays the properties dialog box for the specified Device + * @param boolean [CancelError=false] + */ + ShowDeviceProperties(Device: Device, CancelError?: boolean): void; + + /** + * Displays the properties dialog box for the specified Item + * @param boolean [CancelError=false] + */ + 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + } + + /** The Device object represents an active connection to an imaging device. */ + interface Device { + + /** A collection of all commands for this imaging device */ + readonly Commands: DeviceCommands; + + /** Returns the DeviceID for this Device */ + readonly DeviceID: string; + + /** A collection of all events for this imaging device */ + 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. */ + ExecuteCommand(CommandID: string): Item; + + /** Returns the Item object specified by ItemID if it exists */ + GetItem(ItemID: string): Item; + + /** A collection of all items for this imaging device */ + readonly Items: Items; + + /** A collection of all properties for this imaging device */ + readonly Properties: Properties; + + /** 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 { + + /** Returns the commandID for this Command */ + readonly CommandID: string; + + /** Returns the command Description */ + readonly Description: string; + + /** Returns the command Name */ + readonly Name: string; + } + + /** 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 */ + readonly Count: number; + + /** Returns the specified item in the collection by position */ + Item(Index: number): DeviceCommand; + } + + /** The DeviceEvent object describes an EventID that can be used when calling RegisterEvent or RegisterPersistentEvent on a DeviceManager object. */ + interface DeviceEvent { + + /** Returns the event Description */ + readonly Description: string; + + /** Returns the EventID for this Event */ + readonly EventID: string; + + /** Returns the event Name */ + readonly Name: string; + + /** Returns the Type of this Event */ + readonly Type: WiaEventFlag; + } + + /** 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 */ + readonly Count: number; + + /** Returns the specified item in the collection by position */ + Item(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. */ + interface DeviceInfo { + + /** Establish a connection with this device and return a Device object */ + Connect(): Device; + + /** Returns the DeviceID for this Device */ + readonly DeviceID: string; + + /** A collection of all properties for this imaging device that are applicable when the device is not connected */ + readonly Properties: Properties; + + /** Returns the Type of Device */ + readonly Type: WiaDeviceType; + } + + /** 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; + } + + /** 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 { + + /** 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. + * @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 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 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. + * @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 properties and finally use the Apply method of the ImageProcess object to filter an ImageFile. */ + interface Filter { + + /** Returns a Description of what the filter does */ + readonly Description: string; + + /** Returns the FilterID for this Filter */ + readonly FilterID: string; + + /** Returns the Filter Name */ + readonly Name: string; + + /** A collection of all properties for this filter */ + readonly Properties: Properties; + } + + /** 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 { + + /** Returns a technical Description of what the filter does and how to use it in a filter chain */ + readonly Description: string; + + /** Returns the FilterID for this filter */ + readonly FilterID: string; + + /** Returns the FilterInfo Name */ + readonly Name: string; + } + + /** 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; + } + + /** 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. */ + interface Filters { + + /** + * Appends/Inserts a new Filter of the specified FilterID into a Filter collection + * @param number [Index=0] + */ + Add(FilterID: string, Index?: number): void; + + /** Returns the number of members in the collection */ + readonly Count: number; + + /** Returns the specified item in the collection by position or FilterID */ + Item(Index: number): Filter; + + /** Removes the designated filter */ + Remove(Index: number): void; + } + + /** 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 */ + readonly Count: number; + + /** Returns the specified item in the collection by position */ + Item(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 through LoadFile. An ImageFile object can be created using "WIA.ImageFile" in a call to CreateObject. */ + interface ImageFile { + + /** Returns/Sets the current frame in the image */ + ActiveFrame: number; + + /** Returns the raw image bits as a Vector of Long values */ + readonly ARGBData: Vector; + + /** Returns the raw image file as a Vector of Bytes */ + readonly FileData: Vector; + + /** Returns the file extension for this image file type */ + readonly FileExtension: string; + + /** Returns the FormatID for this file type */ + readonly FormatID: string; + + /** Returns the number of frames in the image */ + readonly FrameCount: number; + + /** Returns the Height of the image in pixels */ + readonly Height: number; + + /** Returns the Horizontal pixels per inch of the image */ + readonly HorizontalResolution: number; + + /** Indicates if the pixel format has an alpha component */ + readonly IsAlphaPixelFormat: boolean; + + /** Indicates whether the image is animated */ + readonly IsAnimated: boolean; + + /** Indicates if the pixel format is extended (16 bits/channel) */ + readonly IsExtendedPixelFormat: boolean; + + /** Indicates if the pixel data is an index into a palette or the actual color data */ + readonly IsIndexedPixelFormat: boolean; + + /** Loads the ImageFile object with the specified File */ + LoadFile(Filename: string): void; + + /** Returns the depth of the pixels of the image in bits per pixel */ + readonly PixelDepth: number; + + /** A collection of all properties for this image */ + readonly Properties: Properties; + + /** Save the ImageFile object to the specified File */ + SaveFile(Filename: string): void; + + /** Returns the Vertical pixels per inch of the image */ + readonly VerticalResolution: number; + + /** Returns the Width of the image in pixels */ + readonly Width: number; + } + + /** The ImageProcess object manages the filter chain. An ImageProcess object can be created using "WIA.ImageProcess" in a call to CreateObject. */ + interface ImageProcess { + + /** Takes the specified ImageFile and returns the new ImageFile with all the filters applied on success */ + Apply(Source: ImageFile): ImageFile; + + /** A collection of all available filters */ + readonly FilterInfos: FilterInfos; + + /** A collection of the filters to be applied in this process */ + readonly Filters: Filters; + } + + /** 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 { + + /** A collection of all commands for this item */ + readonly Commands: DeviceCommands; + + /** Issues the command specified by CommandID. CommandIDs are device dependent. Valid CommandIDs for this Item are contained in the Commands collection. */ + ExecuteCommand(CommandID: string): Item; + + /** A collection of all supported format types for this item */ + readonly Formats: Formats; + + /** Returns the ItemID for this Item */ + readonly ItemID: string; + + /** A collection of all child items for this item */ + readonly Items: Items; + + /** A collection of all properties for this item */ + 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 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; + } + + /** 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. */ + 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; + + /** Returns the number of members in the collection */ + readonly Count: number; + + /** Returns the specified item in the collection by position */ + Item(Index: number): Item; + + /** Removes the designated Item */ + Remove(Index: number): void; + } + + /** 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; + + /** Returns the specified item in the collection either by position or name. */ + Item(Index: any): Property; + } + + /** 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 { + + /** Indicates whether the Property Value is read only */ + readonly IsReadOnly: boolean; + + /** Indicates whether the Property Value is a vector */ + readonly IsVector: boolean; + + /** Returns the Property Name */ + readonly Name: string; + + /** Returns the PropertyID of this Property */ + readonly PropertyID: number; + + /** Returns the SubType of the Property, if any */ + readonly SubType: WiaSubType; + + /** Returns the default Property Value if the SubType is not UnspecifiedSubType */ + readonly SubTypeDefault: any; + + /** Returns the maximum valid Property Value if the SubType is RangeSubType */ + readonly SubTypeMax: number; + + /** Returns the minimum valid Property Value if the SubType is RangeSubType */ + readonly SubTypeMin: number; + + /** Returns the step increment of Property Values if the SubType is RangeSubType */ + readonly SubTypeStep: number; + + /** Returns a Vector of valid Property Values if the SubType is ListSubType or valid flag Values that can be ored together if the SubType is FlagSubType */ + readonly SubTypeValues: Vector; + + /** Returns either a WiaPropertyType or a WiaImagePropertyType */ + readonly Type: number; + + /** Returns/Sets the Property Value */ + Value: any; + } + + /** 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 { + + /** Returns/Sets the Rational Value Denominator */ + Denominator: number; + + /** Returns/Sets the Rational Value Numerator */ + Numerator: number; + + /** Returns the Rational Value as a Double */ + readonly Value: number; + } + + /** 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 { + + /** + * 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; + + /** Returns/Sets the Vector of Bytes as an array of bytes */ + BinaryData: any; + + /** Removes all elements. */ + Clear(): void; + + /** Returns the number of members in the vector */ + readonly Count: number; + + /** Returns/Sets the Vector of Integers from a Date */ + 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 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; + + /** + * 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; + + /** + * 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] + */ + SetFromString(Value: string, Resizable?: boolean, Unicode?: boolean): void; + + /** + * Returns a Vector of Bytes as a String + * @param boolean [Unicode=true] + */ + String(Unicode?: boolean): string; + } + +} + +//Global interfaces +interface ActiveXObject { + on(obj: WIA.DeviceManager, eventName: 'OnEvent', eventArgs: ['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; +} + +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; +} + diff --git a/types/activex-wia/package.json b/types/activex-wia/package.json new file mode 100644 index 0000000000..d798f99261 --- /dev/null +++ b/types/activex-wia/package.json @@ -0,0 +1 @@ +{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file diff --git a/types/activex-windows-image-acquisition/tsconfig.json b/types/activex-wia/tsconfig.json similarity index 53% rename from types/activex-windows-image-acquisition/tsconfig.json rename to types/activex-wia/tsconfig.json index 486d95921c..70a07b894d 100644 --- a/types/activex-windows-image-acquisition/tsconfig.json +++ b/types/activex-wia/tsconfig.json @@ -1,14 +1,9 @@ + { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6", - "dom", - "scripthost" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, + "lib": ["scripthost"], + "strict": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,6 +14,6 @@ }, "files": [ "index.d.ts", - "activex-windows-image-acquisition-tests.ts" + "activex-wia-tests.ts" ] } \ No newline at end of file diff --git a/types/activex-wia/tslint.json b/types/activex-wia/tslint.json new file mode 100644 index 0000000000..1d0e17119e --- /dev/null +++ b/types/activex-wia/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint / dt.json" } \ No newline at end of file diff --git a/types/activex-windows-image-acquisition/index.d.ts b/types/activex-windows-image-acquisition/index.d.ts deleted file mode 100644 index af32d8a865..0000000000 --- a/types/activex-windows-image-acquisition/index.d.ts +++ /dev/null @@ -1,379 +0,0 @@ -// Type definitions for Microsoft Windows Image Acquisition Library v2.0 -// 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 - } - - //Interfaces - 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; -} -