Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this sample code here that is supposed to choose one particular printer when trying to print or scan something. But to do so with my code below, I need the name of the device and I couldn't figure out a way to get the right name, so the script recognizes the right device:
devs = pyinsane2.get_devices()
	devices = None

	for dev in devs:
		if dev.name == "hplip://32.13241":
			devices = dev
			break

	if devices is None:
		print("Not found")
	else:
		print("Will use {} {}".format(devices.vendor, devices.model)

hplip://xxx is obviously the printer, but this one is the printer of the sample. I need to insert my own printer ID in there. Anybody knows how I get this ?
In my current code, where it just chooses the Printer on its own, it tells me it found the printer
'Brother MFC-J6710DW LAN' (Brother, Brother MFC-J6710DW LAN, scanner,streaming_video)
.
is it the device ID? Can anyone tell me what the number in the smaple code stands for?

What I have tried:

Insterting the found printer name as name doesn't work. So it looks like this:
Python
for dev in devs:
		if dev.name == "'Brother MFC-J6710DW LAN' (Brother, Brother MFC-J6710DW LAN, scanner,streaming_video)":
			devices = dev
break 

This doen't work and it chooses
Python
None
Posted
Updated 5-Mar-18 11:42am
v2
Comments
Richard MacCutchan 6-Mar-18 4:22am    
Go to Control Panel ->Printers and check the properties of the devices you have.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900