Last active
February 7, 2016 07:00
-
-
Save ggslyman/e1298af03ec522711b4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!+^F12:: | |
DupeCount := 0 | |
lastHash := | |
newHash := | |
F12F := 1 | |
F12LF := 1 | |
ScreenshotFilePath := "H:\amarec\pic" | |
ScreenshotFilewildcard := ScreenshotFilePath . "\*.PNG" | |
InputBox,saveFolder,"Input save folder name" | |
OkFileDir := ScreenshotFilePath . "\" . saveFolder | |
FileCreateDir, %OkFileDir% | |
FileCount := CountFiles(OkFileDir) | |
Loop{ | |
if(F12LF != 1){ | |
Break | |
}else{ | |
if(0 == CountFiles(ScreenshotFilePath)){ | |
Send,^+!{\} | |
Sleep 1000 | |
}else{ | |
Loop, H:\amarec\pic\*.PNG | |
{ | |
newHash := HashFile(A_LoopFileFullPath,2) | |
} | |
if(newHash != lastHash){ | |
Send,{Left} | |
Sleep 3000 | |
DupeCount := 0 | |
FileMove,%ScreenshotFilewildcard% , %OkFileDir% | |
lastHash := newHash | |
FileCount++ | |
}else{ | |
FileDelete, H:\amarec\pic\*.PNG | |
DupeCount++ | |
if(DupeCount >= 10){ | |
F12LF := 0 | |
Break | |
} | |
} | |
} | |
} | |
} | |
msgbox, "end scan" | |
Return | |
^F12:: | |
F12LF := 0 | |
Return | |
CountFiles(Folder) { | |
fso := ComObjCreate("Scripting.FileSystemObject") | |
Folder := fso.GetFolder(Folder) | |
return fso.GetFolder(Folder).Files.Count | |
} | |
HashFile(filePath,hashType=2) | |
{ | |
PROV_RSA_AES := 24 | |
CRYPT_VERIFYCONTEXT := 0xF0000000 | |
BUFF_SIZE := 1024 * 1024 ; 1 MB | |
HP_HASHVAL := 0x0002 | |
HP_HASHSIZE := 0x0004 | |
HASH_ALG := hashType = 1 ? (CALG_MD2 := 32769) : HASH_ALG | |
HASH_ALG := hashType = 2 ? (CALG_MD5 := 32771) : HASH_ALG | |
HASH_ALG := hashType = 3 ? (CALG_SHA := 32772) : HASH_ALG | |
HASH_ALG := hashType = 4 ? (CALG_SHA_256 := 32780) : HASH_ALG ;Vista+ only | |
HASH_ALG := hashType = 5 ? (CALG_SHA_384 := 32781) : HASH_ALG ;Vista+ only | |
HASH_ALG := hashType = 6 ? (CALG_SHA_512 := 32782) : HASH_ALG ;Vista+ only | |
f := FileOpen(filePath,"r","CP0") | |
if !IsObject(f) | |
return 0 | |
if !hModule := DllCall( "GetModuleHandleW", "str", "Advapi32.dll", "Ptr" ) | |
hModule := DllCall( "LoadLibraryW", "str", "Advapi32.dll", "Ptr" ) | |
if !dllCall("Advapi32\CryptAcquireContextW" | |
,"Ptr*",hCryptProv | |
,"Uint",0 | |
,"Uint",0 | |
,"Uint",PROV_RSA_AES | |
,"UInt",CRYPT_VERIFYCONTEXT ) | |
Goto,FreeHandles | |
if !dllCall("Advapi32\CryptCreateHash" | |
,"Ptr",hCryptProv | |
,"Uint",HASH_ALG | |
,"Uint",0 | |
,"Uint",0 | |
,"Ptr*",hHash ) | |
Goto,FreeHandles | |
VarSetCapacity(read_buf,BUFF_SIZE,0) | |
hCryptHashData := DllCall("GetProcAddress", "Ptr", hModule, "AStr", "CryptHashData", "Ptr") | |
While (cbCount := f.RawRead(read_buf, BUFF_SIZE)) | |
{ | |
if (cbCount = 0) | |
break | |
if !dllCall(hCryptHashData | |
,"Ptr",hHash | |
,"Ptr",&read_buf | |
,"Uint",cbCount | |
,"Uint",0 ) | |
Goto,FreeHandles | |
} | |
if !dllCall("Advapi32\CryptGetHashParam" | |
,"Ptr",hHash | |
,"Uint",HP_HASHSIZE | |
,"Uint*",HashLen | |
,"Uint*",HashLenSize := 4 | |
,"UInt",0 ) | |
Goto,FreeHandles | |
VarSetCapacity(pbHash,HashLen,0) | |
if !dllCall("Advapi32\CryptGetHashParam" | |
,"Ptr",hHash | |
,"Uint",HP_HASHVAL | |
,"Ptr",&pbHash | |
,"Uint*",HashLen | |
,"UInt",0 ) | |
Goto,FreeHandles | |
SetFormat,integer,Hex | |
loop,%HashLen% | |
{ | |
num := numget(pbHash,A_index-1,"UChar") | |
hashval .= substr((num >> 4),0) . substr((num & 0xf),0) | |
} | |
SetFormat,integer,D | |
FreeHandles: | |
f.Close() | |
DllCall("FreeLibrary", "Ptr", hModule) | |
dllCall("Advapi32\CryptDestroyHash","Ptr",hHash) | |
dllCall("Advapi32\CryptReleaseContext","Ptr",hCryptProv,"UInt",0) | |
return hashval | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment