1+ /// <reference path="microsoft-windows-image-acquisition.d.ts" />
2+
3+ //source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx
4+
5+
6+ //Convert a file
7+ var commonDialog = new ActiveXObject ( 'WIA.CommonDialog' ) ;
8+ var img = commonDialog . ShowAcquireImage ( ) ;
9+ if ( img . FormatID != WIA . FormatID . wiaFormatJPEG ) {
10+ var ip = new ActiveXObject ( 'WIA.ImageProcess' ) ;
11+ ip . Filters . Add ( ip . FilterInfos . Item ( 'Convert' ) . FilterID ) ;
12+ ip . Filters . Item ( 1 ) . Properties . Item ( "FormatID" ) . Value = WIA . FormatID . wiaFormatJPEG ;
13+ img = ip . Apply ( img ) ;
14+ }
15+
16+
17+ //Take a picture
18+ var dev = commonDialog . ShowSelectDevice ( ) ;
19+ if ( dev . Type == WIA . WiaDeviceType . CameraDeviceType ) {
20+ var itm = dev . ExecuteCommand ( WIA . CommandID . wiaCommandTakePicture ) ;
21+ }
22+
23+
24+ //Display detailed property information
25+ dev = commonDialog . ShowSelectDevice ( ) ;
26+ var e = new Enumerator < WIA . Property > ( dev . Properties ) ; //no foreach over ActiveX collections
27+ e . moveFirst ( ) ;
28+ while ( ! e . atEnd ( ) ) {
29+ var p = e . item ( ) ;
30+ var s = p . Name + ' (' + p . PropertyID + ') = ' ;
31+ if ( p . IsVector ) {
32+ s += '[vector of data]' ;
33+ } else {
34+ s += p . Value ;
35+ if ( p . SubType != WIA . WiaSubType . UnspecifiedSubType ) {
36+ if ( p . Value != p . SubTypeDefault ) {
37+ s += ' (Default = ' + p . SubTypeDefault + ')' ;
38+ }
39+ }
40+ }
41+
42+ if ( p . IsReadOnly ) {
43+ s += ' [READ ONLY]' ;
44+ } else {
45+ switch ( p . SubType ) {
46+ case WIA . WiaSubType . FlagSubType :
47+ case WIA . WiaSubType . ListSubType :
48+ if ( p . SubType == WIA . WiaSubType . FlagSubType ) {
49+ s += ' [valid flags include: ' ;
50+ } else {
51+ s += ' [valid values include: ' ;
52+ }
53+ var count = p . SubTypeValues . Count ;
54+ for ( var i = 1 ; i <= count ; i ++ ) {
55+ s += p . SubTypeValues . Item ( i ) ;
56+ if ( i < count ) {
57+ s += ', ' ;
58+ }
59+ }
60+ s += ']' ;
61+ break ;
62+ case WIA . WiaSubType . RangeSubType :
63+ s += ' [valid values in the range from ' + p . SubTypeMin + ' to ' + p . SubTypeMax + ' in increments of ' + p . SubTypeStep + ']' ;
64+ break ;
65+ }
66+ }
67+
68+ if ( WScript ) {
69+ WScript . Echo ( s ) ;
70+ } else if ( window ) {
71+ window . alert ( s ) ;
72+ }
73+ }
0 commit comments