Sign in to follow this  
Followers 0
james3mg

calendar on your wallpaper

25 posts in this topic

#1 ·  Posted (edited)

Well, I just did this to help myself learn how to script using the ImageMagickObject.dll COM interface, but it turned out cool and I thought I'd share it!

NOTE THAT IMAGE MAGICK MUST BE INSTALLED ON YOUR COMPUTER!

You can download it from here if you don't have it already. Personally, I like just having the static dll registered in regsrv32 - then I don't need the program installed.

(in my original script I threw #include <ImageMagickObject.dll.au3> (a file I created) at the top of my scripts to take care of registering the dll if it's not on the computer already, including accepting their legal requirements, but that include file is 12mb - too big to post here in any way, so I just took out that line, and you need to have it registered yourself).

Thanks to GeoSoft, I've got a reliable upload of ImageMagickObject.dll.au3 here! No more problems with my other online storage site denying your request because someone else already downloaded it this hour! (stupid, stupid site). Download the .zip file from the above link (note my computer wanted to leave .zip off the filename) then extract the au3 file in it into either your autoit includes folder, or the same directory as the below script, and run the updated script below...that's it! If ImageMagick is already installed, there won't be any effect. If it's not, you'll be prompted to accept their EULA at the beginning of the script.

Note that in the new version of the script, there's only one place to change the filename to .bmp if you're on XP.

Attached is also a portion of my current wallpaper - you can see the effect of this script in the upper-right hand corner.

#include <ImageMagickObject.dll.au3>
#include <Date.au3>
Global $oIM=ObjCreate("ImageMagickObject.MagickImage.1")
Global $NewWallpaperPath=@WindowsDir&"\AutoitCalendarWallpaper.jpg"
Global $WeekOffset=2
$oIM.Convert(RegRead("HKCU\Control Panel\Desktop","Wallpaper"),"-resize",@DesktopWidth&"x"&@DesktopHeight,"-gravity","northeast","-stroke","#000c","-strokewidth","2","-annotate","0x0+50+20",_DateToMonth(@MON,0)&" "&@YEAR,"-stroke","none","-fill","white","-annotate","0x0+50+20",_DateToMonth(@MON,0)&" "&@YEAR,$NewWallpaperPath)

For $i=1 To _DateDaysInMonth(@YEAR,@MON)
    If _DateToDayOfWeek(@YEAR,@MON,$i) = 1 AND $i <> 1 Then $WeekOffset+=1
    If $i=@MDAY Then
        $Color="red"
    Else
        $Color="white"
    EndIf
    $oIM.Convert($NewWallpaperPath,"-gravity","northeast","-stroke","#000C","-strokewidth","2","-annotate","0x0+"&160-(_DateToDayOfWeek(@YEAR,@MON,$i)*20)&"+"&$WeekOffset*20,$i,"-stroke","none","-fill",$color,"-annotate","0x0+"&160-(_DateToDayOfWeek(@YEAR,@MON,$i)*20)&"+"&$WeekOffset*20,$i,$NewWallpaperPath)
Next

_ChangeWallpaper($NewWallpaperPath,3)

Func _ChangeWallpaper($sFile, $iType)
    If Not FileExists($sFile) Then
        SetError(1)
        Return -1
    EndIf
    Select
        Case $iType = 1
            RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '1')
            RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0')
        Case $iType = 2
            RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
            RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0')
        Case $iType = 3
            RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
            RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2')
        Case Else
        ;
    EndSelect
    RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile)
    DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0)
    Return 0
EndFunc

Note that if you're running XP, you need to change the references to AutoItCalendarWallpaper.jpg to AutoItCalendarWallpaper.bmp in the four locations it's referenced - Vista doesn't work if that's a .bmp file, and XP doesn't work if it's a .jpg! Go figure!

As far as credit where it's due: I obviously used the Date.au3 include file, and I took the _ChangeWallpaper function from somewhere on the forum, but I can't remember where - I originally used it in my random wallpaper slideshow script, so I just copied it from there this time. Let me know who wrote it and I'll credit you, for what that's worth in a modest script like this. <_<

Edit: I should have added; this won't modify your current wallpaper file at all - it copies it (after discovering what it is in the registry) into the Windows directory with a filename of AutoItCalendarWallpaper, resizing as it goes so the text doesn't shrink down when using a large original wallpaper file. If you have some kind of automatic wallpaper rotater running, you'll have to run this each time it rotates to add the current calendar onto your new wallpaper. Otherwise, run it once a day to update the 'current day' indication. Until the month changes, that shouldn't be a problem. Once the month changes, you'll be overwriting the new month text on top of the old month text and it could get messy. Change back to the calendar-less original wallpaper and run the script again to clean it up once more.

Edit: I'm working on seeing if I can't shrink down the size of the ImageMagickObject.dll.au3 include file. As it stands right now, the smallest script that #includes it compiles to around 4mb...not bad considering the tradeoff of powerful image manipulation in this world of gigabyte-sized programs, but not exactly what you expect from an AutoIt script. If I get it shrunk down, I'll repost it here.

