This worked for me on my home printer, and I had high hopes for it,
but if fails this morning here at work. The problem seems to be that
with some printers the listing from the ioreg call has little relation
to the name of the printer. For instance, my Brother laserjet MFC 8220
(combo printer fax copier) has an ioreg listing of:
+-o iousbcompositedev...@fd100000 <class IOUSBDevice, registered,
matched, active, busy 0, retain 12>
and there is no way of telling that this is a Brother 8220 or relating
it to the availablePrinters, not on the face of it, anyway.
I'm working on a solution that will involve storing the ioreg name of
a given printer as a customprop "ioregListing[printerName]" More to
come. I'm determined to make this work as invisibly as possible. It
has long been a irritation for me that the system doesn't
automatically just send print jobs to the available printer. There's
no reason on earth why you should have to change printers manually
(after the first time you use one, of course). The system knows what's
plugged in, for goodness sake. [grrrr...]
-- Peter
Peter M. Brigham
pmb...@gmail.com
http://home.comcast.net/~pmbrig
On Nov 21, 2009, at 11:36 PM, Phil Davis wrote:
Everyone is doing it, so... here is what I came up with. Watch line
wraps please. Hopefully the comments explain what the code is doing.
on mouseUp
answer UsbPrinterList()
end mouseUp
function UsbPrinterList
-- set item delimiter
set the itemDelimiter to tab
-- make a list of all active USB I/O devices
put shell("ioreg") into tActiveDeviceList
filter tActiveDeviceList with "*IOUSBDevice*" -- remove all but USB
devices from list
replace "@" with tab in tActiveDeviceList -- isolate device name
replace "+-o" with tab in tActiveDeviceList -- device name is item
2 of each line
-- get all known printer names, whether active or not
put the availablePrinters into tPrinterNames
-- identify active USB printers in the USB device list
put empty into tUsbPrinters
repeat for each line tDeviceLine in tActiveDeviceList
put word 1 to -1 of item 2 of tDeviceLine into tDeviceName --
could be partial device name
get tPrinterNames
filter it with ("*" & tDeviceName & "*")
if it = empty then next repeat -- device is not a printer
-- USB device is a printer, so get full name
repeat for each line tFoundPrinter in it
put tFoundPrinter & cr after tUsbPrinters
end repeat
end repeat
delete last char of tUsbPrinters -- trailing CR
return tUsbPrinters
end UsbPrinterList
Thanks -
Phil Davis
JosepM wrote:
Hi,
In English work, but in Spanish and others languages don't.
The result of the shell command is:
destino por omision del sistema: HP_Photosmart_C4200_series
So we must check for the ":" and get the printer name.
set itemdel to ":"
put item 2 of shell("lpstat -d") into tDefaultPrinter
function getDefaultPrinter
put word 4 of shell("lpstat -d") into tDefaultPrinter
-- shell returns: system default destination: HP_DESKJET_845C
replace "_" with space in tDefaultPrinter
return tDefaultPrinter
end getDefaultPrinter
The getActivePrinter get all the USB devices. In my case, my LaCie
disk, the
iPhone, the DataTraveler and the HP printer.. How to filter between
them?
Salut,
Josep
--
Phil Davis
PDS Labs
Professional Software Development
http://pdslabs.net
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution