如何在实时代码应用程序中的Mac OS X上收听特定的文本字符串

问题描述 投票:0回答:1

我想创建一个类似于textexpanderatext的Mac应用。这两个应用程序都允许用户定义片段以及它们各自的触发词。在任何应用程序中键入触发词,然后用定义的实际代码段替换该触发词。

我假定应用程序侦听任何应用程序中键入的所有字符串,并且当它检测到与定义的触发词之一匹配的字符串时,它将用代码段替换。

是它实际如何工作,还是有其他方法?如果有人能帮助我指出我可以阅读的资源,我将不胜感激。并且任何相关的livecode文档都将是天赐之物。

谢谢。

livecode textexpander
1个回答
0
投票

设置两个字段。在字段2中输入类似以下内容:

  time xyz
  come ABC

在字段1的脚本中:

 on textChanged
if the last char of me = space then put the last word of me into temp
if temp is in fld 2 then
   repeat for each word tWord in fld 2
      put  the last word of line lineOffset(temp,fld 2) of fld 2 into the last word of me
      exit repeat
   end repeat
end if
select after text of me
end textChanged

现在输入fld 1,您知道,“现在是所有好男人来帮助他们的国家的时候了。用数组可以更好地做到这一点,但是在这里可能更容易理解这个概念。

© www.soinside.com 2019 - 2024. All rights reserved.