Solved

LPD on Win95

Posted on 1998-06-17
10
203 Views
Last Modified: 2010-05-03
Hi, first let me say, I sorry for the lack of detail, I'll be more specific this time.  I
have a machine running win95 that is set up as a print server, its running an app that
has an "lpd" (line print deamon).  When a  spooled file is sent to the machine, the
print server app, must print it or send it back to the host que. if the "device" is on
line and ready the print server will print it.  The "device" in this instance is the
generic text printer,  set to print to a file, so when a spooled file is sent it attemps to
print it using the generic text printer, set to print to a file. My problem is the dialog
box that ask you to name the file, I want my app to handle this process, by detecting
the dialog box, name the file "myfile.txt" and close the dialog box so that no user
intervention is needed.

Example:  Workstation1 sends a file to a Unix lan server, the Unix lan server
redirects the job to the print sever, the print sever prints the job using the generic
text print(set to print to a file) and a dialog box opens asking you to name the file,
you name the file, hit ok, or enter, and the process is complete.  I have a file array
sub wrote to independantly name each file that arrives, so the first file that arrives
will be named "myfile1.txt",   "myfile2.txt", "myfile3.txt", I just can't figure out
deal with the dialog box.  I don't want the user to have to name the file, or deal with the dialg box

Try this, set your generic text print driver up(set to print to a file), go to notepad
type some text and and print it, you will get the dialog box I'm trying to deal with.

                                            Thanks for you support!!
                                                            Rick


  I Need serious help soon......  Thanks
0
Comment
Question by:rhop
10 Comments
 

Author Comment

by:rhop
ID: 1463557
Please HELP!!!!!
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463558
rhop,
Can you be a little more detail on what you want to do? You may e-mail me Dalin_N@mailExcite.com
Regards
Dalin

0
 

Expert Comment

by:vamsi_k
ID: 1463559
Same question as was asked by Dalin.  Could not understand what u exactly wanted to do.  U could email me also to aarveekay@hotmail.com, explaining in detail.  Will try to help.
Regards
Vamsi
0
 

Author Comment

by:rhop
ID: 1463560
Edited text of question
0
 

Author Comment

by:rhop
ID: 1463561
Adjusted points to 400
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:rhop
ID: 1463562
Edited text of question
0
 

Author Comment

by:rhop
ID: 1463563
typeO on the first edit please read the second edited ver....
0
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 400 total points
ID: 1463564
rhop,

Basically the below code is keep looking of the Print to File window and when it is becoming active it will fill it with the information to be saved.

Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long

Dim CurhWnd As Long
Dim LasthWnd As Long
Dim Length As Long
Dim NextNo As Long
Dim txt As String

Private Sub Timer1_Timer()
 CurhWnd = GetForegroundWindow
 If CurhWnd <> LasthWnd Then
  LasthWnd = CurhWnd
  If CurhWnd > 0 Then
   Length = GetWindowTextLength(CurhWnd)
   If Length > 0 Then
    txt = Space(Length + 1)
    Call GetWindowText(CurhWnd, txt, Len(txt))
    If UCase(txt) = "PRINT TO FILE" + Chr(0) Then
     NextNo = GetSetting("PrintQueue", "Settings", "File No", 0)
     NextNo = NextNo + 1
     SendKeys "%n"
     SendKeys "c:\queues\myfile" + Trim(NextNo) + ".txt"
     SendKeys "{ENTER}"
     Call SaveSetting("PrintQueue", "Settings", "File No", NextNo)
    End If
   End If
  End If
 End If
End Sub

The above solution might and might not work fine because it depends on a number incremental, which might be unstable if VB failed to save the new number back to the registry and in this case the process that is trying to print might hang. Therefore the following suggested code is much accurate from my point of view because it depends on the date and time, of course this solution will be an excellent for you if you don't have a problem with file names length greater than 8 characters.

*Replace the above Timer1_Timer sub with the following:

Private Sub Timer1_Timer()
 CurhWnd = GetForegroundWindow
 If CurhWnd <> LasthWnd Then
  LasthWnd = CurhWnd
  If CurhWnd > 0 Then
   Length = GetWindowTextLength(CurhWnd)
   If Length > 0 Then
    txt = Space(Length + 1)
    Call GetWindowText(CurhWnd, txt, Len(txt))
    If UCase(txt) = "PRINT TO FILE" + Chr(0) Then
     SendKeys "%n"
     SendKeys "c:\queues\myfile" + Trim(NextNo) + ".txt"
     SendKeys "c:\queues\" + Format(Date, "DDMMYYYY") + "_" + Format(Time, "HHMMSS") + ".txt"
     SendKeys "{ENTER}"
    End If
   End If
  End If
 End If
End Sub


I hope that will help you to solve your problem.


Best regards
Ben Huwairib
0
 
LVL 5

Expert Comment

by:bin_huwairib
ID: 1463565
rhop,

SendKeys "c:\queues\myfile" + Trim(NextNo) + ".txt"  line in the second solution is typeo so please delete it.

0
 

Author Comment

by:rhop
ID: 1463566
Thanks, It worked great, sorry it took me so long to reply, I've been ill for the past week.  Once again thanks for a very speedy and acurate reply.


                                                     "rhop"
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now