Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; http://msgbox.vk.com
- Pass := ""
- Login := ""
- Link_To_Album := "http://vkontakte.ru/album37047698_135055718"
- #SingleInstance Force
- #Persistent
- SName := "VKScreenshot v0.1"
- SetBatchLines -1
- Menu, Tray, NoStandard
- Menu, Tray, Add, Exit, OnExit
- return
- Lbutton::
- Gui, Color, 000000
- Gui, Font, s10 Bold, Tahoma
- Gui, +AlwaysOnTop -caption +Border +ToolWindow +LastFound +DLGFRAME
- Gui, Add, Text, x10 y10 w80 h80 BackgroundTrans cwhite, Width:
- Gui, Add, Text, x10 y28 w80 h80 BackgroundTrans cwhite, Height:
- Gui, Add, Text, x60 y10 w80 h80 BackgroundTrans vCX cwhite,
- Gui, Add, Text, x60 y28 w80 h80 BackgroundTrans vCY cwhite,
- WinSet, Transparent, 125
- CoordMode, Mouse ,Screen
- MouseGetPos, MX, MY
- While, (GetKeyState("LButton", "p")) {
- MouseGetPos, MXend, MYend
- h := Abs(MY - MYend)
- w := Abs(MX - MXend)
- If (MXend!=LCX && MYend!=LCY) {
- GuiControl,, CX, %w%
- GuiControl,, CY, %h%
- LCX := MXend
- LCY := MYend
- }
- If (MX < MXend)
- X := MX
- Else
- X := MXend
- If (MY < MYend)
- Y := MY
- Else
- Y := MYend
- Gui, Show, x%X% y%Y% w%w% h%h%
- if (GetKeyState("p", "p"))
- {
- Gui, Destroy
- ; Send, {LButton up}
- Return
- }
- sleep, 5
- }
- MouseGetPos, MXend, MYend
- Gui, Destroy
- If (MX > MXend)
- {
- temp := MX
- MX := MXend
- MXend := temp
- }
- If (MY > MYend)
- {
- temp := MY
- MY := MYend
- MYend := temp
- }
- CaptureScreen("" MX ", " MY ", " MXend ", " MYend "")
- Image := a_scriptdir "\ScreenShot.jpg"
- httpQueryOps:="storeHeader"
- httpAgent :="Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.8.131 Version/11.10"
- httpQueryDwFlags:=(INTERNET_FLAG_NO_COOKIES:=0x00080000|INTERNET_FLAG_NO_AUTO_REDIRECT:=0x00200000)
- URL:="http://login.vk.com/?act=login&email=" Login "&pass=" Pass ""
- length:=httpQuery(data:="",URL)
- varSetCapacity(data,-1)
- RegExMatch(HttpQueryHeader,"hash=(.*?)&",hash)
- URL:="http://vk.com/login.php?act=slogin&fast=1&hash=" hash1 "&redirect=1&s=1"
- httpQuery(data:="",URL)
- varSetCapacity(data,-1)
- if HttpQueryHeader contains deleted
- {
- MsgBox, 64, % SName, Auth failed!
- ExitApp
- }else{
- SID := RegexReplace(HttpQueryHeader, ".*remixsid=(.*?); .*", "$1")
- Cookie:= "Cookie: remixsid=" SID ";"
- httpQueryDwFlags:=(INTERNET_FLAG_NO_COOKIES:=0x00080000)
- }
- FileGetSize,size,%image%
- SplitPath,image,OFN
- FileRead,img,%image%
- VarSetCapacity(placeholder,size,32)
- Link := Link_To_Album "?act=add"
- httpQuery(data:="", Link_To_Album, POSTdata, HEADERS:=Cookie)
- VarsetCapacity(data, -1)
- Temp := RegexReplace(data, ".*event[)]""></a>(.*?)<span class=""divide.*", "$1")
- StringSplit, Temp, Temp, %a_space%
- AlbumOffset := Temp1
- Vars := "id,aid,gid,mid,hash,rhash"
- httpQuery(data:="", Link, POSTdata, HEADERS:=Cookie)
- VarsetCapacity(data, -1)
- Loop, parse, Vars, `,
- if (a_loopfield!="hash" && a_loopfield!="rhash" && a_loopfield!="url")
- %a_loopfield% := regexreplace(data, ".*""" a_loopfield """:(.*?),.*", "$1")
- else
- %a_loopfield% := regexreplace(data, ".*""" a_loopfield """:""(.*?)"".*", "$1")
- URL := "http://cs"(regexreplace(data, ".*url: 'http://cs(.*?)',.*", "$1"))""
- boundary := "----------" . makeProperBoundary()
- POSTdata:="--" boundary "`n"
- . "Content-disposition: form-data; name=""act""`n`ndo_add`n--" boundary "`n"
- . "Content-disposition: form-data; name=""id""`n`n" id "`n--" boundary "`n"
- . "Content-disposition: form-data; name=""aid""`n`n" aid "`n--" boundary "`n"
- . "Content-disposition: form-data; name=""gid""`n`n" gid "`n--" boundary "`n"
- . "Content-disposition: form-data; name=""mid""`n`n" mid "`n--" boundary "`n"
- . "Content-disposition: form-data; name=""hash""`n`n" hash "`n--" boundary "`n"
- . "Content-disposition: form-data; name=""vk""`n`n`n--" boundary "`n"
- . "Content-disposition: form-data; name=""rhash""`n`n" rhash "`n--" boundary "`n"
- . "Content-disposition: form-data; name=""file1""; filename=""" ofn """`n"
- . "Content-type: " MimeType(img) "`n`n" placeholder "`n--" boundary "--"
- HEADERS:="Content-type: multipart/form-data, "
- . "boundary=" boundary "`nContent-Length: " strlen(POSTdata) "`n" cookie
- DllCall("RtlMoveMemory","uInt"
- ,(offset:=&POSTdata+strlen(POSTdata)-strlen(Boundary)-size-5)
- ,"uInt",&img,"uInt",size)
- httpQuery(data:="",URL,POSTdata,HEADERS)
- varSetCapacity(data, -1)
- if data not contains Security
- TrayTip, %SName%, Okay!,1,1,1
- else
- {
- TrayTip, %SName%, Fuck! There's an error!,1,1,1
- ExitApp
- }
- FileDelete, ScreenShot.jpg
- Esc::
- OnExit:
- ExitApp
- MD5( ByRef V, L=0 ) {
- VarSetCapacity( MD5_CTX,104,0 ), DllCall( "advapi32\MD5Init", Str,MD5_CTX )
- DllCall( "advapi32\MD5Update", Str,MD5_CTX, Str,V, UInt,L ? L : VarSetCapacity(V) )
- DllCall( "advapi32\MD5Final", Str,MD5_CTX )
- Loop % StrLen( Hex:="123456789ABCDEF0" )
- N := NumGet( MD5_CTX,87+A_Index,"Char"), MD5 .= SubStr(Hex,N>>4,1) . SubStr(Hex,N&15,1)
- Return MD5
- }
- makeProperBoundary(){
- Loop,26
- n .= chr(64+a_index)
- n .= "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
- Loop,% StrLen(A_Now) {
- Random,rnd,1,% StrLen(n)
- Random,UL,0,1
- b .= RegExReplace(SubStr(n,rnd,1),".$","$" (round(UL)? "U":"L") "0")
- }
- Return b
- }
- UtfDecode( str ) {
- RawLen := StrLen(str)
- Charset := 0
- BufSize := (RawLen + 1) * 2
- VarSetCapacity(Buf, BufSize, 0)
- DllCall("MultiByteToWideChar", "uint", 65001, "int", 0, "str", str
- , "int", -1, "uint", &Buf, "uint", RawLen + 1)
- DllCall("WideCharToMultiByte", "uint", Charset, "int", 0, "uint", &Buf, "int", -1
- , "str", str, "uint", RawLen + 1
- , "int", 0, "int", 0)
- Return str
- }
- MimeType(ByRef Binary) {
- MimeTypes:="424d image/bmp|4749463 image/gif|ffd8ffe image/jpg|89504e4 image/png|4657530"
- . " application/x-shockwave-flash|49492a0 image/tiff"
- @:="0123456789abcdef"
- Loop,8
- hex .= substr(@,(*(a:=&Binary-1+a_index)>>4)+1,1) substr(@,((*a)&15)+1,1)
- Loop,Parse,MimeTypes,|
- if ((substr(hex,1,strlen(n:=RegExReplace(A_Loopfield,"\s.*"))))=n)
- Mime := RegExReplace(A_LoopField,".*?\s")
- Return (Mime!="") ? Mime : "application/octet-stream"
- }
- URLEncode( p_data,p_reserved=true,p_encode=true) {
- old_FormatInteger := A_FormatInteger
- SetFormat, Integer, hex
- unsafe := "25000102030405060708090A0B0C0D0E"
- . "0F101112131415161718191A1B1C1D1E1F20222"
- . "33C3E5B5C5D5E607B7C7D7F808182838485868"
- . "788898A8B8C8D8E8F909192939495969798999A"
- . "9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABAC"
- . "ADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDB"
- . "EBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCEC"
- . "FD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF7"
- . "EE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0"
- . "F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"
- if (p_reserved)
- unsafe = %unsafe%24262B2C2F3A3B3D3F40
- if ( p_encode )
- loop, % StrLen(unsafe)//2
- {
- StringMid, token, unsafe, A_Index*2-1, 2
- StringReplace, p_data, p_data, % Chr( "0x" token ), `%%token%, all
- }else
- loop, % StrLen(unsafe)//2
- {
- StringMid, token, unsafe, A_Index*2-1, 2
- StringReplace, p_data, p_data, `%%token%, % Chr("0x"token), all
- }
- SetFormat, Integer, %old_FormatInteger%
- return, p_data
- }
- URLDecode( p_data ) {
- return, URLEncode( p_data, true, false )
- }
- httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="") {
- global httpQueryOps, httpAgent, httpProxy, httpProxyByPass, httpQueryReferer, httpQueryAcceptType
- , httpQueryDwFlags
- defaultOps =
- (LTrim Join|
- httpAgent=script|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
- SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
- SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
- INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
- )
- Loop,Parse,defaultOps,|
- {
- RegExMatch(A_LoopField,"(?P<Option>[^=]+)=(?P<Default>.*)",http)
- if StrLen(%httpOption%)=0
- %httpOption% := httpDefault
- }
- hModule := DllCall("LoadLibrary", "Str", "WinINet.Dll")
- offset_name_length:= "4-lpszScheme-255|16-lpszHostName-1024|28-lpszUserName-1024|"
- . "36-lpszPassword-1024|44-lpszUrlPath-1024|52-lpszExtrainfo-1024"
- VarSetCapacity(URL_COMPONENTS,60,0)
- NumPut(60,URL_COMPONENTS,0), NumPut(255,URL_COMPONENTS,12), NumPut(0xffff,URL_COMPONENTS,24)
- Loop,Parse,offset_name_length,|
- {
- RegExMatch(A_LoopField,"(?P<Offset>\d+)-(?P<Name>[a-zA-Z]+)-(?P<Size>\d+)",iCU_)
- VarSetCapacity(%iCU_Name%,iCU_Size,0)
- NumPut(&%iCU_Name%,URL_COMPONENTS,iCU_Offset)
- NumPut(iCU_Size,URL_COMPONENTS,iCU_Offset+4)
- }
- DllCall("WinINet\InternetCrackUrlA","Str",lpszUrl,"uInt",StrLen(lpszUrl),"uInt",0,"uInt",&URL_COMPONENTS)
- Loop,Parse,offset_name_length,|
- {
- RegExMatch(A_LoopField,"-(?P<Name>[a-zA-Z]+)-",iCU_)
- VarSetCapacity(%iCU_Name%,-1)
- }
- nPort:=NumGet(URL_COMPONENTS,24,"uInt")
- dwFlags := httpQueryDwFlags
- if (lpszScheme = "https")
- dwFlags |= (INTERNET_FLAG_SECURE|SECURITY_FLAG_IGNORE_CERT_CN_INVALID
- |SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)
- if (lpszScheme="unknown") {
- Result := "ERR: No Valid URL supplied."
- Return StrLen(Result)
- }
- hInternet := DllCall("WinINet\InternetOpenA"
- ,"Str",httpAgent,"UInt"
- ,(httpProxy != 0 ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT )
- ,"Str",httpProxy,"Str",httpProxyBypass,"Uint",0)
- hConnect := DllCall("WinINet\InternetConnectA"
- ,"uInt",hInternet,"Str",lpszHostname, "Int",nPort
- ,"Str",lpszUserName, "Str",lpszPassword,"uInt",INTERNET_SERVICE_HTTP
- ,"uInt",0,"uInt*",0)
- if (Strlen(POSTDATA)>0) {
- HTTPVerb:="POST"
- if StrLen(Headers)=0
- Headers:="Content-Type: application/x-www-form-urlencoded"
- } else
- HTTPVerb:="GET"
- hRequest := DllCall("WinINet\HttpOpenRequestA"
- ,"uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo
- ,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes
- ,"uInt",dwFlags,"uInt",Context:=0 )
- sRequest := DllCall("WinINet\HttpSendRequestA"
- , "uInt",hRequest,"Str",Headers, "uInt",Strlen(Headers)
- , "Str",POSTData,"uInt",Strlen(POSTData))
- VarSetCapacity(header, 2048, 0)
- VarSetCapacity(header_len, 4, 0)
- Loop, 5
- if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest
- ,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
- break
- If (headerRequest=1) {
- VarSetCapacity(res,headerLength:=NumGet(header_len),32)
- DllCall("RtlMoveMemory","uInt",&res,"uInt",&header,"uInt",headerLength)
- Loop,% headerLength
- if (*(&res-1+a_index)=0)
- NumPut(Asc("`n"),res,a_index-1,"uChar")
- VarSetCapacity(res,-1)
- } else
- res := "timeout"
- Loop,Parse,res,`n,`r
- {
- RetValue := A_LoopField
- break
- }
- If (RetValue="timeout") {
- html := "Error: timeout"
- return -1
- }
- RetValue := RegExReplace(RetValue,"HTTP/1\.[01]\s+")
- RetValue := SubStr(RetValue,1,3)
- if strlen(HTTPQueryOps)>0 {
- if (instr(HTTPQueryOps,"showHeader"))
- MsgBox % res
- if (instr(HTTPQueryOps,"storeHeader"))
- global HttpQueryHeader := res
- if (instr(HTTPQueryOps,"updateSize")) {
- Loop,Parse,res,`n
- If RegExMatch(A_LoopField,"Content-Length:\s+?(?P<Size>\d+)",full) {
- global HttpQueryFullSize := fullSize
- break
- }
- if (fullSize+0=0)
- HttpQueryFullSize := "size unavailable"
- }
- }
- if !(InStr("100 200 201 202 302",RetValue)) {
- Result := RetValue " " RetMsg
- return StrLen(Result)
- }
- VarSetCapacity(BytesRead,4,0)
- fsize := 0
- Loop
- { bc := A_Index
- VarSetCapacity(buffer%bc%,1024,0)
- ReadFile := DllCall("wininet\InternetReadFile"
- ,"uInt",hRequest,"uInt",&buffer%bc%,"uInt",1024,"uInt",&BytesRead)
- ReadBytes := NumGet(BytesRead)
- If ((ReadFile!=0)&&(!ReadBytes))
- break
- Else {
- fsize += ReadBytes
- sizeArray .= ReadBytes "|"
- }
- if (instr(HTTPQueryOps,"updateSize"))
- Global HttpQueryCurrentSize := fsize
- }
- sizeArray := SubStr(sizeArray,1,-1)
- VarSetCapacity(result,fSize+1,0)
- Dest := &result
- Loop,Parse,SizeArray,|
- DllCall("RtlMoveMemory","uInt",Dest,"uInt",&buffer%A_Index%,"uInt",A_LoopField)
- , Dest += A_LoopField
- DllCall("WinINet\InternetCloseHandle", "uInt", hRequest)
- DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
- DllCall("WinINet\InternetCloseHandle", "uInt", hConnect)
- DllCall("FreeLibrary", "UInt", hModule)
- return fSize
- }
- CaptureScreen(aRect = 0, bCursor = False, sFile = "", nQuality = "100")
- {
- 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)
- If bShow && hCursor:=DllCall("CopyIcon", "Uint", hCursor)
- {
- VarSetCapacity(ni, 20, 0)
- DllCall("GetIconInfo", "Uint", hCursor, "Uint", &ni)
- bIcon := NumGet(ni, 0)
- xHotspot := NumGet(ni, 4)
- yHotspot := NumGet(ni, 8)
- hBMMask := NumGet(ni,12)
- hBMColor := NumGet(ni,16)
- DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "Uint", hCursor)
- DllCall("DestroyIcon", "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 = "100")
- {
- If sFileTo =
- sFileTo := A_ScriptDir . "\ScreenShot.jpg"
- 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
- }
Advertisement
Add Comment
Please, Sign In to add comment