AutoHotKey를 사용하는 사람들
오늘: 490
어제: 624
전체: 200,906
회원: 1,883
접속: 21 (회원 1)

AutoHotKey 스크립트 공유

 

AutoHotkey로 제작한 스크립트를 서로 공유하기 위한 공간 입니다. 자유롭게 이용하세요~

 
작성일 : 10-03-08 09:09
AHK cam
 글쓴이 : ImMBRLv.62
조회 : 706   추천 : 0   비추천 : 0  
   AHKcam_v2.exe (203.2K) [34] DATE : 2010-03-08 09:09:22

스크립트에 대한 설명:

얼마전에 올렸던 AHK cam의 소스입니다.

첨부되어 있는 실행파일은 나름대로 손을 본 2nd Ver.입니다.
그런데 고친 친구가 더 형편없는 것 같습니다;;;

그래서 소스는 AHK cam 1st Ver.을 올립니다.
필요하신 분들께서 고쳐서 쓰시는 것이 훨씬 효율적일 것 같군요.
또, 이런 것이 AHK의 매력 아닐까요^^;;;

<--------------------------------------------- AHK 스크립트 내용 --------------------------------------------->

#NoTrayIcon
CoordMode,ToolTip,Relative
fmt=jpg
fol:=folder(A_ScriptDir)
Menu,Submenu,Add,JPG,JPGrt
Menu,Submenu,Add,BMP,BMPrt
Menu,MyMenu,Add,Format,:Submenu
Menu,Submenu2,Add,%fol%,folder
Menu,MyMenu,Add,Folder,:Submenu2
Menu,MyMenu,Add
Menu,Submenu4,Add,AHK-Cam by ImMBR,blank
Menu,MyMenu,Add,About,:Submenu4
Menu,Submenu,Check,JPG
Gui +LastFound +AlwaysOnTop +Resize +MinSize30x30
Gui,Color,EEAA99
Gui,Add,Text,vTxt cLime w100 h100,
WinSet,TransColor,EEAA99 255
Gui,Show,autosize,Cam
WinGet,vid,id
ToolTip,R-Click TitleBar,50,-20
SetTimer,tt,-5000
return

blank:
return

tt:
ToolTip
return

GuiClose:
ExitApp

$Mbutton::
MouseGetPos,,,Var
if Var<>%vid%
{
send,{Rbutton}
return
}
VarSetCapacity(rect,16,0)
DllCall("GetClientRect",uint,vid,uint,&rect)
W:=NumGet(rect,8,"int")
H:=NumGet(rect,12,"int")
ClientToWin(vid,x:=0,y:=0)
x1:=x+W
y1:=y+H
pos=%x%,%y%,%x1%,%y1%
if fmt=jpg
{
name=%fol%%A_Now%.jpg
CaptureScreen(pos,0,name,"100")
}
if fmt=bmp
{
name=%fol%%A_Now%.bmp
CaptureScreen(pos,0,name)
}
ToolTip,Capture!!!,50,-20
sleep,300
Tooltip
return

$Rbutton::
MouseGetPos,,,Var
if Var<>%vid%
{
send,{Rbutton}
return
}
ToolTip
Menu, MyMenu, Show
return

JPGrt:
Menu,Submenu,UnCheck,BMP
Menu,Submenu,Check,JPG
fmt=jpg
return

BMPrt:
Menu,Submenu,UnCheck,JPG
Menu,Submenu,Check,BMP
fmt=bmp
return

folder:
FileSelectFolder,folnew,,1,Select Folder
if Errorlevel
{
return
}
folnew:=folder(folnew)
Menu,Submenu2,Rename,%fol%,%folnew%
fol=%folnew%
return

folder(fol)
{
StringRight,chk,fol,1
If chk<>\
{
fol=%fol%\
}
return fol
}
return

ClientToWin(hwnd, ByRef x, ByRef y)
{
VarSetCapacity(pt, 8)
NumPut(x, pt, 0)
NumPut(y, pt, 4)
DllCall("ClientToScreen", "uint", hwnd, "uint", &pt)
x := NumGet(pt, 0, "int")
y := NumGet(pt, 4, "int")
}

