Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

422 lines
12 KiB

  1. '
  2. ' device initialization script for hp scanjet scanners
  3. '
  4. '
  5. ' constants section: This will be in another file.
  6. '
  7. DIM INITIALIZE_ID
  8. DIM SETVALUE_ID
  9. DIM GETVALUE_ID
  10. DIM RESETDEVICE_ID
  11. DIM SCAN_ID
  12. DIM SCAN_NEXT_ID
  13. DIM SCAN_FINISHED_ID
  14. DIM CANCELSCAN_ID
  15. INITIALIZE_ID = 100
  16. SETVALUE_ID = 101
  17. GETVALUE_ID = 102
  18. RESETDEVICE_ID = 103
  19. SCAN_ID = 104
  20. SCAN_NEXT_ID = 105
  21. SCAN_FINISHED_ID = 106
  22. CANCELSCAN_ID = 107
  23. '
  24. ' Value ID defines
  25. '
  26. DIM XRESOLUTION
  27. DIM YRESOLUTION
  28. DIM XPOSITION
  29. DIM YPOSITION
  30. DIM XEXTENT
  31. DIM YEXTENT
  32. DIM BRIGHTNESS
  33. DIM CONTRAST
  34. DIM DATATYPE
  35. DIM BITDEPTH
  36. DIM NEGATIVE
  37. DIM PIXELORDER
  38. DIM PIXELFORMAT
  39. DIM BEDWIDTH
  40. DIM BEDHEIGHT
  41. DIM OPTICALX
  42. DIM OPTICALY
  43. DIM ADFSUPPORT
  44. DIM TPASUPPORT
  45. DIM ADFWIDTH
  46. DIM ADFHEIGHT
  47. DIM ADFVJUSTIFY
  48. DIM ADFHJUSTIFY
  49. DIM ADFMAXPAGES
  50. DIM FIRMWAREVER
  51. XRESOLUTION = 2
  52. YRESOLUTION = 3
  53. XPOSITION = 4
  54. YPOSITION = 5
  55. XEXTENT = 6
  56. YEXTENT = 7
  57. BRIGHTNESS = 8
  58. CONTRAST = 9
  59. DATATYPE = 10
  60. BITDEPTH = 11
  61. NEGATIVE = 12
  62. PIXELORDER = 13
  63. PIXELFORMAT = 14
  64. BEDWIDTH = 15
  65. BEDHEIGHT = 16
  66. OPTICALX = 17
  67. OPTICALY = 18
  68. ADFSUPPORT = 19
  69. TPASUPPORT = 20
  70. ADFWIDTH = 21
  71. ADFHEIGHT = 22
  72. ADFVJUSTIFY = 23
  73. ADFHJUSTIFY = 24
  74. ADFMAXPAGES = 25
  75. FIRMWAREVER = 26
  76. ' **************************************************************************************
  77. ' * SCRIPTING EVENTS *
  78. ' * *
  79. ' * Events called from WIAFBDRV WIA driver to envoke scripting actions for the device. *
  80. ' * *
  81. ' * *
  82. ' **************************************************************************************
  83. Sub DeviceAction_DeviceActionEvent
  84. Select Case DeviceAction.Action
  85. Case INITIALIZE_ID
  86. '
  87. ' Initialize Device Properties
  88. '
  89. Call IntializeDeviceProperies()
  90. Case SETVALUE_ID
  91. Select Case DeviceAction.ValueID
  92. Case XRESOLUTION
  93. Call SetXResolution(DeviceAction.Value)
  94. Case YRESOLUTION
  95. Call SetYResolution(DeviceAction.Value)
  96. Case DATATYPE
  97. Call SetDataType(DeviceAction.Value)
  98. Case NEGATIVE
  99. Call SetNegative(DeviceAction.Value)
  100. Case XPOSITION
  101. Call SetXPosition(DeviceAction.Value)
  102. Case YPOSITION
  103. Call SetYPosition(DeviceAction.Value)
  104. Case XEXTENT
  105. Call SetXExtent(DeviceAction.Value)
  106. Case YEXTENT
  107. Call SetYExtent(DeviceAction.Value)
  108. Case CONTRAST
  109. Call SetContrast(DeviceAction.Value)
  110. Case BRIGHTNESS
  111. Call SetBrightness(DeviceAction.Value)
  112. Case Else
  113. End Select
  114. Case GETVALUE_ID
  115. Select Case DeviceAction.ValueID
  116. Case XRESOLUTION
  117. Call GetXResolution(DeviceAction.Value)
  118. Case YRESOLUTION
  119. Call GetYResolution(DeviceAction.Value)
  120. Case DATATYPE
  121. Call GetDataType(DeviceAction.Value)
  122. Case NEGATIVE
  123. Call GetNegative(DeviceAction.Value)
  124. Case XPOSITION
  125. Call GetXPosition(DeviceAction.Value)
  126. Case YPOSITION
  127. Call GetYPosition(DeviceAction.Value)
  128. Case XEXTENT
  129. Call GetXExtent(DeviceAction.Value)
  130. Case YEXTENT
  131. Call GetYExtent(DeviceAction.Value)
  132. Case Else
  133. End Select
  134. Case RESETDEVICE_ID
  135. Call ResetDevice(DeviceAction.Value)
  136. Case SCAN_ID
  137. Call StartScan(DeviceAction.Value)
  138. Case SCAN_NEXT_ID
  139. Call ScanNext(DeviceAction.Value)
  140. Case SCAN_FINISHED_ID
  141. Call ScanFinished(DeviceAction.Value)
  142. Case CANCELSCAN_ID
  143. Call CancelScan(DeviceAction.Value)
  144. Case Else
  145. End Select
  146. End Sub
  147. Sub IntializeDeviceProperies
  148. ' **************************************************************************************
  149. ' To change the x resolution valid value types, just use one of
  150. ' the following methods of DeviceProperty:
  151. '
  152. ' SetValidRange() represents resolution in RANGE form.
  153. ' SetValidList() represents resolution in LIST form.
  154. 'Call DeviceProperty.SetValidRange(XRESOLUTION,12,1200,150,1) ' set valid x resolutions (RANGE form)
  155. 'Call DeviceProperty.SetValidRange(YRESOLUTION,12,1200,150,1) ' set valid y resolutions (RANGE form)
  156. DIM ValidResolutions
  157. ValidResolutions = Array(75,100,150,200,300,600,1200)
  158. Call DeviceProperty.SetValidList(XRESOLUTION,ValidResolutions)' set valid x resolutions (LIST form)
  159. Call DeviceProperty.SetValidList(YRESOLUTION,ValidResolutions)' set valid y resolutions (LIST form)
  160. Call DeviceProperty.SetCurrentValue(XRESOLUTION, 150) ' set current x resolution
  161. Call DeviceProperty.SetCurrentValue(YRESOLUTION, 150) ' set current y resolution
  162. ' ****************************************************************************************
  163. Call DeviceProperty.SetValidRange(XPOSITION,0,2549,2549,1) ' set valid x positions
  164. Call DeviceProperty.SetCurrentValue(XPOSITION,0) ' set current x position
  165. Call DeviceProperty.SetValidRange(YPOSITION,0,3506,3506,1) ' set valid y positions
  166. Call DeviceProperty.SetCurrentValue(YPOSITION,0) ' set current y position
  167. Call DeviceProperty.SetValidRange(XEXTENT,1,2550,1,1) ' set valid x extents
  168. Call DeviceProperty.SetCurrentValue(XEXTENT,2550) ' set current x extent
  169. Call DeviceProperty.SetValidRange(YEXTENT,1,3507,1,1) ' set valid y extents
  170. Call DeviceProperty.SetCurrentValue(YEXTENT,3507) ' set current y extent
  171. Call DeviceProperty.SetValidRange(BRIGHTNESS,-127,127,32,1) ' set valid brightness
  172. Call DeviceProperty.SetCurrentValue(BRIGHTNESS,32) ' set current brightness
  173. Call DeviceProperty.SetValidRange(CONTRAST,-127,127,12,1) ' set valid contrast
  174. Call DeviceProperty.SetCurrentValue(CONTRAST,12) ' set current contrast
  175. DIM ValidDataTypes
  176. ValidDataTypes = Array(0,2,3)
  177. Call DeviceProperty.SetValidList(DATATYPE,ValidDataTypes) ' set valid data types
  178. Call DeviceProperty.SetCurrentValue(DATATYPE,2) ' set current data type
  179. Call DeviceProperty.SetCurrentValue(BITDEPTH,8) ' set current bit depth
  180. Call DeviceProperty.SetCurrentValue(NEGATIVE,1) ' set negative option (TRUE)
  181. Call DeviceProperty.SetCurrentValue(PIXELORDER,0) ' set raw pixel packing order option (WIA_PACKED_PIXEL)
  182. Call DeviceProperty.SetCurrentValue(PIXELFORMAT,1) ' set raw pixel format option (WIA_ORDER_BGR)
  183. Call DeviceProperty.SetCurrentValue(BEDWIDTH,8500) ' set bed width
  184. Call DeviceProperty.SetCurrentValue(BEDHEIGHT,11693) ' set bed height
  185. Call DeviceProperty.SetCurrentValue(OPTICALX,300) ' set x optical resolution
  186. Call DeviceProperty.SetCurrentValue(OPTICALY,300) ' set y optical resolution
  187. Call DeviceProperty.SetCurrentValue(ADFSUPPORT,0) ' set ADF support option
  188. Call DeviceProperty.SetCurrentValue(TPASUPPORT,0) ' set TPA support option
  189. Call DeviceProperty.SetCurrentValue(ADFWIDTH,0) ' set ADF width
  190. Call DeviceProperty.SetCurrentValue(ADFHEIGHT,0) ' set ADF height
  191. Call DeviceProperty.SetCurrentValue(ADFVJUSTIFY,0) ' set ADF vertical justification (TOP_JUSTIFIED)
  192. Call DeviceProperty.SetCurrentValue(ADFHJUSTIFY,0) ' set ADF horizontal justification (LEFT_JUSTIFIED)
  193. Call DeviceProperty.SetCurrentValue(ADFMAXPAGES,30) ' set ADF page capacity
  194. Call DeviceProperty.SetCurrentValue(FIRMWAREVER,"1.02a") ' set firmware version
  195. End Sub
  196. Sub SetXResolution(Value)
  197. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "R",(4 + Len(CStr(Value))),100)
  198. End Sub
  199. Sub SetYResolution(Value)
  200. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "S",(4 + Len(CStr(Value))),100)
  201. End Sub
  202. Sub SetDataType(Value)
  203. Select Case Value
  204. Case 0 ' WIA_DATA_THRESHOLD
  205. Call DeviceControl.RawWrite(0,chr(27) + "*a0T",5,100) ' set data type
  206. Call DeviceControl.RawWrite(0,chr(27) + "*a1G",5,100) ' set bits per pixel
  207. Case 2 ' WIA_DATA_GRAYSCALE
  208. Call DeviceControl.RawWrite(0,chr(27) + "*a4T",5,100) ' set data type
  209. Call DeviceControl.RawWrite(0,chr(27) + "*a8G",5,100) ' set bits per pixel
  210. Case 3 ' WIA_DATA_COLOR
  211. Call DeviceControl.RawWrite(0,chr(27) + "*a5T",5,100) ' set data type
  212. Call DeviceControl.RawWrite(0,chr(27) + "*a24G",5,100) ' set bits per pixel
  213. Case Else
  214. End Select
  215. End Sub
  216. Sub SetNegative(Value)
  217. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "I",(4 + Len(CStr(Value))),100)
  218. End Sub
  219. Sub SetXPosition(Value)
  220. '
  221. ' get current x resolution, for calculation of 300 dpi optical offset
  222. '
  223. DIM XResSetting
  224. Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
  225. '
  226. ' calculate new position
  227. '
  228. DIM OpticalValue
  229. OpticalValue = CLng(Value)
  230. OpticalValue = CLng((OpticalValue * 300) / XResSetting)
  231. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "X",(4 + Len(CStr(OpticalValue))),100)
  232. End Sub
  233. Sub SetYPosition(Value)
  234. '
  235. ' get current y resolution, for calculation of 300 dpi optical offset
  236. '
  237. DIM YResSetting
  238. Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
  239. '
  240. ' calculate new position
  241. '
  242. DIM OpticalValue
  243. OpticalValue = CLng(Value)
  244. OpticalValue = CLng((OpticalValue * 300) / YResSetting)
  245. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "Y",(4 + Len(CStr(OpticalValue))),100)
  246. End Sub
  247. Sub SetXExtent(Value)
  248. '
  249. ' get current x resolution, for calculation of 300 dpi optical offset
  250. '
  251. DIM XResSetting
  252. Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
  253. '
  254. ' calculate new position
  255. '
  256. DIM OpticalValue
  257. OpticalValue = CLng(Value)
  258. OpticalValue = CLng((OpticalValue * 300) / XResSetting)
  259. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "P",(4 + Len(CStr(OpticalValue))),100)
  260. End Sub
  261. Sub SetYExtent(Value)
  262. '
  263. ' get current y resolution, for calculation of 300 dpi optical offset
  264. '
  265. DIM YResSetting
  266. Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
  267. '
  268. ' calculate new position
  269. '
  270. DIM OpticalValue
  271. OpticalValue = CLng(Value)
  272. OpticalValue = CLng((OpticalValue * 300) / YResSetting)
  273. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "Q",(4 + Len(CStr(OpticalValue))),100)
  274. End Sub
  275. Sub SetContrast(Value)
  276. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "K",(4 + Len(CStr(Value))),100)
  277. End Sub
  278. Sub SetBrightness(Value)
  279. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "L",(4 + Len(CStr(Value))),100)
  280. End Sub
  281. Sub GetXResolution(Value)
  282. End Sub
  283. Sub GetYResolution(Value)
  284. End Sub
  285. Sub GetDataType(Value)
  286. End Sub
  287. Sub GetNegative(Value)
  288. End Sub
  289. Sub GetXPosition(Value)
  290. End Sub
  291. Sub GetYPosition(Value)
  292. End Sub
  293. Sub GetXExtent(Value)
  294. End Sub
  295. Sub GetYExtent(Value)
  296. End Sub
  297. Sub ResetDevice(Value)
  298. End Sub
  299. Sub StartScan(Value)
  300. ' start a scan
  301. Call DeviceControl.RawWrite(0,chr(27)+"*f0S",5,100)
  302. ' read some data
  303. ScanNext(Value)
  304. End Sub
  305. Sub ScanNext(Value)
  306. Call DeviceControl.ScanRead(0,100)
  307. End Sub
  308. Sub ScanFinished(Value)
  309. 'Call ResetScanner()
  310. End Sub
  311. Sub ResetScanner()
  312. Call DeviceControl.RawWrite(0,chr(27) + chr(69),2,100)
  313. End Sub
  314. Sub CancelScan(Value)
  315. End Sub