2016. 2. 26.

Print Screen(캡쳐) 누르면 bmp자동저장 & 그림판 실행

스크립트에 대한 설명:


개인적으로 요긴하게 사용하고 있어서 함 올려봅니다.
키보드상의 Print Screen (화면캡쳐) 키 실행시 바탕화면에 '해당시각.bmp' 파일로 이미지를 저장하고,
그림판으로 해당 파일을 open 해주는 스크립트 입니다.


출처 : www.autohotkey.com/forum/viewtopic.php?t=35242







; By SKAN    www.autohotkey.com/forum/viewtopic.php?t=35242
ClipboardGet_DIB()
{
 If DllCall("IsClipboardFormatAvailable", UInt,2 )
   DllCall( "OpenClipboard", UInt,0 ), tBM := DllCall("GetClipboardData", UInt,2 )
 , hBM := DllCall( "CopyImage", UInt,tBM, UInt,0, Int,0,Int,0, UInt,0x2000, UInt )
 , DllCall( "CloseClipboard" )

 Return hBM ? hBM : 0
}


; By SKAN    www.autohotkey.com/forum/viewtopic.php?t=35242
GDI_SaveBitmap( hBM, File )

 DllCall( "GetObject", Int,hBM, Int,VarSetCapacity($,84), UInt,NumPut(0,$,40,"Short")-42 )
 Numput( VarSetCapacity(BFH,14,0)+40, Numput((NumGet($,44)+54),Numput(0x4D42,BFH)-2)+4 )
 If ( hF := DllCall( "CreateFile", Str,File,UInt,2**30,UInt,2,Int,0,UInt,2,Int64,0 ) ) > 0
   DllCall( "WriteFile", UInt,hF, UInt,&BFH,  UInt,14, IntP,0,Int,0 ) ; BITMAPFILEHEADER
 , DllCall( "WriteFile", UInt,hF, UInt,&$+24, UInt,40, IntP,0,Int,0 ) ; BITMAPINFOHEADER
 , DllCall( "WriteFile", UInt,hF, UInt,NumGet($,20), UInt,NumGet($,44), UIntP,BW, Int,0 )
 , DllCall( "CloseHandle", UInt,hF )

 Return BW ? 54+BW : 0
}







~!PrintScreen::
 ~PrintScreen::
sleep, 50
current_time := substr(a_now, 1, 4) . " " . substr(a_now, 5, 2) . " " . substr(a_now, 7, 2) . " " . substr(a_now, 9, 6)
file_name1 :=  A_Desktop . "\" . current_time . ".bmp"

 If GDI_SaveBitmap( ClipboardGet_DIB(), OUTF := file_name1 ){
  Runwait, mspaint.exe "%file_name1%", file_name1
  }
return