Guest User

subs to clipboard

a guest
Aug 19th, 2025
46
0
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. utils = require 'mp.utils'
  2.  
  3. function escape(s)
  4.   return (s:gsub('\'', '\'\\\'\''))
  5. end
  6.  
  7. function copy_sub()
  8.             --windows copy taken from hsyong, github.com/mpv-player/mpv/issues/4695
  9.             local escapedtext = string.gsub(mp.get_property("sub-text"), "'", "")
  10.             local res = utils.subprocess({ args = {
  11.                 'powershell', '-NoProfile', '-Command', string.format([[& {
  12.                     Trap {
  13.                         Write-Error -ErrorRecord $_
  14.                         Exit 1
  15.                     }
  16.                     Add-Type -AssemblyName PresentationCore
  17.                     [System.Windows.Clipboard]::SetText('%s')
  18.                 }]], escapedtext)
  19.             } })
  20. end
  21.  
  22. mp.add_key_binding("Ctrl+x", "copy_sub", copy_sub)
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment