DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: want to invoke PrinterDialog, using -setprinter?  (Read 6,608 times)

towser

  • Participant
  • Joined in 2012
  • *
  • Posts: 3
want to invoke PrinterDialog, using -setprinter?
« on: July 12, 2012, 11:43 AM »
Hello.
I am currently trying to make a command line batch file using MiniCap.
What i intend to do is simply capture the active window, and invoke the printing dialog.
Automatically print does of course work using "-print", but only invokes the default printer.

Is it possible to somehow invoke the Windows PrintingDialog, and select the desired printer?
-- either using MiniCap or using win batch code
If yes, how would i use it in the batch file?

My code so far in "mcprint.bat" (as mentioned, nothing special):

Quote
@echo off
"\MiniCap.exe" -captureactivewin -print -exit


Thank you for your time!
-towser

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #1 on: July 12, 2012, 12:51 PM »
Changing the default printer can be done using rundll32 like this:
Code: (text)
rundll32 printui.dll,PrintUIEntry /y /q /n "Printer name"

Source

Some more info on PrintUI can be found here
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

towser

  • Participant
  • Joined in 2012
  • *
  • Posts: 3
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #2 on: July 12, 2012, 01:16 PM »
thank you so much for your reply!
thought it could be "easier" than using rundll32
will do some reading now and use that ;)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #3 on: July 12, 2012, 02:32 PM »
Ath's solution may work and is a good general solution when you need to set the default printer for any app,

BUT you are using MiniCap, which has a way to specify the printer to use and does not require changing the default printer.

From the MiniCap help file, pass commandline option "-setprinter" as follows:

-setprinter PRINTERNAME
sets a specific printer for printing (to get a list invoke -setprinter list); you can use the full name or a substring

towser

  • Participant
  • Joined in 2012
  • *
  • Posts: 3
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #4 on: July 26, 2012, 09:07 AM »
hello again.
i had found "-setprinter list" before, but had trouble using it, as it would not produce any result, or "list" at all on execution, but only after i was "done" doing the screenshot, and had my batch file completed.
what i intend to do is
- automatically take a screenshot of the fullscreen, or last active window
- print this
- for printing use the default fancy gui that you get when you want to print any image under windows, and have the printer selected manually within this gui

meaning i would rather not like to pass the printername on commandline, but have the user select it manually after the screenshot has been taken
i suppose i could use "run" as commandline, and define the printing gui as parameter, if there was something like this...
or alternatively, copy the screenshot to clipboard, and invoke the printing gui using this clipboard?

-regards

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #5 on: August 12, 2012, 06:33 PM »
what about using the MINICAP commandline option:
-printpreview

that should present a print preview dialog and let user choose printer.
« Last Edit: August 12, 2012, 06:46 PM by mouser »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #6 on: August 17, 2012, 04:33 AM »
to clarify, if you pass the -printpreivew commandline option in addition to the -print option, you will get the print preview dialog prior to printing; there you will find a Setup Printer button to change the target printer from the default.

Original address: https://www.donationcoder.com/forum/index.php?topic=31590.0