因此,我正在使用脚本来自动执行扫描,一切都很好,除了我的扫描仪始终使用平台进行扫描而且我似乎无法将源更改为Feeder。这是我正在使用的代码
# Create object to access the scanner
$deviceManager = new-object -ComObject WIA.DeviceManager
$device = $deviceManager.DeviceInfos.Item(1).Connect()
# Create object to access the scanned image later
$imageProcess = new-object -ComObject WIA.ImageProcess
# Store file format GUID strings
$wiaFormatBMP = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"
$wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
$wiaFormatGIF = "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"
$wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
$wiaFormatTIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"
# Scan the image from scanner as BMP
foreach ($item in $device.Items) {
$image = $item.Transfer()
}
# set type to JPEG and quality/compression level
$imageProcess.Filters.Add($imageProcess.FilterInfos.Item("Convert").FilterID)
$imageProcess.Filters.Item(1).Properties.Item("FormatID").Value = $wiaFormatJPEG
$imageProcess.Filters.Item(1).Properties.Item("Quality").Value = 5
$image = $imageProcess.Apply($image)
# Build filepath from desktop path and filename 'Scan 0'
$filename = "$([Environment]::GetFolderPath("Desktop"))\Scan {0}.jpg"
# If a file named 'Scan 0' already exists, increment the index as long as needed
$index = 0
while (test-path ($filename -f $index)) {[void](++$index)}
$filename = $filename -f $index
# Save image to 'C:\Users\<username>\Desktop\Scan {x}'
$image.SaveFile($filename)
# Show image
& $filename
我只需要更改扫描仪的来源,然后保存所有图像即可。
答案 0 :(得分:0)
因此,经过大量的研究和实验。我终于做到了。
foreach($prop in $device.Properties){
if( $prop.Name -eq "Document Handling Select"){
$prop.Value=1
}
}
但是这仍然只给了我1张图片,因此我不得不对我之前给出的所有代码使用while循环。现在工作完美!