just a simple extension--paste current time to clipboard
Posted: 17 May 2012 11:27
1.
I want to get the current time of vlc on to clipboard. The following is an extension for this purpose.
I am new to LUA.
This extension is modified based on Time.
http://addons.videolan.org/content/show ... ent=149618
Many thanks to lubozle.
2.
Putting this simple extension here, I hope those who is not familiar with LUA can get something from it.
Also, if there is any bug with this extension, you are welcomed to point it out.
3.
I use
to put variable into clipboard, is there a direct way to do this in LUA?
I want to get the current time of vlc on to clipboard. The following is an extension for this purpose.
I am new to LUA.
This extension is modified based on Time.
http://addons.videolan.org/content/show ... ent=149618
Many thanks to lubozle.
2.
Putting this simple extension here, I hope those who is not familiar with LUA can get something from it.
Also, if there is any bug with this extension, you are welcomed to point it out.
3.
I use
Code: Select all
strCmd = 'echo '..var..' |clip'
os.execute(strCmd)
Code: Select all
-- Time2Clip.lua -- VLC extension --
--[[
INSTALLATION:
Put the file in the VLC subdir /lua/extensions, by default:
* Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\
Restart the VLC.
Then you simply use the extension by going to the "View" menu and selecting it.
--]]
function descriptor()
return {
title = "Time2Clip";
version = "1.0";
author = "valuex";
url = 'http://addons.videolan.org/content/show.php?content=149618';
shortdesc = "Time2Clip";
description = "<div style=\"background-color:lightgreen;\"><b>just a simple VLC extension </b></div>";
capabilities = {"input-listener"}
}
end
function activate()
input_callback("add")
create_dialog()
end
function deactivate()
input_callback("del")
end
function close()
vlc.deactivate()
end
function input_changed()
input_callback("toggle")
end
callback=false
function input_callback(action) -- action=add/del/toggle
if (action=="toggle" and callback==false) then action="add"
elseif (action=="toggle" and callback==true) then action="del" end
local input = vlc.object.input()
if input and callback==false and action=="add" then
callback=true
vlc.var.add_callback(input, "intf-event", input_events_handler, "Hello world!")
elseif input and callback==true and action=="del" then
callback=false
vlc.var.del_callback(input, "intf-event", input_events_handler, "Hello world!")
end
end
function input_events_handler(var, old, new, data)
end
function create_dialog()
w = vlc.dialog("Time2Clip")
w1 = w:add_label("<b>CurrentTime:</b>",1,1,1,1)
w2 = w:add_text_input("0",2,1,1,1)
w3 = w:add_button("jumpto", click_SEEK,1,2,1,1)
w4 = w:add_button("Save_to_Clip", click_SAVE,2,2,1,1)
end
function click_SAVE()
local input = vlc.object.input()
if input then
local curtime=vlc.var.get(input, "time")
w2:set_text( curtime )
save_to_clipboard(curtime)
end
end
function click_SEEK()
local time_togo = w2:get_text()
local input = vlc.object.input()
if input then
vlc.var.set(input, "time", time_togo) --jump to specified time
end
end
function save_to_clipboard(var)
strCmd = 'echo '..var..' |clip'
os.execute(strCmd)
end