Quantcast
Channel: Ru.Board
Viewing all articles
Browse latest Browse all 923190

CLCL_AHK - менеджер буфера обмена (28) / +расширенная обработка текста средствами Autohotkey и AutoIt

$
0
0
Krot66:
Предложения с заглавных:

Код:

###-AHK###

text:=Clipboard

Clipboard:=RegExReplace(text, "m)(\.|^)([ 0-9\-\*\(]*)(.)([^\.\r\n]*)", "$1$2$U3$L4")

Sleep 200

Send ^{vk56}

Декодирование base64 из выделенного в тексте (файлы с временными метками, расширение можно поменять):
[more=Скрипт]
Код:

###+AHK###

ext:="wav" ; расширение выходного файла

out_file:=A_Temp "\" A_Now "." ext
nBytes := Base64Dec(Clipboard, Bin)
File := FileOpen(out_file, "w")
File.RawWrite(Bin, nBytes)
File.Close()
FileToClipboard(out_file)
ExitApp

Base64Dec( ByRef B64, ByRef Bin ) { ; By SKAN / 18-Aug-2017
Local Rqd := 0, BLen := StrLen(B64) ; CRYPT_STRING_BASE64 := 0x1
DllCall( "Crypt32.dll\CryptStringToBinary", "Str",B64, "UInt",BLen, "UInt",0x1
, "UInt",0, "UIntP",Rqd, "Int",0, "Int",0 )
VarSetCapacity( Bin, 128 ), VarSetCapacity( Bin, 0 ), VarSetCapacity( Bin, Rqd, 0 )
DllCall( "Crypt32.dll\CryptStringToBinary", "Str",B64, "UInt",BLen, "UInt",0x1
, "Ptr",&Bin, "UIntP",Rqd, "Int",0, "Int",0 )
Return Rqd
}

FileToClipboard(PathToCopy,Method="copy")
{
FileCount:=0
PathLength:=0

; Count files and total string length
Loop,Parse,PathToCopy,`n,`r
{
FileCount++
PathLength+=StrLen(A_LoopField)
}

pid:=DllCall("GetCurrentProcessId","uint")
hwnd:=WinExist("ahk_pid " . pid)
; 0x42 = GMEM_MOVEABLE(0x2) | GMEM_ZEROINIT(0x40)
hPath := DllCall("GlobalAlloc","uint",0x42,"uint",20 + (PathLength + FileCount + 1) * 2,"UPtr")
pPath := DllCall("GlobalLock","UPtr",hPath)
NumPut(20,pPath+0),pPath += 16 ; DROPFILES.pFiles = offset of file list
NumPut(1,pPath+0),pPath += 4 ; fWide = 0 -->ANSI,fWide = 1 -->Unicode
Offset:=0
Loop,Parse,PathToCopy,`n,`r ; Rows are delimited by linefeeds (`r`n).
offset += StrPut(A_LoopField,pPath+offset,StrLen(A_LoopField)+1,"UTF-16") * 2

DllCall("GlobalUnlock","UPtr",hPath)
DllCall("OpenClipboard","UPtr",hwnd)
DllCall("EmptyClipboard")
DllCall("SetClipboardData","uint",0xF,"UPtr",hPath) ; 0xF = CF_HDROP

; Write Preferred DropEffect structure to clipboard to switch between copy/cut operations
; 0x42 = GMEM_MOVEABLE(0x2) | GMEM_ZEROINIT(0x40)
mem := DllCall("GlobalAlloc","uint",0x42,"uint",4,"UPtr")
str := DllCall("GlobalLock","UPtr",mem)

if (Method="copy")
DllCall("RtlFillMemory","UPtr",str,"uint",1,"UChar",0x05)
else if (Method="cut")
DllCall("RtlFillMemory","UPtr",str,"uint",1,"UChar",0x02)
else
{
DllCall("CloseClipboard")
return
}

DllCall("GlobalUnlock","UPtr",mem)

cfFormat := DllCall("RegisterClipboardFormat","Str","Preferred DropEffect")
DllCall("SetClipboardData","uint",cfFormat,"UPtr",mem)
DllCall("CloseClipboard")
return
}

[/more]

Viewing all articles
Browse latest Browse all 923190

Trending Articles