CaptureScreen(aRect = 0, bCursor = False, sFile = "", nQuality = "")
{
 If !aRect
 {
  SysGet, nL, 76
  SysGet, nT, 77
  SysGet, nW, 78
  SysGet, nH, 79
 }
 Else If aRect = 1
  WinGetPos, nL, nT, nW, nH, A
 Else If aRect = 2
 {
  WinGet, hWnd, ID, A
  VarSetCapacity(rt, 16, 0)
  DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt)
  DllCall("ClientToScreen", "Uint", hWnd, "Uint", &rt)
  nL := NumGet(rt, 0, "int")
  nT := NumGet(rt, 4, "int")
  nW := NumGet(rt, 8)
  nH := NumGet(rt,12)
 }
 Else If aRect = 3
 {
  VarSetCapacity(mi, 40, 0)
  DllCall("GetCursorPos", "int64P", pt)
  DllCall("GetMonitorInfo", "Uint", DllCall("MonitorFromPoint", "int64", pt, "Uint", 2), "Uint", NumPut(40,mi)-4)
  nL := NumGet(mi, 4, "int")
  nT := NumGet(mi, 8, "int")
  nW := NumGet(mi,12, "int") - nL
  nH := NumGet(mi,16, "int") - nT
 }
 Else
 {
  StringSplit, rt, aRect, `,, %A_Space%%A_Tab%
  nL := rt1
  nT := rt2
  nW := rt3 - rt1
  nH := rt4 - rt2
  znW := rt5
  znH := rt6
 }

 mDC := DllCall("CreateCompatibleDC", "Uint", 0)
 hBM := CreateDIBSection(mDC, nW, nH)
 oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
 hDC := DllCall("GetDC", "Uint", 0)
 DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
 DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
 If bCursor
  CaptureCursor(mDC, nL, nT)
 DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
 DllCall("DeleteDC", "Uint", mDC)
 If znW && znH
  hBM := Zoomer(hBM, nW, nH, znW, znH)
 If sFile = 0
  SetClipboardData(hBM)
 Else Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "Uint", hBM)
}

 

CaptureCursor(hDC, nL, nT)
{
 VarSetCapacity(mi, 20, 0)
 mi := Chr(20)
 DllCall("GetCursorInfo", "Uint", &mi)
 bShow   := NumGet(mi, 4)
 hCursor := NumGet(mi, 8)
 xCursor := NumGet(mi,12)
 yCursor := NumGet(mi,16)

 VarSetCapacity(ni, 20, 0)
 DllCall("GetIconInfo", "Uint", hCursor, "Uint", &ni)
 xHotspot := NumGet(ni, 4)
 yHotspot := NumGet(ni, 8)
 hBMMask  := NumGet(ni,12)
 hBMColor := NumGet(ni,16)

 If bShow
  DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "Uint", hCursor)
 If hBMMask
  DllCall("DeleteObject", "Uint", hBMMask)
 If hBMColor
  DllCall("DeleteObject", "Uint", hBMColor)
}

Zoomer(hBM, nW, nH, znW, znH)
{
 mDC1 := DllCall("CreateCompatibleDC", "Uint", 0)
 mDC2 := DllCall("CreateCompatibleDC", "Uint", 0)
 zhBM := CreateDIBSection(mDC2, znW, znH)
 oBM1 := DllCall("SelectObject", "Uint", mDC1, "Uint",  hBM)
 oBM2 := DllCall("SelectObject", "Uint", mDC2, "Uint", zhBM)
 DllCall("SetStretchBltMode", "Uint", mDC2, "int", 4)
 DllCall("StretchBlt", "Uint", mDC2, "int", 0, "int", 0, "int", znW, "int", znH, "Uint", mDC1, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020)
 DllCall("SelectObject", "Uint", mDC1, "Uint", oBM1)
 DllCall("SelectObject", "Uint", mDC2, "Uint", oBM2)
 DllCall("DeleteDC", "Uint", mDC1)
 DllCall("DeleteDC", "Uint", mDC2)
 DllCall("DeleteObject", "Uint", hBM)
 Return zhBM
}

Convert(sFileFr = "", sFileTo = "", nQuality = "")
{
 If sFileTo  =
  sFileTo := A_ScriptDir . "\screen.bmp"
 SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo

 If Not hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll")
  Return sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : ""
 VarSetCapacity(si, 16, 0), si := Chr(1)
 DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)

 If !sFileFr
 {
  DllCall("OpenClipboard", "Uint", 0)
  If  DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2))
  DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage)
  DllCall("CloseClipboard")
 }
 Else If sFileFr Is Integer
  DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage)
 Else DllCall("gdiplus\GdipLoadImageFromFile", "Uint", Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage)

 DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
 VarSetCapacity(ci,nSize,0)
 DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci)
 Loop, % nCount
  If InStr(Ansi4Unicode(NumGet(ci,76*(A_Index-1)+44)), "." . sExtTo)
  {
   pCodec := &ci+76*(A_Index-1)
   Break
  }
 If InStr(".JPG.JPEG.JPE.JFIF", "." . sExtTo) && nQuality<>"" && pImage && pCodec
 {
 DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize)
 VarSetCapacity(pi,nSize,0)
 DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", &pi)
 Loop, % NumGet(pi)
  If NumGet(pi,28*(A_Index-1)+20)=1 && NumGet(pi,28*(A_Index-1)+24)=6
  {
   pParam := &pi+28*(A_Index-1)
   NumPut(nQuality,NumGet(NumPut(4,NumPut(1,pParam+0)+20)))
   Break
  }
 }

 If pImage
  pCodec ? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", pParam) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)

 DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
 DllCall("FreeLibrary", "Uint", hGdiPlus)
}

CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
{
 NumPut(VarSetCapacity(bi, 40, 0), bi)
 NumPut(nW, bi, 4)
 NumPut(nH, bi, 8)
 NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
 NumPut(0,  bi,16)
 Return DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
}

SaveHBITMAPToFile(hBitmap, sFile)
{
 DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
 hFile:= DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0)
 DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0)
 DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0)
 DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0)
 DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0)
 DllCall("CloseHandle", "Uint", hFile)
}

SetClipboardData(hBitmap)
{
 DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
 hDIB := DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44))
 pDIB := DllCall("GlobalLock", "Uint", hDIB)
 DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40)
 DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44))
 DllCall("GlobalUnlock", "Uint", hDIB)
 DllCall("DeleteObject", "Uint", hBitmap)
 DllCall("OpenClipboard", "Uint", 0)
 DllCall("EmptyClipboard")
 DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB)
 DllCall("CloseClipboard")
}

Unicode4Ansi(ByRef wString, sString)
{
 nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
 VarSetCapacity(wString, nSize * 2)
 DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize)
 Return &wString
}

Ansi4Unicode(pString)
{
 nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int",  0, "Uint", 0, "Uint", 0)
 VarSetCapacity(sString, nSize)
 DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0)
 Return sString
}

비추천 : 0
추천 : 0
MBR is not Master Boot Record.

       오키Lv.13 / 2010-03-08 09:26

사실은... 처음에 게시물 올리시고 지우시기 전에 살짝 소스를 봤었답니다. ^^
수정하시느라 고생하셨어요.

       베르바Lv.13 / 2010-03-08 10:54

저번에 테스트 한다고 다운받아서 써봤는데,
편하고 잘찍히고 좋더라구요 ㅎㅎ

고생하셨어요^^

       eocndLv.13 / 2010-03-08 12:04

수고 많으셧습니다..
유용할꺼같네요..
감사합니다~~~~~~ 흐.. 앞으로도 잦은 활동부탁드릴게요.............
~하하

       NewJungLv.12 / 2010-03-08 15:17

ImMBR님은 만약 AHK 올림픽이 있다면
무조건 한국 국가대표로 참가하셨을 듯 하네요.^^

고생 많이 하셨습니다.^^


 
 

 
Total 144
번호 제   목 글쓴이 날짜 조회 추천 비추천
[영문포럼] SciTE4 AutoHotKey v2 - AHK 스크립팅 편집기 (11) 관리자Lv.100 03-18 2303 0 0
144 문자열>16진수>문자열 (3) 만약에Lv.6 08-25 232 1 0
143 창 이동 스크립트2 (3) AHsK현수Lv.10 08-06 454 0 0
142    창 이동 스크립트2 (5) 샤이닝Lv.2 08-06 289 0 1
141 휠로 마우스 속도 조절하기 (2) 운장Lv.17 08-21 189 1 0
140 한글 자소별로 분리 또는 합치기 (4) 운장Lv.17 08-17 231 3 0
139 네이버로그인 및 카페등급 인증소스 (1) RextenLv.1 08-17 320 0 0
138 마우스, 키보드 레코더 (8) eocndLv.13 08-16 460 0 0
137 컨트롤(ClassNN)내의 좌표구하기 (4) DRAGONLv.14 08-11 321 1 0
136 분 단위로 윈도우 자동종료 (1) 제트나비Lv.4 08-10 255 1 0
135 원하는 Window를 투명화시키자!? (3) AHsK현수Lv.10 08-10 363 1 0
134 save images from clipboard (2) ImMBRLv.62 08-08 290 1 0
133 퍼온글: 마우스 오작동 방지 ~ (1) 만약에Lv.6 08-07 377 0 0
132 exe 파일을 ahk 파일로 변환 (디컴파일러) (9) 만약에Lv.6 08-02 766 3 0
131 스크립트 작성을 쉽게~ 템플릿(파라미터 추가) 만약에Lv.6 08-02 447 0 0
130 마우스 제스처에 옷입혔어요 :) (13) 만약에Lv.6 07-29 511 1 0
 
 
 1  2  3  4  5  6  7  8  9  10  

 

Copyright Tleap. All rights reserved.