19
cb219
5y

Well I FUCKING FINALLY managed to build a program that makes my dad's printer print automatically.
Have ranted about this on my previous rant.
My recent approach was actually overengineered all over the top. I was using pyautogui to simulate the mouse that would call the settings window on Windows, which would print a nozzle test (the translation for "Düsentestmuster" according to google?). The more I worked with it, the more I would have had to care about edge cases when calling the settings and god knows what else...πŸ˜–
So I left the idea.
What I came up with was a python script with some copy-pasted code of an example from the win32print api that printed an image that I specified, so it would use all inks. Somehow it works perfectly...
After that I used the win32api. ShellExecute() with ghostscript to print a PDF for the PGBK ink.
Finally a batch script to run this python script on the task scheduler. No converted .exe as dependencies and whatnot let it all go to hell.πŸ˜’

It's not quite what I had originally anticipated as a solution but IT FINALLY FUCKING WORKS!!
...πŸ˜ͺ It took way longer than expected and although I somehow couldn't manage to print all on 1 paper, I'm still satisfied that it really works.

That's all, had to vent my frustration and share this personal success.

Comments
  • 1
    Just one word... Windows πŸ˜‚
  • 2
    @joas I think I could write a whole rant about that but ... that's for another day.
    My dad doesn't know anything besides Windows. I experimented several times with Linux Ubuntu/Mint and other ones, it lacks too many things to be considered an alternative (for me). The fact that I can't handle it well enough tells me my dad will (probably) neither.
    My dad's PC also runs a "cash system" software ("Kassensystem/Warenwirtschaftssystem" on google translate?🀷), which only runs on Windows.
    I know you meant it as a joke, but there's no other way for me.πŸ˜πŸ˜…
  • 0
    Curious to know the reason for doing this?
  • 1
    @HighTurtleDev you mean what problem I originally had or how I ended up with my solution?
  • 1
    @cb219 Sorry, realise I wasn't very clear. What was the original problem?
  • 3
    @HighTurtleDev ok so the original problem was that my dad has got a food printer he uses for customers that order cakes with edible images on top. The printer for this task is not used regularly, so the ink drying up and, in worst case using the printer again with dry ink, will damage the printer permanently, which makes it unusable. Already bought a new printer because of thisπŸ˜–.
    The solution is to regularly let the printer run, e.g. once a week. This can be automated in Windows and that's what I tried to achieve.
    Otherwise my dad wanted to keep track of the print jobs with pen and paper, which I don't believe is good idea, for several reasons one can discuss about.
  • 0
    Should look into c/c++, this still sounds heavily overengineered.
  • 0
    @nitwhiz Have a tiny bit of experience with C, never worked with C++.
    Thought about C but didn't find anything really useful. Don't know whether I would consider looking into a C/C++ solution, but if you can tell me a source how to do it, I might give it a try. My python script us now 40 lines of pure code + a batch one-liner + 2 printable files🀷
  • 1
    well, post it to git somewhere then
  • 2
    @jesustricks thanks for the idea! had it as a private repo but I guess others might benefit too, so why not...
    I mean there might still be a better way to do this but I guess if people are fine with my approach, they might as well use it too. 🀷
  • 1
    @cb219 I don't think it has to be used, if it can, cool, but it can be educational to see what to printer controlling windows command line code looks like.
  • 1
Add Comment