Jump to content

Network printing


Go to solution Solved by kaotkbliss,

Recommended Posts

We have some files in .pcl formal that cannot be opened in a viewer to print (they lose embeded commands) 1 printer we can print to using ftp, but the back-up printer is older and does not have that capability.

I thought that if I could send the data dirrectly via the ip address then maybe we could get around this issue.

Unfortunately the printer does not seem to be responding :mellow:

#include <GuiConstants.au3>
#include <Array.au3>
#include <WindowsConstants.au3>

$x = 1
$i = 0
Global $ip
Global $ipen
Global $ipme
Global $ipin
Global $ftpr
Global $prin
Global $ip[$x]

$ip = IniReadSection(@WorkingDir & "\printip.ini", "ips")

GUICreate("IP Print", 250, 120, -1, -1, -1, $WS_EX_ACCEPTFILES)
$ipen = GUICtrlCreateCombo("", 1, 50)
GUICtrlCreateLabel("Select IP", 1, 32, 45, 15)

For $x = 1 To UBound($ip) - 1
    GUICtrlSetData($ipen, $ip[$x][1] & "|")
Next

$ipme = GUICtrlCreateInput("Enter IP", 1, 3, 100, 20)
$ipin = GUICtrlCreateButton("Save IP", 105, 1)
$ftpr = GUICtrlCreateInput("", 1, 97, 100, 20)
GUICtrlSetState($ftpr, $GUI_DROPACCEPTED)
$prin = GUICtrlCreateButton("Print", 105, 94)
GUICtrlCreateLabel("Drag File Here", 1, 77, 75, 15)

GUISetState(@SW_SHOW)

main()

Func main()

    While 1
        $msg = GUIGetMsg()

        If $msg = $ipin Then
            Do
                $i += 1
                $chk = IniRead(@WorkingDir & "\printip.ini", "ips", $i, "")
            Until $chk = ""
            $nwip = GUICtrlRead($ipme)
            IniWrite(@WorkingDir & "\printip.ini", "ips", $i, $nwip)

            GUICtrlSetData($ipen, "")

            For $x = 1 To UBound($ip) - 1
                GUICtrlSetData($ipen, $ip[$x][1] & "|")
            Next

        ElseIf $msg = $prin Then

            print()

        ElseIf $msg = $GUI_EVENT_CLOSE Then
            GUIDelete()
            TCPCloseSocket($prntr)
            TCPShutdown()
            Exit (1)

        EndIf

    WEnd

EndFunc   ;==>main

Func print()

    $ipad = GUICtrlRead($ipen)
    $flad = GUICtrlRead($ftpr)

    If $ipad = "" Then
        MsgBox(0, "Error", "No IP Selected", 10)
        main()
    EndIf

    If $flad = "" Then
        MsgBox(0, "Error", "No File Selected", 10)
        main()
    EndIf

    TCPStartup()
    $prntr = TCPConnect($ipad, 80)
    $flopn = FileOpen($flad, 16)
    $flrd = FileRead($flad)
    $flsnd = TCPSend($prntr, $flrd)
    main()

EndFunc   ;==>print

All the variables after TCPStartup() are not throwing errors, so there is communication, just don't know why it's not printing.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

That's the HP Printer Control Language (PCL) insn't it? Are you sure you're not trying to send PCL6 commands to a PCL3 printer, or some such? You did mention the backup is not of the same generation.

:mellow:

P.S. If that's the problem, then you would install the driver for that generation of PCL printer, print to file again to generate a compatible .pcl file, then FTP that to the older printer. Even if you can't do this with the current file, try it with a different document just to test the theory.

