Code: Select all
#singleinstance force
GroupAdd,ExplorerGroup, ahk_class CabinetWClass
GroupAdd,ExplorerGroup, ahk_class ExploreWClass
Explorer_GetPath(hwnd="")
{
if !(window := Explorer_GetWindow(hwnd))
return ErrorLevel := "ERROR"
if (window="desktop")
return A_Desktop
path := window.LocationURL
path := RegExReplace(path, "ftp://.*@","ftp://")
StringReplace, path, path, file:///
StringReplace, path, path, /, \, All
Loop
If RegExMatch(path, "i)(?<=%)[\da-f]{1,2}", hex)
StringReplace, path, path, `%%hex%, % Chr("0x" . hex), All
Else Break
return path
}
Explorer_GetAll(hwnd="")
{
return Explorer_Get(hwnd)
}
Explorer_GetSelected(hwnd="")
{
return Explorer_Get(hwnd,true)
}
Explorer_GetWindow(hwnd="")
{
WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
WinGetClass class, ahk_id %hwnd%
if (process!="explorer.exe")
return
if (class ~= "(Cabinet|Explore)WClass")
{
for window in ComObjCreate("Shell.Application").Windows
if (window.hwnd==hwnd)
return window
}
else if (class ~= "Progman|WorkerW")
return "desktop"
}
Explorer_Get(hwnd="",selection=false)
{
if !(window := Explorer_GetWindow(hwnd))
return ErrorLevel := "ERROR"
if (window="desktop")
{
ControlGet, hwWindow, HWND,, SysListView321, ahk_class Progman
if !hwWindow
ControlGet, hwWindow, HWND,, SysListView321, A
ControlGet, files, List, % ( selection ? "Selected":"") "Col1",,ahk_id %hwWindow%
base := SubStr(A_Desktop,0,1)=="\" ? SubStr(A_Desktop,1,-1) : A_Desktop
Loop, Parse, files, `n, `r
{
path := base "\" A_LoopField
IfExist %path%
ret .= path "`n"
}
}
else
{
if selection
collection := window.document.SelectedItems
else
collection := window.document.Folder.Items
for item in collection
ret .= item.path "`n"
}
return Trim(ret,"`n")
}
return
<^<!<e::
IfWinActive ahk_group ExplorerGroup
{
inputfile =
inputfile := Explorer_GetSelected()
Loop, parse, inputfile, `n
{
filetoencrypt = %A_LoopField%
keyWord := "мой пароль"
keyLen := (StrPut(keyWord) - 1) << !!A_IsUnicode
; encrypt data
File := FileOpen(filetoencrypt, "r")
File.Pos := 0
len := File.RawRead(buff, File.Length)
Bcrypt(&buff, len, outData, &keyWord, keyLen,,, "RC4")
File := FileOpen(filetoencrypt, "w")
File.RawWrite(outData, len)
File := ""
}
}
return
Bcrypt(pData, dataSize, ByRef outData, pKey, keySize, pIv := 0, ivSize := 0, AlgId := "AES", crypt := "Decrypt", chainingMode := "ChainingModeCBC") {
; crypt: Encrypt/Decrypt
static padding := BCRYPT_BLOCK_PADDING := 1, chainingModeSize := StrLen(chainingMode)*2
pLocalIv := 0
if pIv {
VarSetCapacity(localIv, ivSize, 0)
DllCall("RtlMoveMemory", "Ptr", pLocalIv := &localIv, "Ptr", pIv, "Ptr", ivSize)
}
DllCall("Bcrypt\BCryptOpenAlgorithmProvider", "PtrP", hAlgorithm, "WStr", AlgId, "Ptr", 0, "UInt", 0)
DllCall("Bcrypt\BCryptSetProperty", "Ptr", hAlgorithm, "WStr", "ChainingMode"
, "WStr", chainingMode, "UInt", chainingModeSize, "UInt", 0)
DllCall("Bcrypt\BCryptGenerateSymmetricKey", "Ptr", hAlgorithm, "PtrP", hKey, "Ptr", 0, "UInt", 0
, "Ptr" , pKey, "UInt", keySize, "UInt", 0, "UInt")
res := DllCall("Bcrypt\BCrypt" . crypt, "Ptr", hKey, "Ptr", pData, "UInt", dataSize, "Ptr", 0
, "Ptr", pLocalIv, "UInt", ivSize, "Ptr", 0
, "UInt", 0, "UIntP", outSize, "UInt", padding, "UInt")
if (res != 0)
throw "Crypt error! BCrypt" . crypt . "1 result: " . Format("{:#x}", res)
VarSetCapacity(outData, outSize, 0)
res := DllCall("Bcrypt\BCrypt" . crypt, "Ptr", hKey, "Ptr", pData, "UInt", dataSize, "Ptr", 0
, "Ptr", pLocalIv, "UInt", ivSize, "Ptr", &outData
, "UInt", outSize, "UIntP", outSize, "UInt", padding, "UInt")
if (res != 0)
throw "Crypt error! BCrypt" . crypt . "2 result: " . Format("{:#x}", res)
DllCall("Bcrypt\BCryptDestroyKey", "Ptr", hKey)
DllCall("Bcrypt\BCryptCloseAlgorithmProvider", "Ptr", hAlgorithm, "UInt", 0)
Return outSize
}