Jump to content

Recommended Posts

Posted (edited)

Here is a small .exe file (13kb) that does nothing by itself, but when you drag and drop image files into it (single or multiple) it invokes the 'Print Pictures Wizard' and allows staff/students to easily print contact sheets or select special features for photo printing in Windows

 

This is especially useful if you have blocked 'right-click' in W11 as file explorer no longer contains any 'print' buttons in W11 (thanks MS)

 

The usual 'I take no responsibility' applies, it was written in Visual Basic using .net 4.5 - 80 lines of code taken from a 'Power Basic' script and converted to VB using ChatGPT

 

It can be hosted on a network share, copied to locations, or shortcuts created, and it still works if you drag and drop onto the shortcut.

 

Enjoy!

Imports WIA ' Windows Image Acquisition Library (WIA)

Module Module1

    Sub Main()
        ' Get command-line arguments passed to the application
        Dim commandLineArgs As String() = Environment.GetCommandLineArgs()

        Dim wsImages As New List(Of String)()
        Dim lArg As Integer = 1
        Dim lPic As Integer = 0

        ' Command-line argument processing (simulate drag-and-drop of files)
        While lArg < commandLineArgs.Length
            Dim wsFile As String = commandLineArgs(lArg).Trim("""")

            If IO.File.Exists(wsFile) AndAlso wsFile.Length > 4 AndAlso
                (wsFile.ToUpper().EndsWith(".BMP") OrElse
                 wsFile.ToUpper().EndsWith(".GIF") OrElse
                 wsFile.ToUpper().EndsWith(".ICO") OrElse
                 wsFile.ToUpper().EndsWith(".JPG") OrElse
                 wsFile.ToUpper().EndsWith(".PNG") OrElse
                 wsFile.ToUpper().EndsWith(".TIFF")) Then

                lPic += 1
                wsImages.Add(wsFile)
            Else
                Console.WriteLine(wsFile & " does not have an acceptable image extension" & vbCrLf &
                                  "Only drop .BMP, .GIF, .ICO, .JPG, .PNG, or .TIFF files")
            End If

            lArg += 1
        End While

        If wsImages.Count > 0 Then
            PrintImages(wsImages.ToArray())
        Else
            Console.WriteLine("No images passed on command line")
        End If
    End Sub

    Sub PrintImages(wsFiles As String())
        Dim WIADlg As WIA.CommonDialog = New WIA.CommonDialog()
        If WIADlg IsNot Nothing Then
            Dim Vec As WIA.Vector = New WIA.Vector()
            If Vec IsNot Nothing Then
                For Each wsFile As String In wsFiles
                    Vec.Add(wsFile)
                Next
                Dim v As Object = Vec
                WIADlg.ShowPhotoPrintingWizard(v)
                Vec = Nothing
            End If
            WIADlg = Nothing
        End If
    End Sub

End Module

 

ContactPrint.exe

Edited by Warwick_Tech

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



×
×
  • Create New...