Jump to content

Printdone


Recommended Posts

Can someone take a look at the following scripts and let me know if there is a better way to do it.

Basically, after the file is printed. I want a message box to be display so the user is aware that the printing is done. Thank you in advance.

Question: If it failed to print the message should not be display. Should I add error if not printed?

Before:

$i_Show = @SW_HIDE
$File = _FilePrint ($v_path&$s_serial&".log")
_FilePrint($File, $i_Show)
    Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "print", _
            "string", $File, _
            "string", "", _
            "string", "", _
            "int", $i_Show)
   If $a_Ret[0] > 32 And Not @error Then
       Return 1
    Else
        SetError($a_Ret[0])
        Return 0
    EndIf
Exit
EndIf

After: (This is one way I was able to make the message box appear)

;Print the Report.
$i_Show = @SW_HIDE
$Msg_Show = @SW_SHOW
$File = _FilePrint ($s_path&$s_serial&".log")
_FilePrint($File, $i_Show)
    Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "print", _
            "string", $File, _
            "string", "", _
            "string", "", _
            "int", $i_Show)
   If $a_Ret[0] > 32 And Not @error Then
       Return 1
    Else
        SetError($a_Ret[0])
        Sleep (10000) 
        MsgBox(0,"SUCCESS","Report Has been Printed.") 
        Return 0
    EndIf
Link to comment
Share on other sites

yours didn't work for me...

this does

#include <GUIConstants.au3>

Dim $i_Show, $a_Ret

$File = _FilePrint ("test.txt", @SW_HIDE)

If $File = 1 Then
    MsgBox(64,"Sucess", " a page has been sent to the printer  ", 3)
Else
    MsgBox(64,"Failure", " The page was not sent to the printer  ", 3)
EndIf

Func _FilePrint($File, $i_Show)
    $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "print", _
            "string", $File, _
            "string", "", _
            "string", "", _
            "int", $i_Show)
   If $a_Ret[0] > 32 And Not @error Then
       Return 1
    Else
        SetError($a_Ret[0])
        Return 0
    EndIf
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

Thanks Valuater, I will try your script. I was looking to have a message box to display after the file has been printed. How can I do this?

yours didn't work for me...

this does

#include <GUIConstants.au3>

Dim $i_Show, $a_Ret

$File = _FilePrint ("test.txt", @SW_HIDE)

If $File = 1 Then
    MsgBox(64,"Sucess", " a page has been sent to the printer  ", 3)
Else
    MsgBox(64,"Failure", " The page was not sent to the printer  ", 3)
EndIf

Func _FilePrint($File, $i_Show)
    $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "print", _
            "string", $File, _
            "string", "", _
            "string", "", _
            "int", $i_Show)
   If $a_Ret[0] > 32 And Not @error Then
       Return 1
    Else
        SetError($a_Ret[0])
        Return 0
    EndIf
EndFunc

8)

; A Message box here if possible????
Link to comment
Share on other sites

Help, please.

I am still can't figure out why after the report prints, I cannot have a message box that informs the user that the report is now printed. Can some look at the script that I originally posted. I have tried the script that Valuater suggested and it works good, but I really need to have the message box display at the end of the print job.

Thanks Valuater, I will try your script. I was looking to have a message box to display after the file has been printed. How can I do this?

; A Message box here if possible????

Link to comment
Share on other sites

Help, please.

I am still can't figure out why after the report prints, I cannot have a message box that informs the user that the report is now printed. Can some look at the script that I originally posted. I have tried the script that Valuater suggested and it works good, but I really need to have the message box display at the end of the print job.

the script i gave you has a message box...

cant you see it????

8)

NEWHeader1.png

Link to comment
Share on other sites

Valuater,

Yes I do see the message at the begining of printing, but I need a message at the end. When the printing is complete all windows close automatically, there is no way of knowing if the printing is done or not, unless a message box is there to tell you. I hope this makes sense.

logically, your script is perfect. It notifies you that the report has being sent to the printer, so one would assume to walk to the printer to obtain the report. But for the work Environment in my company I work for, there is alot of Distraction. People walk away and come back not knowing were they left off. I hope this helps. Thanx

the script i gave you has a message box...

cant you see it????

8)

Link to comment
Share on other sites

Valuater,

After thinking about it. I realized that by taking the delay time of the message box, after the file prints the message box stays Open and it will close only after the user clicks OK.

Thanks everyone for the help . I really appreciated.

Have a good day.

Meetrix

Valuater,

Yes I do see the message at the begining of printing, but I need a message at the end. When the printing is complete all windows close automatically, there is no way of knowing if the printing is done or not, unless a message box is there to tell you. I hope this makes sense.

logically, your script is perfect. It notifies you that the report has being sent to the printer, so one would assume to walk to the printer to obtain the report. But for the work Environment in my company I work for, there is alot of Distraction. People walk away and come back not knowing were they left off. I hope this helps. Thanx

Link to comment
Share on other sites

I will read the Help and learn more about it. For now, I'm good to implement what I have. Thanks for your help.

Welcome

i thought about this a little last night...

i think the printer creates a process... and you could check when that process terminates

if processexists()

just an idea

8)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...