Not sure what you are wanting your buttons to do, maybe reset the timer?
Have you looked at the onSleep/onWake callbacks of the Activity object?
onWake is called whenever the screen activates. That being said, it is called for sure whenever scroll wheel is touched/nudged but for Firm/Hard keys you can configure independently as follows:
1. Activate Screen 2. Activate Screen and Send IR 3. Send IR Only (Send IR also implies execute anything in the action list).
I recommend using scheduleActions instead of executeActions() as executeActions() throws an exception/error if your actionlist contains a Jump Action.
You can put combined script + action functionality on a hard/firm key. You'd need to program your actions in the actionlist and then set the firm/hard key to ProntoScript mode and put in your Javascript.
The button script is as follows: // do whatever you like in javascript followed by. var a=123;
// this will cause the actions in the current button to be executed and because // you are using scheduleActions, the IR Send Icon will rotate. // scheduleActions() can be used safely from within a page script as well as a button script. See the Dev Guide for more details on the usage. this.scheduleActions();
Keep in mind that the above approach will not work well for any IR code that requires a long press or a button that you'd want to hold such as Volume Up/Down. The best you'd be able to do is to use the repeatInterval on a button to send and send again but volume ramping will be very sluggish.
Caveat Emptor - eval is very dangerous in the Web Browser world but for your Pronto Code, it should be just fine with no security issues.
Also note that the 'eval' keyword works too which helps to keep your common script in a single location.
Consider that you put a label on a hidden page with correct prontoscript tagging. // You can put this in your activity ProntoScript so you have an activity-level scoped variable. // Load common script from a panel widget in your config. var w = CF.widget('Script1', 'Scripts', 'CommonStuff'); // The label contains the code to execute. var script1 = w.label;
Then in your button or page script you could do this. this.eval(script1);
The result of 'eval' call is the result of the last statement in your script.
By using 'this.eval', the variables in the button/page/activity are visible within the script you are executing.