post-5585-1192749411_thumb.jpg

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites



That's pretty neat!

Share this post


Link to post
Share on other sites

Was not able to find the dll after installing program - no where on my computer.

But I like the idea!


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

When you install it there is an option to install the dll for com usage which is automatically unchecked.

Share this post


Link to post
Share on other sites

Wow! It works great!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks for your encouragement! :)

See my first post again - I stuck the #include ImageMagickObject.dll.au3 line back in at the top and included a link to a link where you can download my include file, so now you don't have to install ImageMagick's entire package to use this script. Note if you run this and accept the EULA, the script won't delete or unregister the dll it creates and registers...you can do this manually with

regsvr32 /u ImageMagickObject
then deleting @Systemdir\ImageMagickObject.dll.

I'm working on getting the size of the #include file down. I'll repost it here if I succeed. I don't have Visual Studio or I'd compile a custom version of the dll that only had the functions I needed :-)

Have fun! Let me know what you think of this approach!

--------

Edit: I'm trying (and failing) to use StringRegExpReplace() to find characters in the dll string that repeat more than 14 times, and replace the repeating characters with

"&rep('[the repeating character]',[the number of times it repeats])&"
For instance, if the string were "abc000000000000000000def", it would be replaced with "abc"&rep('0',18)&"def" Then rep() would just be a simple 4-line loop function that returns the first parameter, repeated the number of times listed in the second parameter. That way, it would be as absolutely short as possible. However, StringRegExp is hard enough for me...throwing a replace in there with back references is way beyond me. I can't even get [:xdigit:]{14,} to consistently find a repeating character. So I'm stumped. <_< Probably just plan on using the full #include file I gave you above for now. I'll let you know if I get it working. Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Well, I just did this to help myself learn how to script using the ImageMagickObject.dll COM interface, but it turned out cool and I thought I'd share it!

Nice, thank you for sharing. I have a work I am on to which I am going to add it!

A suggestion: it might be easier to run a UDF like _AddCalendarToImage($srcImage, $dstImage)

Share this post


Link to post
Share on other sites

The design looks like a Theme of Reinlendar

Share this post


Link to post
Share on other sites

the link to your zip is broken


[size="1"]Please stop confusing "how to" with "how do"[/size]

Share this post


Link to post
Share on other sites

the link to your zip is broken

Hmm...seems to still be working to me...

@ptrex...thanks! <_<

@MCP...I agree, but I believe there's already been an ImageMagickObject UDF put out there with functions similar to this...my goal with this particular script wasn't to write a UDF but to write a script that accomplished a certain task. Feel free to modify it however you see fit.


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Nice script! Would it be hard to add left & right arrows for the previous & next months?

-John

Hard? Impossible, AFAIK <_<

Remember this isn't making a GUI - it's drawing on a picture. Think of it this way - if you can do it in Paint or Photoshop and export it as a .jpg, you can do it with this dll. So I could draw left and right arrows, but try clicking on them, and you'll realize that it's not a control, it's just a picture. To do what you're talking about, think about using Active Desktop and an HTML file as your wallpaper - set the background to your picture, then use javascript to write your calendar as text into a div, and create links (or buttons) that have onclick calls to functions that will recreate the calendar to represent adjacent months. WAY different than what I'm doing here. :)

Glad you liked it though!

Edit: the closest thing you could do with this script to what you want is have it prompt you for a month offset when it runs (0 is current month, -1 is last month, 1 is next month, etc), then wherever @month is called in the script, _DateAdd() that value to it (simple addition would break over a year change like December to January). That way, the calendar it draws on your wallpaper would be the month you asked for, rather than the current one. To reset it, run the script again and give it the old month offset again (0).

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

where is "ImageMagickObject.dll.au3"


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Look at the first post.."...so download the zip archive linked to on this page, "

Edited by DjDeep00

Share this post


Link to post
Share on other sites

Look at the first post.."...so download the zip archive linked to on this page, "

Nope, not there

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Nope, not there

Looks like there's a data transfer limit I'm hitting on that site <_< I don't have any other online storage, and it doesn't come close to fitting in the 492k I've got left on this site (I still can't get RegExpReplace to do what I want to, in order to reduce the size), so I guess just try again later (maybe their counter resets every hour or so...?). Sorry.

---

Edit: If you have Image Magick installed, having checked the option to register the ImageMagickObject for COM use (or if you've registered the COM dll yourself), you can just remove the #include <imagemagickobject.dll.au3> line at the top of this script and it should work. There's a link to the download you need in the second line of the crossed-out part of my first post.

Sorry for the inconvenience...

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

I had no trouble getting it

ImageMagickObject.dll.zip

@James3mg

If people still have a problem then I can upload your latest version. I have no limits.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

You can now download the .zip file containing ImageMagickObject.dll.au3 here with no problems, thanks to GEOSoft hosting it for me. Just make sure the resulting file has a .zip at the end...mine didn't when I tested the link. <_<

Thanks GEOSoft...you're the best! :):P:)

Now...back to the discussions at hand...

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0