Valhalla Legends Archive

General => General Discussion => Topic started by: iago on November 05, 2003, 06:17 PM

Title: Doing the same thing every day.
Post by: iago on November 05, 2003, 06:17 PM
I'm not terribly sure how to do this, but I Suspect it could involve Scheculed Tasks :)

Anyway, my mom does crosswords every day, and I need to print them off.  So far, I'm doing it manually.  

It would be nice to have this automated.  The URL each day is slightly different, but I can easily write a C program to calculate this url.  So I'm faced with 2 problems:

a) How do I write a C or C++ program to print a website?  I'm sure there's a switch on iexplore to do it, which I could run from a program.

b) How do I make sur ethis program runs exactly once a day?
Title: Re:Doing the same thing every day.
Post by: Skywing on November 05, 2003, 06:19 PM
Perhaps the MFC web browser components, WinInet, or wget could be used to fetch the page.

As for only running once per day, you could store the last start date in the registry and check that on startup.
Title: Re:Doing the same thing every day.
Post by: Spht on November 05, 2003, 06:22 PM
What's the URL for the crossword page?
Title: Re:Doing the same thing every day.
Post by: Thing on November 05, 2003, 06:43 PM
cron
Title: Re:Doing the same thing every day.
Post by: iago on November 05, 2003, 06:47 PM
Quote from: Spht on November 05, 2003, 06:22 PM
What's the URL for the crossword page?

http://www.uclick.com/puzzles/cx/03/11/05/Puzpic.gif


And Skywing - I really didn't want to do it that way, mainly because I don't use that computer every day; in fact, it gets used maybe twice a week.  But it's on all the time, as a server type dealy.  

I was hoping for an easier way to download the page; in fact, it's a .gif, so is that even possible with your method?  

Unless I get some other way of doing it, though, I'll look into those controls; thanks! :)
Title: Re:Doing the same thing every day.
Post by: Spht on November 05, 2003, 07:02 PM
The fastest solution to download the image ("http://www.uclick.com/puzzles/cx/" & Format(Date, "yy/mm/dd") & "/Puzpic.gif") would probably be to use WinInet. In Visual Basic, I'd probably display the image on a picture box (or form) then use the Printer object to paint the image, and then print it. You can store last date in registry as Skywing suggested and have your program automatically ran daily.
Title: Re:Doing the same thing every day.
Post by: MyndFyre on November 05, 2003, 07:53 PM
Hrm, I've been looking into getting into printing with .NET, want me to write you a quick program?  It'll run in the tray and print off once a day.  Lemme know  =)
Title: Re:Doing the same thing every day.
Post by: Thing on November 05, 2003, 08:22 PM
#!/bin/bash

URL=http://www.uclick.com/puzzles/cx/$(date +%y)/$(date +%m)/$(date +%d)/Puzpic.gif
wget $URL
lp Puzpic.gif


./edit I forgot to add the printing part.
You windows guys always make things difficult. :P
Title: Re:Doing the same thing every day.
Post by: iago on November 05, 2003, 09:10 PM
Quote from: Thing on November 05, 2003, 08:22 PM
#!/bin/bash

URL=http://www.uclick.com/puzzles/cx/$(date +%y)/$(date +%m)/$(date +%d)/Puzpic.gif
wget $URL
lp Puzpic.gif


./edit I forgot to add the printing part.
You windows guys always make things difficult. :P

That WOULD be nice, but .. well, you know exactly why it's not!  :P

Actually, I'm planning on installing linux sometime soon, but some body needs to convince me.  I'm going to post antoher thread on it in the next week or so :)
Title: Re:Doing the same thing every day.
Post by: Adron on November 07, 2003, 10:25 AM
You could just spawn a copy of wget with the right arguments. Or if the page is linked to from some constant url, spawn "wget -r -l 1 <url to page that links to the gif>".
Title: Re:Doing the same thing every day.
Post by: Spht on November 07, 2003, 10:35 AM
http://www.valhallalegends.com/spht/files/cwd.zip

Let me know if it works. I made it faily quickly and never gave it much testing. On run, connects to server to download image file (based on current date), then stores last date in registry, prints off the image, then exits. Storing last date in registry is simply for determining if it already has the image for the current date (incase you happen to run the program twice on the same day). If last date < current date, it'll close.
Title: Re:Doing the same thing every day.
Post by: Thing on November 07, 2003, 10:54 AM
wget http://www.uclick.com/puzzles/cx/$(date +%y)/$(date +%m)/$(date +%d)/Puzpic.gif
Somanabench, I should have tried that first!  For some weird reason I thought that wget would not execute the command in the parenthesis.
Title: Re:Doing the same thing every day.
Post by: iago on November 07, 2003, 12:36 PM
Quote from: Spht on November 07, 2003, 10:35 AM
http://www.valhallalegends.com/spht/files/cwd.zip

Let me know if it works. I made it faily quickly and never gave it much testing. On run, connects to server to download image file (based on current date), then stores last date in registry, prints off the image, then exits. Storing last date in registry is simply for determining if it already has the image for the current date (incase you happen to run the program twice on the same day). If last date < current date, it'll close.

wow, thanks, Spht!  When I get home I'll give it a try!