Jump to content
Macro Express Forums

Image capture and MD5 checksum calculation with external programs

Recommended Posts

I created these scripts partly in response to feature requests from Strahan et al. who asked for an “image capture and compare” solution.


These scripts will capture images and generate MD5 checksums, which you can then use for comparison.


There are already excellent programs for capturing screen images and calculating MD5 checksums, so I don’t want to reinvent the wheel.


For these scripts, I am using IrfanView and md5.exe. Both are free and fast programs. I wanted to create an MEP-only solution, but my initial efforts showed that MEP is too slow for this purpose.


On my 3-year-old notebook, these scripts (using external programs) take 1.1 sec to execute, which I think would not bother most users. An MEP-only solution would probably be 5 to 10 times slower.


These scripts can serve as building blocks for screen logging, image comparison, or image matching scripts. Please modify to suit to your purposes. A full installation guide and how-to follows in the next post.


I am actually working on an image search solution for MEP, which is a tougher problem. I’ll probably make use of IrfanView again.

Link to comment
Share on other sites


Please do not skip any of these steps.


1. Download and install IrfanView from www.irfanview.com. Take note of the installation folder, which is usually C:\Program Files\IrfanView\


2. Download md5.zip from www.fourmilab.ch/md5/


3. Extract md5.exe from the zip file. There is no installer; just copy md5.exe into C:\Program Files\


4. Download the scripts below (attached) and import the scripts into Macro Express Pro. If IrfanView and md5.exe are not in their default folder locations, pls modify the scripts accordingly.


5. Press Ctrl-Alt-9 to capture a segment of the active window, or Ctrl-Alt-0 to capture the full active window.


6. The script will report the MD5 checksum for the captured segment or active window, and the location for the saved file.

Image capture and MD5 checksum calc.mex

Link to comment
Share on other sites



The two external programs are doing all the heavy lifting; these scripts merely launch them.


The first part of the script launches IrfanView with the following parameters:


/capture=2 /crop=(%Xposi%,%Yposi%,180,150) /convert=%ScreenCaptFile%


On a command line (command prompt), this would be equivalent to:


irfanview.exe /capture=2 /crop=(4,21,180,150) /convert=CapturedSegment.jpg


/capture=2 means capture the foreground window

/crop=(4,21,180,150) means crop a 180x150 segment starting at 4,21

/jpgq=81 sets Jpg quality at 81

/convert=CapturedSegment.jpg means convert the captured image to Jpg


The “Capture Active Win” script is almost the same as the "Capture 180x150" except it leaves out the crop parameter (no cropping), so it is basically:


irfanview.exe /capture=2 /convert=CapturedWindow.jpg


Both versions of the script then launch md5.exe:


md5.exe CapturedSegment.jpg


which will calculate and spit out the MD5 checksum for the file. An MD5 checksum serves as a “fingerprint” to uniquely identify a file’s contents. If you know the MD5 checksum for two files, you can get a definitive answer to the question: Are these two files different?


Other stuff to note


The scripts will save captured images to the folder listed in the %USERPROFILE% Environment Variable. On Windows Vista/7 this usually means C:\Users\{your username}, while on Windows XP/2000, it is usually C:\Documents and Settings\{ your username}.


The captured images are in Jpg format. You can view them using any image viewer, including IrfanView.


The scripts have built-in benchmarking; they will report their Start and End times.


A full list of IrfanView command-line options can be obtained from the IrfanView help file, which is installed along with the program.


More info about MD5 at: Wikipedia.org/wiki/MD5

More info about checksums at: Wikipedia.org/wiki/Checksum

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...