按键精灵_脚本限时试用的通用代码

Dim str=ReadUIConfig("输入框1") 
Dim path="/sdcard/pictures/code.txt"  
Dim time_key=300 '默认单位是秒,5分钟是300秒


If str = "abc123" Then 
  ShowMessage ("激活码正确")
  TracePrint "激活码正确"
  If Dir.Exist(path) = 0 Then 
    TracePrint "计时文件不存在,是首次使用"
    Dim t=time()
    TracePrint t
    file.write(path,t)
    Else 
    TracePrint "计时文件存在"
    dim t1=file.read(path)
    Dim t2=time()
    If t2 - t1 > time_key Then 
      TracePrint "超过试用时间,请联系作者"
      EndScript
      Else 
      TracePrint "剩余时间"&int((time_key-(t2-t1))/60)&"分"&(time_key-(t2-t1)) mod 60 &"秒"
      For i=0 to 3
        ShowMessage ("剩余时间"&int((time_key-(t2-t1))/60)&"分"&(time_key-(t2-t1)) mod 60 &"秒")
        Delay 1000
      Next
    End If
  End If
  Else 
  ShowMessage ("激活码错误")
  TracePrint "激活码错误"
  EndScript
End If

这个在我的基础课也讲过代码的原理,就是通过在本地新建一个文本,用于存储脚本第一次使用时的时间,当脚本再次使用的时候,就会比对这个时间,如果超出你规定的时间,脚本就会自动停止。

赞 (0)