knowing if a printer is connected

Phil Davis revdev at pdslabs.net
Thu Nov 19 20:07:45 EST 2009


Here's another OS X shell command that will list only the USB printers 
turned on. Unfortunately, it doesn't list them by their full names.

Here's the code (in a button):

on mouseUp
   put shell("ioreg") into tList
   filter tList with "*IOUSBDevice*"
   put the number of lines in tList & cr & tList into fld "list2"
end mouseUp


Here's the output on my machine:
8
    | |   |   +-o IR Receiver at 4500000  <class IOUSBDevice, registered, 
matched, active, busy 0, retain 8>
    | |   |   +-o Apple Cinema Display at 24320000  <class IOUSBDevice, 
registered, matched, active, busy 0, retain 8>
    | |   |   +-o C-Media USB Audio       @24330000  <class IOUSBDevice, 
registered, matched, active, busy 0, retain 9>
    | |   |   +-o Apple Cinema Display at 24720000  <class IOUSBDevice, 
registered, matched, active, busy 0, retain 8>
    | |   |   +-o iP1700 at 24310000  <class IOUSBDevice, registered, 
matched, active, busy 0, retain 8>
    | |   |   +-o Microsoft 3-Button Mouse with IntelliEye(TM)@6400000  
<class IOUSBDevice, registered, matched, active, busy 0, retain 8>
    | |   |   +-o Bluetooth USB Host Controller at 6110000  <class 
IOUSBDevice, registered, matched, active, busy 0, retain 11>
    | |   |   +-o Apple Keyboard at 26220000  <class IOUSBDevice, 
registered, matched, active, busy 0, retain 9>

Line 5 above is the USB printer.
When I turn the printer off and run the code again, I get 7 lines and 
the printer line is missing.

This printer shows up in "the availablePrinters" list as "Canon iP1700". 
So there's a partial association between the 2 sets of data.

FWIW -
Phil



Phil Davis wrote:
> BNig wrote:
>> The last item of the properties of a printer is the status, it 
>> unfortunately
>> returns idle. At least you get the names of the printers. The current
>> printer is the default printer.
>> regards
>> Bernd
>>
>>   
>
> You can also get the names of the printers with:
>
>   put the availablePrinters into tList
>
> :-)

-- 
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net




More information about the use-livecode mailing list