AutoHotkey: Make a Screenshot of the current Window with Irfanview

From TotalcmdWiki
Jump to navigation Jump to search

This script is for those who already use Irfanview and occasional need a screenshot to post it in the Web. The Creation itself is not very quick if you use the PNG format (as I do in the script) for it takes several passes but neverthless you can do a lot shots in a short time.

This script uses Ctrl+Printscreen following the Alt+Printscreen Hotkey of Windows


;This script creates a screenshot of the current window and saves it as shot%Current_Date_and_Time%.PNG in the folder c:\screenshot
;If this folder does not exist already it will be created by the script
;The hotkey is Ctrl + PrintScreen (ususally next key on the right to F12)
;The path has, of course, to be adjusted.


 ~^PrintScreen::
; if there is not already a folder c:\screenshot create one
ifnotexist,C:\screenshot
fileCreateDir, C:\screenshot 
; Call the function Adjust(zeit)
 adjust(zeit)
; run Irfanview with commandline /capture=1 what takes a screenshot of the active window
; (0 would take the whole desktop and 2 only the client area of the active window)
; "/convert="   will save the captured image to the specified filename (and format) 
;  - in this case shot%timestamp%.PNG
; you may adjust the format as well as the path, but I recommend to keep at least the timestamp
run, "%A_ProgramFiles%\IrfanView\i_view32.exe" "/capture=1 /convert=c:\Screenshot\Shot%Zeit%.PNG", msgbox, Ctrl Printscreen
return


;take the current system time and convert it to the format 31.12.06_13-22-45 
; i.e day.month.year_Hour-minute-second and return it in the variable "zeit"
 
adjust(ByRef zeit)
{
formattime,zeit,A_now,dd.MM.yy_HH-mm-ss
return
}

The following script does the same but uses IrfanView's own filename functions:

^PrintScreen::
; if there is not already a folder c:\screenshot create one
ifnotexist, C:\screenshot
fileCreateDir, C:\screenshot 
; /capture=0 takes a screenshot of the whole desktop
; /capture=1 takes a screenshot of the active window
; /capture=2 takes a screenshot of the client area of the active window
Run, "%A_ProgramFiles%\IrfanView\IrfanView\i_view32.exe" /capture=1 /convert=C:\screenshot\capture_$U(`%Y-`%m-`%d_`%H`%M`%S).png
return

Back to AutoHotkey