Advertisement
Cerberus_tm

Ed

Oct 17th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Auto-execute section
  2. ; Note: no commands / variable names / etc. are case sensitive.
  3.  
  4. ; How to escape characters:
  5. ; `% (perc. sign)
  6. ; "" (double quotes)
  7.  
  8. ; Commas should not be used in the list of matching pairs, and spaces only to separate the members of each pair. Both restrictions can be changed if needed.
  9.  
  10. AllMatchingPairs :=  
  11. (LTrim Join`,  ; This section may not exceed 16,383 characters.
  12. "
  13. '6 {U+2018}
  14. '9 {U+2019}
  15. ""6 {U+201c}
  16. "
  17. )
  18.  
  19. AllNgraphs := RegExReplace(AllMatchingPairs, "(\s[^,]*)|(^,)|(,$)")  ; Creates string of n-graphs to match.
  20.  
  21. ; End of auto-execute section
  22. ; ----------------------------------------------------------
  23.  
  24. ^k::  
  25. Input, NgraphTyped, V, {Escape}, %AllNgraphs%  ; Escape cancels input. If V(isible) is removed, the two {Backspace ...} below should also be removed.
  26.  
  27. If ( Errorlevel = "Match" )
  28.     Loop, Parse, AllMatchingPairs, `,
  29.         {
  30.         Loop, Parse, A_Loopfield, %A_Space%  
  31.             {
  32.             If (A_Index = "1")
  33.                 {
  34.                 If ( A_Loopfield != NgraphTyped )
  35.                     Break
  36.                 Else
  37.                     StringLen, NgraphLength, A_Loopfield
  38.                 }
  39.             If (A_Index = "2")
  40.                 {
  41.                 If ( NgraphLength > 10 )
  42.                     {
  43.                     NgraphLength := 10
  44.                     Send {Backspace %NgraphLength%}%A_Loopfield%
  45.                     Msgbox Error: sending more than 10 backspaces is probably a bug.
  46.                     }
  47.                 Else
  48.                     Send {Backspace %NgraphLength%}%A_Loopfield%
  49.                 Return
  50.                 }
  51.             }
  52.         }
  53.  
  54. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement