I am making a program which has a functionality to print things. I have managed to put together this snippet which fetches the name of the default printer (if there is one):
import ctypes
buffer = ctypes.create_unicode_buffer(1024)
ctypes.WinDLL("winspool.drv").GetDefaultPrinterW(buffer, ctypes.byref(ctypes.c_ulong(1024)))
printerName = buffer.value
However I cannot figure out how to actually print the file with this. Using notepad.exe with the -P argument (or running a text file with the print verb) it can print but it opens a notepad window and such, which I want to be silent.
The print
command does not allow direct printer names, it requires you to set an LPT port and use that.
If you have any clue how to print the file, now that I have the printer name (It's a txt file if that matters) I would greatly appreciate it!