Thanks to
Sean and
his great idea, I could think of a solution to switch my default printer within a given list (of, in this case, 2 printers).
Of course, you could think of something like cycling through a whole array of printers.
Code:
LWin & PrintScreen::
Printer1 = Minotaurus ; change according to your Printer1
Printer2 = Adobe PDF ; change according to your Printer2
If (GetDefaultPrinter() = Printer1)
{
SetDefaultPrinter(Printer2)
}
Else
{
SetDefaultPrinter(Printer1)
}
GetDefaultPrinter()
{
nSize := VarSetCapacity(gPrinter, 256)
DllCall(A_WinDir . "\system\winspool.drv\GetDefaultPrinterA", "str", gPrinter, "UintP", nSize)
Return gPrinter
}
SetDefaultPrinter(sPrinter)
{
DllCall(A_WinDir . "\system\winspool.drv\SetDefaultPrinterA", "str", sPrinter)
TrayTip, AHK » Drucker und Faxgeräte, %sPrinter% wurde als Standard definiert., 10, 17
; the English translation would be:
; AHK » Printers and Faxes, %sPrinter% set as default printer.
Sleep, 3000
TrayTip
}
return
Note that the tray tip causes a delay of 3 seconds before another switch can be triggered.
Update 2008-02-09: on Vista-based machines, please replace the two "\system\" sections by "\System32\". Enjoy!
I hope this comes in handy to somebody as it did for me.
Christian Sentis