Hello,
i have a lot of complicated scripts and some of them are crashing from time to time, i want to create an function, that will take a SNAPSHOT of the entire SCREEN , save it in c:\photos\macros as {script_name}_{date}.bmp , then will send a smaller version jpg (600x480 or even smaller) to my email [email protected]
I want this to be done entirely with macro sheduller 11 (without any other software), is this possible?
resize screen image
Moderators: JRL, Dorian (MJT support)
yes i have tried that, but with no sucess - i want this resized picture to be saved on disc, but it doesnt work with those handles,
wish that would work
Can you help me please ?
Code: Select all
ScreenCapture>0,0,1024,768,%DESKTOP_DIR%\screen.bmp
LibFunc>Gdi32,StretchBlt,SBres,%DESKTOP_DIR%\screen2.jpg,0,0,640,480,%DESKTOP_DIR%\screen.bmp,0,0,1024,768,13369376

Can you help me please ?
Here's a script that takes a screen shot then reduces the screen shot image and writes the screen shot and the reduced images to files that can then be attached to a mail message. Note that the directory structure C:\Photos\Macros\ must exist for the files to be created. This uses screen captures so there's a bit of screen activity. Its possible there is a way to reduce one image file directly to another image file but I don't know how to do that. Maybe someone else knows how?
This version writes BMP files, All you need to do to write JPG files is change the extension in the file name. (More Macro Scheduler magic)
Read the comments, ask questions if anything is unclear. Hope this is more helpful.
This version writes BMP files, All you need to do to write JPG files is change the extension in the file name. (More Macro Scheduler magic)
Read the comments, ask questions if anything is unclear. Hope this is more helpful.
Code: Select all
//Set the X and Y size for the email image
Let>ResizeX=640
Let>ResizeY=480
//Acquire the name of the running macro or executable
//If run form the Macro Scheduler menu this will be msched
//In which case the desired name may need to be hard coded
Separate>%command_line%,\,name
Let>filename=name_%name_count%
Separate>filename,.,vFilename
//Get date and time info for filename datestamp
Sec>ss
Min>mn
Hour>hh
Day>dd
Month>mm
Year>yy
//Need the screen resolution
GetScreenRes>ScrX,ScrY
//Set names of files
Let>ReSizeFilename=C:\Photos\Macros\%vFilename_1%_%yy%%mm%%dd%%hh%%mn%%ss%_%ResizeX%_%ResizeY%.bmp
Let>Filename=C:\Photos\Macros\%vFilename_1%_%yy%%mm%%dd%%hh%%mn%%ss%_%scrX%_%scrY%.bmp
//Capture the screen and save to %Filename%
ScreenCapture>0,0,ScrX,ScrY,%Filename%
//Set both Device Context Handles to the screen. (saves having to deal with dialogs)
LibFunc>user32,GetDC,HDC1,0
LibFunc>user32,GetDC,HDC3,0
//Use the StretchBlt API function to reduce and display the screen image
LibFunc>Gdi32,StretchBlt,SBres,HDC3,0,0,ResizeX,ResizeY,HDC1,0,0,scrX,scrY,13369376
//Capture and save the reduced image
ScreenCapture>0,0,ResizeX,ResizeY,%ReSizeFilename%
//Clean up the clutter from the screen
//This could be eliminated by creating a dialog and displaying the reduced image on the dialog
SetFocus>Program Manager
Press F5
Press LWinKey
Send>d
Release LWinKey
Wait>0.5
Press LWinKey
Send>d
Release LWinKey
//Add code for emailing the reduced size image
I thought of a cleaner way to clean up the screen. Here's the improved script.
Code: Select all
//Set the X and Y size for the email image
Let>ResizeX=640
Let>ResizeY=480
//Acquire the name of the running macro or executable
//If run form the Macro Scheduler menu this will be msched
//In which case the desired name may need to be hard coded
Separate>%command_line%,\,name
Let>filename=name_%name_count%
Separate>filename,.,vFilename
//Get date and time info for filename datestamp
Sec>ss
Min>mn
Hour>hh
Day>dd
Month>mm
Year>yy
//Need the screen resolution
GetScreenRes>ScrX,ScrY
//Set names of files
Let>ReSizeFilename=C:\Photos\Macros\%vFilename_1%_%yy%%mm%%dd%%hh%%mn%%ss%_%ResizeX%_%ResizeY%.jpg
Let>Filename=C:\Photos\Macros\%vFilename_1%_%yy%%mm%%dd%%hh%%mn%%ss%_%scrX%_%scrY%.jpg
//Capture the screen and save to %Filename%
ScreenCapture>0,0,ScrX,ScrY,%Filename%
//Set both Device Context Handles to the screen. (saves having to deal with dialogs)
LibFunc>user32,GetDC,HDC1,0
LibFunc>user32,GetDC,HDC3,0
//Use the StretchBlt API function to reduce and display the screen image
LibFunc>Gdi32,StretchBlt,SBres,HDC3,0,0,ResizeX,ResizeY,HDC1,0,0,scrX,scrY,13369376
//Capture and save the reduced image
ScreenCapture>0,0,ResizeX,ResizeY,%ReSizeFilename%
//Clean up the clutter from the screen
Dialog>ScreenEraser
Width=%scrX%
Height=%scrY%
EndDialog>ScreenEraser
Show>ScreenEraser
CloseDialog>ScreenEraser
//Add code for emailing the reduced size image
Nice example JR.
To resize the image to 50% e.g. replace the the first 3 lines of JR's last script
With this one...
To resize the image to 50% e.g. replace the the first 3 lines of JR's last script
Code: Select all
//Set the X and Y size for the email image
Let>ResizeX=640
Let>ResizeY=480
Code: Select all
//Set the X and Y size for the email image
///Get Screen Resolution
GetScreenRes>X,Y
// Set percentage to resize image to. (0.50=50%)
let>PERCENT=0.50
//Calculate percentage of screen resolution
Let>ResizeX=%X%*%PERCENT%
Let>ResizeY=%Y%*%PERCENT%
//Round result
Let>ResizeX={round(%ResizeX%)}
Let>ResizeY={round(%ResizeY%)}