Advertisement
FichteFoll

mIRC - Aegisub script

May 3rd, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.77 KB | None | 0 0
  1. #aegisub on
  2. alias aegisub_get_lasteditfile {
  3.   var %fi $findfile($1-,*.*,0)
  4.   var %latestfile_name none
  5.   var %latestfile_time 0
  6.   while (%fi > 0) {
  7.     var %fn $findfile($1-,*.*,%fi)
  8.     if ($_filetime(%fn) > %latestfile_time) {
  9.       var %latestfile_name %fn
  10.       var %latestfile_time $file(%fn).mtime
  11.     }
  12.     dec %fi
  13.   }
  14.   return %latestfile_name
  15. }
  16.  
  17. alias -l _expandenv {
  18.   if (!$com(WSH)) .comopen WSH WScript.Shell
  19.   .timer 0 60 if ($com(WSH)) .comclose WSH
  20.   if (!$comerr) {
  21.     if ($com(WSH,ExpandEnvironmentStrings,1,bstr*,$1-)) {
  22.       return $com(WSH).result
  23.     }
  24.   }
  25. }
  26.  
  27. alias -l _filetime {
  28.   if (!$exists($1-)) return 0
  29.   var %mt $file($1-).mtime
  30.   var %ct $file($1-).ctime
  31.   if (%mt >= %ct) return %mt
  32.   return %ct
  33. }
  34.  
  35. alias aegisub_get_currentfile {
  36.   var %appdata $+(%,appdata,%)
  37.   var %cand1 $aegisub_get_lasteditfile($_expandenv(%appdata $+ \Aegisub\autoback))
  38.   var %cand2 $aegisub_get_lasteditfile($_expandenv(%appdata $+ \Aegisub\autosave))
  39.   if (%cand1 && %cand2) {
  40.     var %mtime1 $_filetime(%cand1)
  41.     var %mtime2 $_filetime(%cand2)
  42.     var %cand $iif(%mtime1 > %mtime2,%cand1,%cand2)
  43.   }
  44.   elseif (%cand1) {
  45.     var %cand %cand1
  46.   }
  47.   elseif (%vand2) {
  48.     var %cand %cand2
  49.   }
  50.   else {
  51.     return
  52.   }
  53.   if ($calc($ctime - $_filetime(%cand)) < 600) return %cand
  54. }
  55.  
  56. alias aegisub_undecorate_filename {
  57.   if (!$exists($1-)) return
  58.   var %fn $nopath($1-)
  59.   var %fn $replace(%fn,.AUTOSAVE.,.,.ORIGINAL.,.)
  60.   return %fn
  61. }
  62.  
  63. alias aegisub_nowediting {
  64.   var %fn $aegisub_get_currentfile
  65.   if (!%fn) {
  66.     /me has not worked on something with Aegisub in the past 10 minutes
  67.   }
  68.   else {
  69.     var %fn $aegisub_undecorate_filename(%fn)
  70.     /me was just (and may still be) using Aegisub to edit $+(",%fn,")
  71.   }
  72. }
  73. #aegisub end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement