Solved

LPD on Win95

Posted on 1998-06-17
10
205 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 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