prtsc direct to print

Hi experts!
I wrote the code:
My.Computer.Keyboard.SendKeys("{PRTSC}", True) in a botton click.
I need code to print direct.
Tks.
MGASPARAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Depending on how much functionality you need, you can do it quite simply in fact. If you add a PrintDocument to your form, then you can print the image via the PrintDocument's PrintPage event. Here's an example of how:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        My.Computer.Keyboard.SendKeys("{PRTSC}", True)
        Me.PrintDocument1.Print()
    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Using screenGrab As Image = My.Computer.Clipboard.GetImage()
            e.Graphics.DrawImage(screenGrab, New Point(100, 100))
        End Using
    End Sub
End Class

Open in new window


And then you get something like this:

Result Screenshot
Do take note that the above code relies on the default printer. You can allow the user to select by adding some of the other print controls, or the user can switch their default printer for printing purposes. For the screenshot above, I used the MS XPS document printer.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
Grrrr....   Wrong screenshot. Corrected below.
untitled.PNG
0
MGASPARAuthor Commented:
Hi Kaufmed!
Perfect.
Simple, clear and efficient.
Thank you!
0
käµfm³d 👽Commented:
NP. Glad to help  = )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.