knowing if a printer is connected

Phil Davis revdev at pdslabs.net
Thu Nov 19 18:59:38 EST 2009


Hi Peter,

Here is another approach for OS X that might give you info that's easier 
to use. Or not.

put shell("system_profiler SPPrintersDataType") into tDescriptions

In my world it returns this:
--- start of data ---
Printers:

    Canon iP1700:

      Status: Idle
      Print Server: Local
      Driver Version: 5.8.3
      Default: No
      URI: usb://Canon/iP1700?serial=705357
      PPD: Canon iP1700
      PPD File Version: 1.0
      PostScript Version: (3011.104) 0

    HP Color LaserJet 2600n:

      Status: Idle
      Print Server: Local
      Driver Version: 1.3.0501
      Default: Yes
      URI: 
mdns://HP%20Color%20LaserJet%202600n._pdl-datastream._tcp.local./?bidi
      PPD: HP Color LaserJet 2600n
      PPD File Version: 1.0
      PostScript Version: (3011.104) 0

    Officejet Pro 8500 A909g [7134F4]:

      Status: Idle
      Print Server: Local
      Driver Version: 1.2
      Default: No
      URI: 
mdns://Officejet%20Pro%208500%20A909g%20%5B7134F4%5D._pdl-datastream._tcp.local./?bidi
      PPD: HP Officejet Pro 8500 A909g Series
      PPD File Version: 1.2
      PostScript Version: (3011.104) 0

--- end of data ---

I see the URI line in each description tells if it is USB or not. BUT it 
doesn't tell you the status of the printers; I got the same descriptions 
when my USB printer was turned on/turned off/unplugged.

If I learn more I'll post it.

Phil Davis



Peter Brigham MD wrote:
> It returns "idle" in all cases? Are you saying that it doesn't 
> distinguish if the printer is on/connected vs off/disconnected?
>
> How would I get the contents of the various printer properties from 
> this script into rev variables to test this out? Do I use an 'on 
> appleEvent' handler -- if so, how? Sorry for the naive questions, but 
> I haven't used applescript much.
>
> -- Peter
>
> Peter M. Brigham
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig
>
>
> On Nov 19, 2009, at 3:33 PM, BNig wrote:
>
>>
>> Peter,
>> I was a little too fast with my reply, I am afraid
>>
>> this gives me all the information of the current printer 
>> unfortunately it
>> does return idle even if the current printer is off.
>>
>> tell application "Printer Setup Utility"
>>     set Current_Printer to name of current printer --> set a variable 
>> for the
>> name of your current/default printer
>>     set tKind to kind of current printer
>>     set tproperties to properties of current printer
>>     set tJob to job of current printer
>> end tell
>>
>> Since you are looking for an active/connected printer this is 
>> probably not
>> working.
>> regards
>> Bernd
>>
>>
>>
>>
>> BNig wrote:
>>>
>>> Peter,
>>>
>>> tell application "Printer Setup Utility"
>>>     set Current_Printer to name of current printer --> set a 
>>> variable for the
>>> name of your current/default printer
>>> end tell
>>>
>>> this applescript tells me the currently selected printer on MacOSX 
>>> 10.5.8
>>>
>>> regards
>>> Bernd
>>>
>>>
>>> Peter Brigham MD wrote:
>>>>
>>>> I have a stack system that is being used on laptops (at this point Mac
>>>> OSX only). One of my beta testers uses it in three different
>>>> locations. Among many other things, the stack prints out notes and
>>>> various other text files from within Rev (running in IDE on RevMedia
>>>> 4.0 -- eventually I'll get to porting it as a standalone). As it
>>>> stands now, the user needs to select the currently available printer
>>>> using the system preferences. I need a way to discover if the printer
>>>> designated as active in the system preferences is actually the one
>>>> that is plugged into the USB port. I have a way for the user to change
>>>> the printer from within the stack, but I'd like to avoid the situation
>>>> where he tries to print something and gets the bobbing printer driver
>>>> icon in the dock telling him that that printer is unavailable (because
>>>> he's at a different site and forgot to change his printer 
>>>> designation).
>>>>
>>>> The ideal solution would be to be able to detect the currently
>>>> connected printer and send any print job automatically  to that
>>>> printer, but I'd settle for just being able to post an alert when
>>>> trying to print to notify him that he is about to use an unavailable
>>>> printer. How do I detect what printer is connected? Or at least,
>>>> detect if a designated printer is connected or not?
>>>>
>>>> -- Peter
>>>>
>>>> Peter M. Brigham
>>>> pmbrig at gmail.com
>>>> http://home.comcast.net/~pmbrig
>>>>
>>>
>>>
>>
>> -- 
>> View this message in context: 
>> http://n4.nabble.com/knowing-if-a-printer-is-connected-tp624188p624225.html 
>>
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

-- 
Phil Davis

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




More information about the use-livecode mailing list