1

i tried doing this, but it does not work with png, if you can help out, that would be great!

import datetime


while True:
    now = datetime.datetime.now()
    if now.hour == 8 and now.minute == 10:
        os.startfile(r'''D:\testpage.png''', "print")
        break

2 Answers2

0

Is it necessary to be done with python? Instead of writing a program that runs in the background and checks the time, it is better to use a built-in solution in your OS like cron.

You can find here how to run scheduled tasks on Windows: Setting up a cron job in Windows

And how to print files from command line: command line tool for print picture?

fela
  • 679
  • 8
  • 7
  • not necessary to be done with python, i believe cron is for linux, and task scheduler can run a program/script.. still need a way to print png with a script/program – PlexAlanahce Jan 28 '22 at 06:02
  • you can write a short script in batch file or power shell and add it to scheduled tasks. Batch file just contains list of commands you can run from cmd terminal. If you need variable image to be printed you can pass it as an argument to your script https://stackoverflow.com/questions/26551/how-can-i-pass-arguments-to-a-batch-file – fela Jan 28 '22 at 07:55
0

Answer: i used the command

mspaint /pt [image filename]

using notepad and saved it as a batch file, and used Windows Task Scheduler to run the batch file everyday Thanks!

  • Thanks for sharing your solution. Can you share a full code snippet that you have used to make the answer meet the quality standard here? – TeilaRei Jan 28 '22 at 15:13
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 28 '22 at 15:14