Reputation: 461
How do I save to and from (get clipboard data) clipboard in lua? (Windows)
Upvotes: 2
Views: 9024
Reputation: 26744
You can use get_clipboard and set_clipboard functions from winapi.
Upvotes: 1
Reputation: 461
Simple! You can save and get information from the clipboard using the afxLua library:
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.
Upvotes: 2