Clipboard manager - mIRC

By contr0l on Jul 26, 2015

Keeps track of past clipboard entries. Resizable.

on *:load:cbm.load
on *:start:cbm.load
on *:exit:cbm.hs
on *:unload:cbm.cu
dialog cbm {
  title "ClipBoard Management v1.4"
  size -1 -1 130 76
  option dbu
  icon $scriptdircbm.ico, 0
  edit "", 4, 39 0 91 66, read multi return vsbar
  text "", 14, 1 67 128 8, disable center
  list 2, 0 0 39 66, size
  menu "Settings", 8
  item "Preferences", 9, 8
  menu "Clear", 10
  item "Selected", 11, 10
  item "All", 7, 10
  button "", 1, 0 0 0 0
}
dialog cbms {
  title "ClipBoard Management's Settings"
  size -1 -1 137 72
  option dbu
  icon $scriptdircbm.ico, 0
  box "Double Click Action", 1, 0 45 137 27
  radio "//msg $active ", 2, 4 55 44 10, group
  radio "//echo -a", 3, 54 55 34 10, group
  radio "ReClipBoard", 14, 93 55 41 10, group
  box "Logging:", 4, 0 0 84 44
  text "Would you like ClipBoard Management to log all clipboard entries when dialog isn't open?", 5, 2 8 80 21, center
  radio "Yes", 6, 16 32 21 11, group
  radio "No", 7, 49 32 17 11, group
  box "Entry Limit:", 8, 83 0 54 44
  text "(default is none/off)", 9, 84 33 52 8, center
  edit "", 10, 91 20 22 10, autohs
  radio "On", 11, 90 9 20 10, group
  radio "Off", 12, 113 9 21 10, group
  button "Set", 13, 113 20 15 11
}
on *:dialog:cbm:*:*: {
  if $devent == init {
    dll $cbmmdx SetMircVersion $version
    dll $cbmmdx MarkDialog $dname
    dll $cbmmdx SetControlMDX 1 Positioner size minbox > $+($scriptdir,mdx\dialog.mdx)
    if %cbm-xywh { dialog -s $dname $ifmatch }
    cbm-.rs
    if ($c'(cbm.so) == yes) { if !$timer(cbm) { .timercbm 0 1 cbm.re } | cbm.rl | did -f $dname 14 }
  } 
  if $devent == sclick { 
    if $did == 1 && *sizing* iswm $did(1) { cbm-.rs }
    if $did == 2 { if $did(cbm,2).sel { var %; $c.ep, %: $+(%;,$did(cbm,2).sel,-cbm.txt) | did -r cbm 4 | loadbuf -o cbm 4 %: } }
  }
  if $devent == dclick && $did == 2 {
    var %? $c.ep, %] $+(%?,$did(cbm,2).sel,-cbm.txt)
    if $c'(cbm.a) == msg { msg $active <cbm> | var %" 1 | while %" <= $lines(%]) { msg $active $read(%],n,%") | inc %" } | msg $active </cbm> }
    elseif $c'(cbm.a) == echo { echo -a <cbm> | var %" 1 | while %" <= $lines(%]) { echo -a $read(%],n,%") | inc %" } | echo -a </cbm> } 
    elseif $c'(cbm.a) == rcb {
      var %" 1 | while %" <= $lines(%]) {
        if %" == 1 { clipboard -n $read(%],%") }
        elseif %" > 1 { clipboard -an $read(%],%") }
        inc %"
      }
      echo -a Entry $+([,$did(cbm,2).sel,]) reclipboarded.
    }
  }
  if $devent == menu {
    if $did == 7 { cbm.da $c.ep }
    elseif $did == 9 { cbm -s }
    elseif $did == 11 { cbm.ds $did(cbm,2).sel }
  }
  if $devent == close { cbm.hs | if $c'(cbm.so) == no { if $timer(cbm) { .timercbm off } | if $dialog(cbms) { dialog -x cbms } } }
}
on *:dialog:cbms:*:*: {
  if $devent == init {
    if $c'(cbm.a) == msg { did -c cbms 2 }
    elseif $c'(cbm.a) == echo { did -c cbms 3 }
    elseif $c'(cbm.a) == rcb { did -c cbms 14 }
    if $c'(cbm.els) == off { did -c cbms 12 | did -b cbms 10,13 }
    elseif $c'(cbm.els) == on { did -c cbms 11 }
    if $c'(cbm.el) { did -ra cbms 10 $ifmatch }
    if $c'(cbm.so) == yes { did -c cbms 6 }
    elseif $c'(cbm.so) == no { did -c cbms 7 }
  }
  if $devent == sclick {
    var %° cbm
    if $did == 2 { hadd %° cbm.a msg | did -u cbms 3,14 }
    elseif $did == 3 { hadd %° cbm.a echo | did -u cbms 2,14 }
    elseif $did == 6 { hadd %° cbm.so yes | did -u cbms 7 }
    elseif $did == 7 { hadd %° cbm.so no | did -u cbms 6 }
    elseif $did == 11 { hadd %° cbm.els on | did -e cbms 10,13 | did -u cbms 12 }
    elseif $did == 12 { hadd %° cbm.els off | did -b cbms 10,13 | did -u cbms 11 }
    elseif $did == 13 { if $did(10) { hadd %° cbm.el $did(10) } }
    elseif $did == 14 { hadd %° cbm.a rcb | did -u cbms 2,3 }
  }
}
alias cbm { if $1 == -s { if !$dialog(cbms) && $dialog(cbm) { d cbms } } | elseif !$1 { if !$dialog(cbm) { d cbm } } }
alias -l d { dialog $iif($dialog($1),-v $1,-m $1) $1 }
alias cbm.cu { cbm.da $c.ep | .timercbmrm 1 1 rmdir $c.ep | .timercbm* off | unset %cbm* | if $hget(cbm) { hfree cbm } | if $isfile($+(",$scriptdircbm.htbl,")) { .remove $+(",$scriptdircbm.htbl,") } }
alias cbm.load {
  set %cbm-xywh 213 76 305 237
  var %- cbm
  if !$hget(%-) { hmake %- 2 }
  if $isfile($+(",$scriptdircbm.htbl,")) { hload %- $+(",$scriptdircbm.htbl,") }
  if !$c'(cbm.ep) { hadd %- cbm.ep $+($scriptdir,entries\) }
  if !$isdir($+(",$c.ep,")) { mkdir $+(",$c.ep,") }
  if !$c'(cbm.a) { hadd %- cbm.a msg }
  if !$c'(cbm.els) { hadd %- cbm.els off }
  if !$c'(cbm.el) { hadd %- cbm.el 0 }
  if !$c'(cbm.so) { hadd %- cbm.so yes }
  if !$timer(%-) { .timercbm 0 1 cbm.re }
  if !$timer(cbmhs) { .timercbmhs 0 300 cbm.hs }
}
alias c' { return $hget(cbm,$1) }
alias -l c.ep { return $c'(cbm.ep) }
alias cbm.hs { if $hget(cbm) { .hsave -o cbm $+(",$scriptdircbm.htbl,") } }
alias -l cbm.rcr { var %res $remove($1,$crlf) | return %res }
alias cbm.re {
  if ($c'(cbm.so) == yes) {
    if $cb(0) {
      var %tt $+(",$c.ep,$cbm.cnn,-cbm.txt,"), %cb $cb(1), %cbb 1, %ctmp 1, %ctmpd $+(",$c.ep,tmp,.cbm.txt,"), %cbbb
      write -c %ctmpd
      while %ctmp <= $cb(0) { write %ctmpd $cb(%ctmp) | inc %ctmp }
      if %tt { if $crc(%tt) != $crc(%ctmpd) { cbm.ma } }
      cbm.rl
    }
  }
}
alias -l cbm.ma {
  if ($c'(cbm.els) == off) || (($c'(cbm.els) == on) && ($cbm.cnn < $c'(cbm.el))) {
    var %= $+(",$c.ep,$calc($cbm.cnn + 1),-cbm.txt,"), %> 1, %< $cb(0)
    write -c %=
    while %> <= %< { write %= $($cb(%>),1) | inc %> }
  }
}
alias -l cbm.rl { if $dialog(cbm) { if $cbm.cnn == 0 || $cbm.cnn > $did(cbm,2).lines { cbm.rl2 } } }
alias -l cbm.rl2 {
  var %. 1, %^ $iif($did(cbm,2).sel,$ifmatch)
  did -r cbm 2
  while %. <= $cbm.cnn {
    did -a cbm 2 $+($str($chr(160),3),%.)
    inc %. 
  } 
  did -ra cbm 14 $+([,$cbm.cnn,]) Entries Recorded.
  if %^ { did -c cbm 2 %^ }
  if $did(cbm,2).sel {
    var %; $c.ep, %: $+(%;,$ifmatch,-cbm.txt) | did -r cbm 4 | loadbuf -o cbm 4 %:
  }
  else did -r cbm 4
}
alias -l cbm.dir { return $+(",$c.ep,$1-,") }
alias -l cbm.cnn { return $findfile($+(",$c.ep,"),*-cbm.txt,0) }
alias -l cbm.da { var %q = $findfile($+(",$1-,"),*-cbm.txt,0,0,.remove $1-) | cbm.rl }
alias cbmmdx { return $+($scriptdir,mdx\mdx.dll) }
alias -l cbm-.rs {
  var %dn cbm
  set %cbm-xywh $dialog(%dn).x $dialog(%dn).y $dialog(%dn).w $dialog(%dn).h
  dll $cbmmdx MoveControl %dn 2 0 0 75 $calc($dialog(%dn).h -56)
  dll $cbmmdx MoveControl %dn 14 $calc(($dialog(%dn).w /2) -55) $calc($dialog(%dn).h - 65) 128 15
  dll $cbmmdx MoveControl %dn 4 75 0 $calc($dialog(%dn).w -83) $calc($dialog(%dn).h - 66)
}

;preciate your help on the following esoteric
alias -l cbm.ds {
  window -hns @_tmp
  var %x $1,%y $findfile($cbm.dir,*-cbm.txt,0,aline @_tmp $nopath($1-)),%z $1,%i
  if (%x isnum 1-) && ($1 <= $line(@_tmp,0)) {
    while (%x <= $line(@_tmp,0)) {
      %i = $gettok($line(@_tmp,%x),1,45)
      if (%i = %z) { .remove $cbm.dir($line(@_tmp,%x)) }
      if (%i != %z) { dec %i | .rename $cbm.dir($line(@_tmp,%x)) $cbm.dir($+(%i,-cbm.txt)) }
      inc %x
    }
  }
  close -@ @_tmp | cbm.rl2
}

menu channel,menubar,status { 
  -
  ClipBoard Management v1.4:cbm
  -
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.