Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LPD on Win95

Posted on 1998-06-17
10
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:rhop
ID: 1463560
Edited text of question
0
 

Author Comment

by:rhop
ID: 1463561
Adjusted points to 400
0
 

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 1600 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

719 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