【发布时间】:2014-07-16 12:06:46
【问题描述】:
如何在 lua 中保存到(获取剪贴板数据)剪贴板? (视窗)
【问题讨论】:
-
Lua 没有内置的方法,所以所有答案很可能都是“使用库 X”。
如何在 lua 中保存到(获取剪贴板数据)剪贴板? (视窗)
【问题讨论】:
简单!您可以使用 afxLua 库从剪贴板保存和获取信息:
0 . go here - http://luaforge.net/projects/jaslatrix/
1 . click on the "clipboard" link
2 . click on "1.0.0"
3 . select lua version accordingly. If unsure try "clipboard-1.0.0-Lua51.zip"
4 . unzip the downloaded file
5 . the documentation is inside of the clipboard.chm file.
6 . place the clipboard.dll inside of your project folder (or in the same folder as the .lua)
7 . add to the top of your code the following - require "clipboard"
8 . to get clipboard data, assign a variable to clipboard.gettext()
9 . to save data to the clipboard do this - clipboard.setdata(yourVariableOrStringHere)
[meta-numbers]
0 . Why did I make this?
Because awhile ago, when I was a total newbie (lua is the first language I learned), I needed this for a project and was unable to figure out how, so the feature was never implemented despite it's importance. I was also a slightly scared of add-on libraries.
1 . I am not jaslatrix nor am I advertising his library. However, when you search "clipboard API lua" on google, it is impossible to find anything except for c library tutorials, so I figured it'd be nice to share this.
【讨论】:
您可以使用来自winapi 的get_clipboard 和set_clipboard 函数。
【讨论】: