|
|
|
08-06-2020, 02:36 PM
|
#1
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
Timestamp in clipboard. How to go there?
I have a timestamp, such as 1:03:27.901 in the clipboard.
Normally I open the Jump to time window, paste the timestmap in, then press enter.
I don't see how to automate this in a custom action. I can open the dialog, but I'm unclear how to paste the time into the textbox.
I'm guessing there's a more elegant way to go about this (such as by bypassing the jump-to dialog altogether), but I'm not seeing it. There is no paste command in the actions dialog, that accomplishes what I want, nor any "go to time as stored in clipboard," that I can see.
To repeat. The ultimate goal is: I want to programatically jump to the time that is currently stored in the clipboard.
How can I achieve this?
Thanks.
|
|
|
08-07-2020, 02:41 PM
|
#2
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
Searched through both the manual and
Options > Assign keyboard shortcuts > Actions
for all the following terms, with no luck:
Paste, clipboard, jump, cursor, time
Seems hitting a menu command such as paste or the delete key should be easy, so I'm assuming I'm missing something big. Still looking... Need to start watching the videos...
Last edited by aliteralmind; 08-07-2020 at 03:09 PM.
|
|
|
08-08-2020, 01:45 AM
|
#3
|
Human being with feelings
Join Date: Jan 2014
Posts: 923
|
lua script: Jump to time (timestamp from clipboard)
https://drive.google.com/file/d/1aWX...ew?usp=sharing
---------------------------------------------------------------------------------
Or you can copy all timestamps at once
format should look like this:
1:03:27.901
1:04:27.901
1:05:27.901
then run this lua script: Insert markers (multiline timestamp from clipboard)
https://drive.google.com/file/d/1FlZ...ew?usp=sharing
then use actions to navigate in project:
Markers: Go to previous marker/project start
Markers: Go to next marker/project end
|
|
|
08-08-2020, 11:01 AM
|
#4
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
Amazing.
I just discovered that function in the API, but had not yet had a chance to write my first script. Watching and reading tutorials. Will be trying it soon, but it's already made as part of a custom action, ready to go.
Thanks so much.
|
|
|
08-08-2020, 04:58 PM
|
#5
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
Okay, Thanks to your example, I'm really close.
I took your code and come up with the following:
Code:
--[[
Inspired by:
-- Author: Embass
-- v0.1
local times = {}
local clipboard = reaper.CF_GetClipboard()
for line in string.gmatch(clipboard, "[^\n ]+") do
local time = reaper.parse_timestr(line)
table.insert(times, time)
end
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()
for i, time in ipairs(times) do
reaper.AddProjectMarker(0, false, time, 0, "", -1)
end
reaper.Undo_EndBlock("Insert project markers", -1)
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
]]
-- UNKNOWN MINOR PROBLEM: Changing variable name from "s" to "toTrim" causes
-- "attempt to call a nil value (method 'gtoTrimub')"
function trimString(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function msgLine(toDisplayNoEOL)
reaper.ShowConsoleMsg(toDisplayNoEOL.."\n")
end
-- Test string:
startSkipEndTimestamps="38:57.711\n Skip Mark\n 38:59.094\n"
-- Live:
--local startSkipEndTimestamps = reaper.CF_GetClipboard()
msgLine("Original line from clipboard: '"..startSkipEndTimestamps.."'")
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()
local startTime = nil
for line in string.gmatch(startSkipEndTimestamps, "[^\n]+") do
line = trimString(line)
msgLine("line='"..line.."'")
if line ~= "Skip Mark" then
local time = reaper.parse_timestr(line)
reaper.AddProjectMarker(0, false, time, 0, "", -1)
msgLine("Created marker at line='"..line.."', '".."time='"..time.."'")
--We want the first value only.
if startTime == nil then
startTime = time
msgLine("startTime='"..startTime.."'")
end
else
end
end
-- Go to the start-marker (start-cut)
-- With thanks to
-- Author: Embass
-- v0.1
reaper.SetEditCurPos(startTime, true, false)
reaper.Undo_EndBlock("Insert project markers", -1)
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
My goal is to take this from the clipboard (I'm assuming it's formatted exactly as I expect. I'm not error checking it):
Code:
38:57.711
Skip Mark
38:59.094
Splitting and trimming the outer two (timestamp) lines, creating markers at those two timestamps, and then putting the cursor on the start-mark. Between these two markers represents a cut.
The problem is that although ****this works**** for the test string, it doesn't work when I retrieve that SAME STRING from the clipboard. When I attempt it, it tells me:
Code:
Line 41: attempt to concatenate a nil value (local 'startSkipEndTimestamps')
What am I missing?
Once I figure this out, I already have a custom action ready and waiting to actually implement the cut.
Last edited by aliteralmind; 08-08-2020 at 05:18 PM.
|
|
|
08-08-2020, 09:47 PM
|
#6
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
By the way, here’s the only place I’m seeing the CF_Get Clipboard function mentioned:
http://forum.cakewalk.com/m/tm.aspx?m=3652246&p=1
(Not doubting it works, just documenting it.)
Last edited by aliteralmind; 08-09-2020 at 07:02 AM.
|
|
|
08-09-2020, 08:18 AM
|
#7
|
Human being with feelings
Join Date: Jan 2014
Posts: 923
|
It works for me.. maybe you forgot to uncomment this line?
Code:
local startSkipEndTimestamps = reaper.CF_GetClipboard()
Code:
-- UNKNOWN MINOR PROBLEM: Changing variable name from "s" to "toTrim" causes
-- "attempt to call a nil value (method 'gtoTrimub')"
-- function should look like this:
function trimString(toTrim)
return (toTrim:gsub("^%s*(.-)%s*$", "%1"))
end
|
|
|
08-09-2020, 08:24 AM
|
#8
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
Quote:
Originally Posted by Embass
It works for me.. maybe you forgot to uncomment this line?
Code:
local startSkipEndTimestamps = reaper.CF_GetClipboard()
|
Lol. No. It doesn’t work when I uncomment the line. As the above error message confirms.
I just tried it again to make sure I’m not crazy.
|
|
|
08-09-2020, 08:26 AM
|
#9
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
Quote:
Originally Posted by Embass
Code:
-- UNKNOWN MINOR PROBLEM: Changing variable name from "s" to "toTrim" causes
-- "attempt to call a nil value (method 'gtoTrimub')"
-- function should look like this:
function trimString(toTrim)
return (toTrim:gsub("^%s*(.-)%s*$", "%1"))
end
|
Ohhhhhh!
|
|
|
08-09-2020, 11:13 AM
|
#10
|
Human being with feelings
Join Date: Jan 2014
Posts: 923
|
For testing purposes try this:
Code:
-- comment out this line
-- msgLine("Original line from clipboard: '"..startSkipEndTimestamps.."'")
-- add this code below
if startSkipEndTimestamps == nil then
reaper.ShowConsoleMsg("ERROR: startSkipEndTimestamps = nil")
else
reaper.ShowConsoleMsg(startSkipEndTimestamps)
end
do return end -- terminate script
it should show clipboard contents in console output.
|
|
|
08-09-2020, 11:45 AM
|
#11
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
Done. New code:
Code:
function trimString(toTrim)
return (toTrim:gsub("^%s*(.-)%s*$", "%1"))
end
function msgLine(toDisplayNoEOL)
reaper.ShowConsoleMsg(toDisplayNoEOL.."\n")
end
-- Test string:
-- startSkipEndTimestamps="38:57.711\n Skip Mark\n 38:59.094\n"
-- Live:
local startSkipEndTimestamps = reaper.CF_GetClipboard()
if startSkipEndTimestamps == nil then
reaper.ShowConsoleMsg("ERROR: startSkipEndTimestamps = nil\n")
else
reaper.ShowConsoleMsg(startSkipEndTimestamps)
end
do return end -- terminate script
-- msgLine("Original line from clipboard: '"..startSkipEndTimestamps.."'")
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()
local startTime = nil
for line in string.gmatch(startSkipEndTimestamps, "[^\n]+") do
line = trimString(line)
msgLine("line='"..line.."'")
if line ~= "Skip Mark" then
local time = reaper.parse_timestr(line)
reaper.AddProjectMarker(0, false, time, 0, "", -1)
msgLine("Created marker at line='"..line.."', '".."time='"..time.."'")
--We want the first value only.
if startTime == nil then
startTime = time
msgLine("startTime='"..startTime.."'")
end
else
end
end
-- Go to the start-marker (start-cut)
-- With thanks to
-- Author: Embass
-- v0.1
reaper.SetEditCurPos(startTime, true, false)
reaper.Undo_EndBlock("Insert project markers", -1)
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
Code:
ERROR: startSkipEndTimestamps = nil
|
|
|
08-09-2020, 12:00 PM
|
#12
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
This is weird.
Same code, but manually setting the clipboard, immediately before getting it:
Code:
function trimString(toTrim)
return (toTrim:gsub("^%s*(.-)%s*$", "%1"))
end
function msgLine(toDisplayNoEOL)
reaper.ShowConsoleMsg(toDisplayNoEOL.."\n")
end
-- Test string:
-- startSkipEndTimestamps="38:57.711\n Skip Mark\n 38:59.094\n"
-- Live:
x = reaper.CF_SetClipboard("test!!!")
local startSkipEndTimestamps = reaper.CF_GetClipboard("y")
if startSkipEndTimestamps == nil then
reaper.ShowConsoleMsg("ERROR: startSkipEndTimestamps = nil\n")
else
reaper.ShowConsoleMsg(startSkipEndTimestamps)
end
do return end -- terminate script
-- msgLine("Original line from clipboard: '"..startSkipEndTimestamps.."'")
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()
local startTime = nil
for line in string.gmatch(startSkipEndTimestamps, "[^\n]+") do
line = trimString(line)
msgLine("line='"..line.."'")
if line ~= "Skip Mark" then
local time = reaper.parse_timestr(line)
reaper.AddProjectMarker(0, false, time, 0, "", -1)
msgLine("Created marker at line='"..line.."', '".."time='"..time.."'")
--We want the first value only.
if startTime == nil then
startTime = time
msgLine("startTime='"..startTime.."'")
end
else
end
end
-- Go to the start-marker (start-cut)
-- With thanks to
-- Author: Embass
-- v0.1
reaper.SetEditCurPos(startTime, true, false)
reaper.Undo_EndBlock("Insert project markers", -1)
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
Before adding the "y" parameter to CF_SetClipboard, I got this output:
Code:
test!!!ERROR: startSkipEndTimestamps = nil
And this error:
Code:
'reaper.CF_GetClipboard': expected 1 arguments minimum
After adding in the "y" parameter, it worked for the manually set clipboard. Output:
|
|
|
08-09-2020, 12:19 PM
|
#13
|
Human being with feelings
Join Date: Mar 2013
Posts: 96
|
SON OF UH.
That "y" parameter kicked it into gear.
I eliminated the call to CF_SetClipboard, and now it works. It actually responds with the text that I copy from my timestamps text document.
It now sets the markers exactly as I hoped.
I appreciate your working through this with me.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:23 AM.
|