Moderators Popular Post SmOke_N Posted February 14 Moderators Popular Post Share Posted February 14 (edited) After answering some clipboard questions in the help forum, I found myself writing a couple of helper funcs so I thought I'd share. I don't think I added any headers, I'm probably assuming (maybe to much?) that most will get it (yep, to lazy). Example code: #include "ClipBoardMisc.au3" #include <Array.au3> #cs Example 1 collect all the text/unicode/binary data in an array from clip #ce Global $gaArgs = _cbTest_GetAllData() _ArrayDisplay($gaArgs, Default, Default, Default, Default, _ "Format Type|Data TEXT|Data Unicode|Data Byte|Data ByteStr") Func _cbTest_GetAllData() Local $aClipFormats = _ClipBoard_GetCurrentFormatArray() If @error Then Return SetError(1, 0, Null) Local $aRet[UBound($aClipFormats)][5] ; [n][3] is memory address For $i = 0 To UBound($aClipFormats) - 1 ; Using all CBRT_ globals because I'm to lazy to go through all the CFSTR and do ; exhausting test functions to test what type of strings they are ; See: https://geekdude.io/static/ahk/Constants.W32.ini if you want to get a long list of CFSTR_ options $aRet[$i][0] = $aClipFormats[$i][2] $aRet[$i][1] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_TEXT) $aRet[$i][2] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_UNICODE) $aRet[$i][3] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_BYTE) $aRet[$i][4] = _ClipBoard_GetMemoryData($aClipFormats[$i][3], $CBRT_BYTESTR) Next Return $aRet EndFunc Example 2: Get specific format id types array #include "ClipBoardMisc.au3" #include <Array.au3> ;~ #cs Example 2 ; Make sure you use "copy" on a file to test this ; Func: _ClipBoard_GetTypeArray($sType, $hOwner = 0) ; ; $sType: 1. String to be split by "|" separator char ; 2. Return type to be added similar as a struct ; example: $sType = "Text;str|FileNameW;wstr" ; Separates 2 types of arrays internally ; 1. Type array: [n] = "Text" ; [n] = "FileNameW" ; 2. Return type: [n] = "str" ; [n] = "wstr" ; Valid Format Return Strying types: ; "str" or "chr" ; "wstr" or "wchr" or "unicode" ; "byte" ; "bytestr" ; Return: Success: 2D array ; [n][0] = Found Type ; [n][1] = Found Value ; ; Note: It will not validate if the memory address is valid for your return type Global $ga_Test = _ClipBoard_GetTypeArray("filename;str|filenameW;wstr") If @error Then MsgBox(16, "Error", "Error: " & @error & " :: Extended: " & @extended) Else _ArrayDisplay($ga_Test) EndIf ;~ #ce ; updated zip ClipBoardMisc.zip Edited February 16 by SmOke_N Updated zip, added headers to ClipBoardMisc.au3 functions ioa747, taurus905, argumentum and 2 others 2 3 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now