:(

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Richo (Lenier) 5705

I'm thinking I might be missing some code in my script to make it work (ddl call or something?)

but I have no clue what it would be.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • Developers

Should you use the LPR protocol to send the file to the printer? You script open the HTTP port now.

There is an LPR command that comes with windows that would allow that.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Should you use the LPR protocol to send the file to the printer? You script open the HTTP port now.

There is an LPR command that comes with windows that would allow that.

Jos

Thanks Jos, that is the part of the script that was missing. simple text files print to both printers, now just need to test pcl files.

#include <GuiConstants.au3>
#include <Array.au3>
#include <WindowsConstants.au3>

$x = 1
$i = 0
Global $ip
Global $ipen
Global $ipme
Global $ipin
Global $ftpr
Global $prin
Global $ip[$x]

$ip = IniReadSection(@WorkingDir & "\printip.ini", "ips")

GUICreate("IP Print", 250, 120, -1, -1, -1, $WS_EX_ACCEPTFILES)
$ipen = GUICtrlCreateCombo("", 1, 50)
GUICtrlCreateLabel("Select IP", 1, 32, 45, 15)

For $x = 1 To UBound($ip) - 1
    GUICtrlSetData($ipen, $ip[$x][1] & "|")
Next

$ipme = GUICtrlCreateInput("Enter IP", 1, 3, 100, 20)
$ipin = GUICtrlCreateButton("Save IP", 105, 1)
$ftpr = GUICtrlCreateInput("", 1, 97, 100, 20)
GUICtrlSetState($ftpr, $GUI_DROPACCEPTED)
$prin = GUICtrlCreateButton("Print", 105, 94)
GUICtrlCreateLabel("Drag File Here", 1, 77, 75, 15)

GUISetState(@SW_SHOW)

main()

Func main()

    While 1
        $msg = GUIGetMsg()

        If $msg = $ipin Then
            Do
                $i += 1
                $chk = IniRead(@WorkingDir & "\printip.ini", "ips", $i, "")
            Until $chk = ""
            $nwip = GUICtrlRead($ipme)
            IniWrite(@WorkingDir & "\printip.ini", "ips", $i, $nwip)

            GUICtrlSetData($ipen, "")

            For $x = 1 To UBound($ip) - 1
                GUICtrlSetData($ipen, $ip[$x][1] & "|")
            Next

        ElseIf $msg = $prin Then

            print()

        ElseIf $msg = $GUI_EVENT_CLOSE Then
            GUIDelete()
            Exit (1)

        EndIf

    WEnd

EndFunc   ;==>main

Func print()

    $ipad = GUICtrlRead($ipen)
    $flad = GUICtrlRead($ftpr)

    If $ipad = "" Then
        MsgBox(0, "Error", "No IP Selected", 10)
        main()
    EndIf

    If $flad = "" Then
        MsgBox(0, "Error", "No File Selected", 10)
        main()
    EndIf

    Run(@SystemDir&"\cmd.exe")
    WinWaitActive("[CLASS:ConsoleWindowClass]")
    ControlSend("[CLASS:ConsoleWindowClass]","","","lpr -S "&$ipad&" -P raw -o l "&$flad&"{ENTER}")
    ProcessClose("cmd.exe")
    main()

EndFunc   ;==>print

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

That's a good tip. Some of the files can get pretty large. (over 10,000 pages)

On another note, it seems cmd does not like spaces in file paths :mellow: not a big issue, just can be annoying. I tried enclosing the path in quotes but cmd still breaks it apart.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • Developers

Spaces in the filespath should not be an issue. Doesn't something like this work?

RunWait(@ComSpec & ' /c lpr -S "' & $ipad & '" -P raw -o l "' & $flad &'"')
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thank you again Jos. I was just looking into how @COMSPEC was used and you gave me the answer.

As to the quotes, I've used it in other scripts to "close gaps" in file paths, I must have had a missplaced quote when I tried.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

It sure did and printed correctly as well

so even better is, I won't need to edit the program that creates the pcl's :mellow:

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • 3 years later...

Is necro-ing your own post allowed?

This script has been working just fine with no problems all this time, but then the computer I made it for was upgraded to windows 7 64 bit and now it does everything same as it did before except the printer doesn't print anything :(

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • Developers

Are you sure LPR is installed on the Win7 computer, because I believe it isn't by default.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I had just seen in a google search to add/remove windows features and select lpd printservice and lpr port monitor. I tried that on the machine but still the same thing :(

The cmd window pops up for a second as it send the file (assumingly to the printer) then closes and the printer just sits there.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

I think our IT guy has, he's been working on trying to get a file sent to the printer via lpr since I've got multiple things going on. I was thinking that maybe it was changes to how windows 7 handles cmd, or the way 64 bit machine handles cmd?

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

The IT guy seems to have figured it out. The initial /c was killing the process before it even ran for some reason in Win7 64.

They couldn't just remove it because then the process wouldn't be accepted, so they used /k. now it just a matter of closing the process when it's finished.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • Developers

Is the LPR command an x64 program and your Compiled script x86?

If so, you might try compiling your script as x64.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...