'How to copy to clipboard w/o os api using lua and ffi

How do you copy a value or string in lua? I’ve only found alternatives for the regular microsoft os api. For my use I do not have access to the os api and instead have access to ffi and steam panorama.

If possible I would also know how to get a string from the current clipboard.

I have access to,

  1. LuaJIT 2.0.5 (https://github.com/LuaJIT/LuaJIT)

  2. FFI (https://luajit.org/ext_ffi.html)

  3. bit (https://bitop.luajit.org/api.html)

    via neverlose (https://docs.neverlose.cc)



Solution 1:[1]

Probably not the most beautiful solution, but assuming you can run the powershell:

local pipe = io.popen("powershell get-clipboard", "r")
local clipboard = pipe:read("*a")
print("Clipboard: " .. clipboard)
pipe:close()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Piglet