topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday December 15, 2024, 2:04 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

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

towser

  • Participant
  • Joined in 2012
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
want to invoke PrinterDialog, using -setprinter?
« on: July 12, 2012, 06: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):

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


Thank you for your time!
-towser

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #1 on: July 12, 2012, 07:51 AM »
Changing the default printer can be done using rundll32 like this:
Code: Text [Select]
  1. rundll32 printui.dll,PrintUIEntry /y /q /n "Printer name"

Source

Some more info on PrintUI can be found here

towser

  • Participant
  • Joined in 2012
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #2 on: July 12, 2012, 08:16 AM »
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,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #3 on: July 12, 2012, 09:32 AM »
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
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #4 on: July 26, 2012, 04: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,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #5 on: August 12, 2012, 01: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, 01:46 PM by mouser »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: want to invoke PrinterDialog, using -setprinter?
« Reply #6 on: August 16, 2012, 11:33 PM »
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.