Figured it out from lockscreen lua. You need a timer that can be stopped if you do not have a need for it. So the "if not VoiceCmdCheckCount" does that. Then later in your code you start it again with the timer start command and setting "VoiceCmdCheckCount = 0"
Code:
--## handler to check for \windows\startup\voice command.lnk
VoiceCmdCheck = function()
if not VoiceCmdCheckCount or VoiceCmdCheckCount > 60 then
VoiceCmdCheckCount = nil -- set counter to be "off"
VoiceCmdTimer:Stop() --stop after initializing or after 60 seconds
else
VoiceCmdCheckCount = VoiceCmdCheckCount + 1
if VoiceCmdStart == 1 then --starting voice command
if MusicHelper_FileExists("\\windows\\startup\\voice command.lnk") then --if \windows\startup\voice command.lnk exists
_application.Store:SetIntValue(Lifetime_Permanent, "CHT.VoiceCommand.Active", 1)
VoiceCmdCheckCount = nil -- set counter to be "off"
end
elseif VoiceCmdStart == 0 then -- stopping voice command
if not MusicHelper_FileExists("\\windows\\startup\\voice command.lnk") then --if \windows\startup\voice command.lnk is gone
_application.Store:SetIntValue(Lifetime_Permanent, "CHT.VoiceCommand.Active", 0)
VoiceCmdCheckCount = nil -- set counter to be "off"
end
end
end
end
--## timer to check for \windows\startup\voice command.lnk
VoiceCmdTimer = timer(1) -- one second
VoiceCmdTimer:Stop()
VoiceCmdTimer.OnElapsed:connect(VoiceCmdCheck)
-- In each part for start or stop voice command need
-- stop
VoiceCmdStart = 0
VoiceCmdCheckCount = 0 -- set counter to be "on"
VoiceCmdTimer:Start()
-- start
VoiceCmdStart = 1
VoiceCmdCheckCount = 0 -- set counter to be "on"
VoiceCmdTimer:Start()
Now to see if I can figure out if MusicHelper has a process exists check
Samsung Galaxy S III
Read About Me to see what I am working on & following like CHTS, Reminder and AppTask widgets, and CHT basic function tweaks. Also, Fixed CHT restarting when you have no tasks.
Mortscript | iniEditor | regEditor| MortScripts to toggle settings
Samsung Infuse 4G drowned. If you have one check out Scott's CM10 or CM10PA Firmware
ATT Fuze (HTC RAPH110) with Energy ROM: Energy.RAPHAEL.29022.Sense2.5.Cookie.2.0.Jul.06
HTC Wizard|See about me for my ROM collection and other work
|