Solved

LPD on Win95

Posted on 1998-06-17
10
202 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

758 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

21 Experts available now in Live!

Get 1:1 Help Now