 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
controlfreak
Joined: 13 Apr 2007 Posts: 7 Location: Unterschleißheim, BY, DE
|
Posted: Sat Apr 14, 2007 2:21 pm Post subject: WORKS: switch default printer upon hotkey trigger |
|
|
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 _________________ On-on!
Last edited by controlfreak on Sat Feb 09, 2008 10:31 am; edited 3 times in total |
|
| Back to top |
|
 |
Justineo14
Joined: 30 Oct 2006 Posts: 43
|
Posted: Mon Apr 16, 2007 7:57 am Post subject: |
|
|
Why don't you make a pop up menu?? _________________ Tex© Click here to mail me |
|
| Back to top |
|
 |
randy@ahk Guest
|
Posted: Mon Aug 20, 2007 3:48 pm Post subject: Doesnt work.. |
|
|
Thanx for the script, the idea sounds very usefull. But it doesnt work on my windows version (XP). It shows the message and all seems well, but my printer doesnt get changed. I tried a few different name styles for my printers, but all dont work.
Could it be that my version of winspool.drv doesnt support printer change?
Any idea?
Thanx!
Randy |
|
| Back to top |
|
 |
randy@ahk Guest
|
Posted: Mon Aug 20, 2007 3:56 pm Post subject: Apologies,.. found the answer.. |
|
|
I found the answer in the post you mentioned at the top, I overlooked that one. Sorry..
In my case it missed a network adress: "/a100/".
Again, great idea... for me it's very usefull!
Greets,
Randy |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Aug 20, 2007 7:48 pm Post subject: Re: Apologies,.. found the answer.. |
|
|
| randy@ahk wrote: | Again, great idea... for me it's very usefull! |
Randy,
Thank you for your appreciated feedback! Always nice to hear
Christian |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|