Word Shortcut

By Callison1 on Jun 09, 2007

This snippet will allow you to create shortcuts for words or phrases via a menu bar popup and when switched on, will replace the shortcuts with the words or phrasea when you send the message in both channels and query.

The menu will also allow you to remove shortcuts, switch it on and off and view the txt file called words.txt (should create itself when you add words) but you must create it manually if you want to add words manually, each shortcut should be on it's own line, with it's word or phrase.

Hi Hello there!
brb be right back
k kay

Hi would be replaced with Hello there, and so on.

Is switched off in it's initial state, but easily switched on, by the menu bar popup.

menu menubar {
  Autocomplete
  .Add a shortcut: { var %q = $$?="Enter The Word or Phrase" | var %p = $$?="Enter Keyboard Shortcut"
    if (( %q == $null )) { noop $input(You didn't enter the word or phrase,o,No Word or Phrase Entered) | halt }
    if (( %p == $null )) { noop $input(You didn't enter keyboard shortcut,o,No Shortcut Entered) | halt }
    if (( $read(words.txt, s, %p) != $null )) { noop $input(You already have a word or phrase for that shortcut,o,Shortcut Already Exists) | halt }
    write words.txt %p %q
  }
  .Remove a shortcut: { var %q = $$?="Enter Keyboard Shortcut"
    if (( %q == $null )) { noop $input(You didn't enter the shortcut,o,No Shortcut Entered) | halt }
    if (( $read(words.txt, s, %q) == $null )) { noop $input(You don't have that shortcut,o,Shortcut Doesn't Exist) | halt }
    write -ds $+ $$! words.txt %q
  }
  .Turn Autocomplete On:.enable #autocomplete | noop $input(Auto Complete is switched on,o,Auto Complete On)
  .Turn Autocomplete Off:.disable #autocomplete | noop $input(Auto Complete is switched off,o,Auto Complete Off)
  .View your words:run words.txt
}
#autocomplete off
on *:INPUT:*: {
  if (Status !isin $active && $left($1-,1) != /) {
    var %c = 1
    var %p
    while (( %c <= $numtok($1-,32) )) {
      var %m = $($+($,%c),2)
      if (( $read(words.txt, s, $($+($,%c),2)) != $null )) { var %t = $read(words.txt, s, $($+($,%c),2)) }
      else { set %t nope }
      if (( %t != nope )) { var %p = %p %t }
      if (( %t == nope )) { var %p = %p %m }
      inc %c
    }
    msg $active %p
    halt
  }
}
#autocomplete end

Comments

Sign in to comment.
AndyAbnormal   -  May 21, 2022

Thx, exactly what i was looking for :D

 Respond  
Callison1   -  Jun 21, 2007

Thanks

 Respond  
Ghost-lit Warder   -  Jun 21, 2007

Nice job. :)

 Respond  
Callison1   -  Jun 12, 2007

Any feedback?

 Respond  
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.