wia-cmd-scanner icon indicating copy to clipboard operation
wia-cmd-scanner copied to clipboard

Multiple scanners/devices?

Open winternet-studio opened this issue 5 years ago • 5 comments

What happens if you have multiple scanners connected to the computer? How can you select which one to work with?

winternet-studio avatar Mar 17 '20 09:03 winternet-studio

Currently there is no provision for scanner selection. If there are two or more scanners attached, this statement would simply select "the first one". Since I don't know the order in which devices are placed into DeviceManager, "the first one" should be read as "the random one". Implementing a scanner selection flag would require a bit of extra code to walk through the DeviceManager and list all the scanners, and then display them to let the user select "scanner number two". While being a very simple feature to implement, I feel uneasy about it. Unplugging the second scanner before running a batch file feels more like a "right way" of doing things when scanning from the command-line. I'd rather play a plug-unplug game than run wia-cmd-scanner /listscanners, read the list, then re-run everything with wia-cmd-scanner /scanner 2 ... and so on.

nagimov avatar Mar 25 '20 03:03 nagimov

I see. Understand the concern about just specifying a scanner by a number... but isn't there another property that can be used?

I just tried to run the following vbscript inspired by https://stackoverflow.com/questions/531076/wia-devicemanager-deviceinfos-count-0-why - and I got unique identifiers and everything:

Set DeviceManager = CreateObject("WIA.DeviceManager")
Set objFSO = CreateObject("Scripting.FileSystemObject")

If DeviceManager.DeviceInfos.Count < 1 Then
    MsgBox("No compatible scanners found (count: " & DeviceManager.DeviceInfos.Count & ")")
End If

Set objFile = objFSO.CreateTextFile("c:\Ztrans\vbsoutput.txt", True)

Dim output
output = ""
For i = 1 To DeviceManager.DeviceInfos.Count
    For Each prop in DeviceManager.DeviceInfos(i).Properties
        output = output & prop.Name & " :: " & prop.Value & vbCrLf
    Next

'    If DeviceManager.DeviceInfos(i).Type = 1 Then
'        MsgBox("Scanner " & DeviceManager.DeviceInfos(i).Type)
'    End If

    output = output & vbCrLf & vbCrLf
Next

MsgBox(output)

objFile.Write output
objFile.Close

Resulted in this output:

Unique Device ID :: {6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000
Manufacturer :: Epson
Description :: Epson Stylus CX6600/CX6500
Type :: 65537
Port :: \\.\Usbscan0
Name :: Epson Stylus CX6600/CX6500
Server :: local
Remote Device ID :: 
UI Class ID :: {00000000-0000-0000-0000-000000000000}
Hardware Configuration :: 0
BaudRate :: 
STI Generic Capabilities :: 19
WIA Version :: 2.0
Driver Version :: 1.7.3.1
PnP ID String :: \\?\usb#vid_04b8&pid_0813&mi_00#7&333ecf72&0&0000#{6bdd1fc6-810f-11d0-bec7-08002be2092f}
STI Driver Version :: 2

winternet-studio avatar Mar 25 '20 10:03 winternet-studio

Not sure what's the goal here. Is this a hypothetical "what if someone has two or more scanners" question or are you actually trying to use it with two scanners yourself?

Here are the problems I see:

  • if using "unique device ID" to id scanners, are you proposing the user to type the UUID? (that's inhumane)
  • if using manufacturer name/model, what if there are two scanners with the same name/model?
  • if using port number, what if port numbering has changed? what if USB hub was reconnected? what if a new scanner was connected and became USB number zero?

I have multiple setups with various scanners that use this tool. None of them have more than a single scanner attached. So this feels like a solution in search of a problem. If you do need to use this tool with two scanners I encourage you to fork it and add the required functionality - the code is as simple as it gets. IMO it isn't worth complicating the code with an extra functionality that could theoretically solve problems of 0.1% of the users.

nagimov avatar Mar 25 '20 20:03 nagimov

Granted... it was just a hypothetical question for now - a college asked me what happened if our client had two scanners connected - I don't think it was the case though. So just forget about it for now. :)

Regarding the problems of I would say using the unique device ID is not a problem - this is normally not something a user enters manually but is run programmatically by a script or something. So then the complexity isn't an issue.

winternet-studio avatar Mar 26 '20 09:03 winternet-studio

I have two printer/scanner devices here and the "first" one is not the one I want to use. The first one is an 8.5x11 scanner and I'm trying to scan an 11x17 document with my second one. No go.

edit: Turning the power off on the other one is an acceptable game plan. :)

ShortyCM avatar Feb 12 '23 18:02 ShortyCM