In conditions of Source Engine (in this case - csgo) hacks Lua api, you can create interface to vgui2.dll and ffi.cast to it's functions. Here is three snippets of code for neverlose - initialisation, getting and setting clipboard.
If you want - you can still port this code to other csgo cheats by replacing Utils.CreateInterface
with the same function what is in your cheat's api documentation. For example, in gamesense it will be client.create_interface
-- initialisation (ffi, creating functions and interface)
local ffi = require("ffi")
ffi.cdef[[
typedef int(__thiscall* get_clipboard_text_count)(void*);
typedef void(__thiscall* get_clipboard_text)(void*, int, const char*, int);
typedef void(__thiscall* set_clipboard_text)(void*, const char*, int);
]]
local VGUI_Systemdll = Utils.CreateInterface("vgui2.dll", "VGUI_System010")
local VGUI_System = ffi.cast(ffi.typeof('void***'), VGUI_Systemdll)
local get_clipboard_text_count = ffi.cast( "get_clipboard_text_count", VGUI_System[ 0 ][ 7 ] )
local get_clipboard_text = ffi.cast( "get_clipboard_text", VGUI_System[ 0 ][ 11 ] )
local set_clipboard_text = ffi.cast( "set_clipboard_text", VGUI_System[ 0 ][ 9 ] )
-- getting clipboard content
local clipboard_text_length = get_clipboard_text_count( VGUI_System )
local clipboardstring = ""
if clipboard_text_length > 0 then -- game will probably crash without that check
local buffer = ffi.new("char[?]", clipboard_text_length)
local size = clipboard_text_length * ffi.sizeof("char[?]", clipboard_text_length)
get_clipboard_text( VGUI_System, 0, buffer, size )
clipboardstring = ffi.string( buffer, clipboard_text_length-1 )
end
-- clipboardstring variable is what's in the clipboard
-- writing to clipboard
local some_cool_string = "i love ryuko very much"
set_clipboard_text(VGUI_System, some_cool_string, some_cool_string:len())