Process Printer Head Cleaning Programmatically
Greetings sir,
for one of my project, my users use EPSON L130 printer (Inkjet Color Printer).
I don't know why, but this printer needs regular like every single or every 2nd day to do the printer head cleaning otherwise print quality fall (color issue, gap in color etc).
And the issue is, my end users is not that much tech savvy and there are quite a few steps to complete the head cleaning process.
steps:
Code:
1. Go to "Control Panel"
2. Double click on "Device And Printers"
3. Identify the correct printer and check if it is online.
4. Right click on the printer and select "Printing Preferences"
5. Go to "Maintenance" tab.
6. Click on "Head Cleaning"
7. Click on "Start"
8. Wait for the process to complete
9. Click On "Print" button.
10. etc...
so, you see there is 10 steps to complete the head cleaning process, and as mentioned it is too tough for my end users i myself or my staff have to visit them and do that on be-half of them. It is very time consuming process for me as i have to engage my staff just for that :(
so, i am wondering and looking for a way to initiate and complete the head cleaning process from my program it self!
is there any way to do that?
thanks in advance
best regards
Re: Process Printer Head Cleaning Programmatically
Try this...
Code:
Private Declare Function Escape Lib "gdi32" _
(ByVal hdc As IntPtr, ByVal nEscape As Integer, ByVal nCount As Integer, _
ByVal lpInData As String, ByVal lpOutData As Object) As Integer
Private Const PASSTHROUGH As Integer = 19
Dim pd As New Printing.PrintDocument
Private Sub Cleanit()
Dim tmp As String
tmp = Chr(27) & "some cleaning string"
Dim hDC As IntPtr = pd.PrinterSettings.CreateMeasurementGraphics.GetHdc
Escape(hDC, PASSTHROUGH, Len(tmp), tmp, 0)
pd.PrinterSettings.CreateMeasurementGraphics.ReleaseHdc(hDC)
End Sub
Re: Process Printer Head Cleaning Programmatically
Quote:
Originally Posted by
.paul.
Try this...
Code:
Private Declare Function Escape Lib "gdi32" _
(ByVal hdc As IntPtr, ByVal nEscape As Integer, ByVal nCount As Integer, _
ByVal lpInData As String, ByVal lpOutData As Object) As Integer
Private Const PASSTHROUGH As Integer = 19
Dim pd As New Printing.PrintDocument
Private Sub Cleanit()
Dim tmp As String
tmp = Chr(27) & "some cleaning string"
Dim hDC As IntPtr = pd.PrinterSettings.CreateMeasurementGraphics.GetHdc
Escape(hDC, PASSTHROUGH, Len(tmp), tmp, 0)
pd.PrinterSettings.CreateMeasurementGraphics.ReleaseHdc(hDC)
End Sub
thanks a lot for your reply sir..
but i really don't understand what it would do? can you please explain your code a bit?
will it do the same cleaning process as i mentioned in the steps? or just write/print "some cleaning string" on a blank page?
once again thanks for your reply sir
best regards
Re: Process Printer Head Cleaning Programmatically
I found this legacy vb answer here...
http://www.vbforums.com/showthread.p...=1#post1366444
You'll have to search for the exact escape sequence that triggers head cleaning...
Re: Process Printer Head Cleaning Programmatically
Quote:
Originally Posted by
.paul.
I found this legacy vb answer here...
.....
You'll have to search for the exact escape sequence that triggers head cleaning...
Sir, when i tried your exact code, following error occurred:
Code:
PInvokeStackImbalance was detected
Message: A call to PInvoke function 'Head Clean!Head_Clean.Form1::Escape' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
and then i tried to change nEscape and nCount to long from integer, doing so return different error:
Code:
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
any idea/help please?
thanks in advance
best regards
Re: Process Printer Head Cleaning Programmatically
As .paul mentioned, that is legacy code, i.e. code for VB6 or before.
Since you're using .Net, you have to change the code to be compatible with .Net.
In particular, the Long in VB6 is 32-bits. So you need to replace the VB6 Long in the declaration with a .Net 32-bit Integer, like Integer for instance.
Re: Process Printer Head Cleaning Programmatically
The code i posted in post #2 is that legacy code updated for vb.net, but as i also said, i don't know the exact escape sequence you need to send to your printer to initiate the head cleaning. In the code i posted, you need to change the value of tmp to whatever escape sequence your printer requires...
Re: Process Printer Head Cleaning Programmatically
Quote:
Originally Posted by
.paul.
The code i posted in post #2 is that legacy code updated for vb.net, but as i also said, i don't know the exact escape sequence you need to send to your printer to initiate the head cleaning. In the code i posted, you need to change the value of tmp to whatever escape sequence your printer requires...
hi thanks for your reply sir..
how can i find the " exact escape sequence" for my printer, my printer model is epson L130...
and also sir, when i tried your code (updated using the help of pInvoke.net)..
it crash the app.. :(
thanks in advance again..
best regards
Re: Process Printer Head Cleaning Programmatically
Re: Process Printer Head Cleaning Programmatically
Quote:
Originally Posted by
jdc2000
thanks for your reply sir, but as i mentioned i am looking or a automatic/programtic solution..
though of course i must admin yours solution need less steps than i specified in my post...
best regards
Re: Process Printer Head Cleaning Programmatically
There may or may not be an Escape or other character sequence that you can send to the printer to cause the Head Cleaning sequence to activate. However, it may be possible to use the Epson utility to trigger the head cleaning, either with a batch file /desktop icon or a scheduled task.
Re: Process Printer Head Cleaning Programmatically
Quote:
Originally Posted by
jdc2000
There may or may not be an Escape or other character sequence that you can send to the printer to cause the Head Cleaning sequence to activate. However, it may be possible to use the Epson utility to trigger the head cleaning, either with a batch file /desktop icon or a scheduled task.
yes i am also thinking that, now i am planning to use ui.automation to automate the steps.
thanks for your help though..
best regards