Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Previous page Next page Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Page 2 of 3
Topic:
[SOLVED]Change multiple key actions on press of a key
This thread has 36 replies. Displaying posts 16 through 30.
OP | Post 16 made on Monday January 2, 2012 at 03:41
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
Guy, good spotting of the missing bracket. Thanks.

On January 1, 2012 at 15:16, Guy Palmer said...
  Hence your test scripts of OutputState=6 etc are never executed but if you replaced these with actionlists then they would be.

It's a fresh new day and I have looked through "The prontoscript developers guide" again. But I still can't find any examples of the correct syntax to use for the Actions of my buttons KeyA (to set OutputState=6 & 10). I have tried various permutations to no avail.

I'm stuck!
Post 17 made on Monday January 2, 2012 at 05:48
Guy Palmer
Active Member
Joined:
Posts:
June 2008
647
I'm not clear what you are trying to do but my guess is that your problem is a conceptual one rather than a syntax one.  scheduleActions() is a prontoscript command which invokes non-prontoscript actionlists held on buttons.  If you want to run some prontoscript (e.g. outputstate=6), you don't use scheduleActions().  Rather, you either just add the script directly on the button being pressed or you put the script into a function held in the activity-level (or page-level) prontoscript and then do a function call from the button.
OP | Post 18 made on Monday January 2, 2012 at 07:32
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
On January 2, 2012 at 05:48, Guy Palmer said...
I'm not clear what you are trying to do but my guess is that your problem is a conceptual one rather than a syntax one.  scheduleActions() is a prontoscript command which invokes non-prontoscript actionlists held on buttons.  If you want to run some prontoscript (e.g. outputstate=6), you don't use scheduleActions().  Rather, you either just add the script directly on the button being pressed or you put the script into a function held in the activity-level (or page-level) prontoscript and then do a function call from the button.

I’m certainly out of my depth with this…

My goal was to have a keyboard on an Overlay. My problem was how to handle CAPS Shift and Numbers Shift from a button press on the keyboard.

Lyndel’s (appreciated) suggestion was to:-

Create 2 buttons with same ProntoScript Name on 2 separate hidden pages and then use executeActions() or scheduleActions() against the correct widget/button. In the onscreen button (the one pressed for Key A on the keyboard Overlay), do the following:-

if (keyboardState == 0) // unshifted
CF.widget("KeyA", "Unshifted").scheduleActions();
else if (keyboardState == 1) // shifted
CF.widget("KeyA", "Shifted").scheduleActions();

In the action of the shift key, simply set the appropriate keyboard state i.e 0 or 1.

In the buttons of the duplicate pages Unshifted and Shifted I am trying to put some simple code in there just to confirm the Keyboard is switching pages. So I decided to try to change a variable (i.e. OutputState = 6; And for Unshifted OutputState = 10) and read it to confirm. Once this is working correctly my intention is to use both IR commands and TCP Socket commands.

I am very new to Prontoscript and Javascript and maybe I have bitten off more that I can chew at the moment. However if I could get this to work it will be great!.

What to do to correct this, I have no idea. If one of you Prontoscript gods could walk me through it I would be eternally grateful!

Steve
Post 19 made on Monday January 2, 2012 at 09:27
Guy Palmer
Active Member
Joined:
Posts:
June 2008
647
Steve,

I think you just need to take a deep breath and try and understand how the Prontos work.  I'll try and explain again:

a. Actions are selected from the dropdown boxes in actions tab.  They are basically restricted to a) sending IR commands and b) jumping between pages.  When you press a button which contains some actions, these actions are executed.

b. Prontoscript (which is Javascript with a few extras) can be used to do lots of things (e.g. in your case, set values for variables or do conditional logic) but it can't directly either a) send IR commands or b) jump between pages.

c. To get round this, Phillips added two prontoscript commands - i.e. scheduleActions() and executeActions() - which allow scripts to invoke actions which are on buttons and thus allow prontoscript to effectively send IR commands and to jump between pages.

So, the way one does something is to do it all in prontoscript, occassionally jumping out using scheduleActions/executeActions when you want to either send an IR commmand or jump to a different page.

Putting this another way: Prontos handle IR commands and TCP commands in completely different ways: IR commands are handled by actions (which can be invoked by either pressing the relevant button or by using scheduleActions/executeActions in prontoscript); TCP commands are handled within prontoscript and not by actions.  By contrast, prontos handle TCP commands, setting variable values and conditional logic in similar ways: i.e. within prontoscript

Or another way: scheduleActions/executeActions only work when what you want to do is limited to sending IR commands and/or jumping pages.

The code you have written:

if (keyboardState == 0) // unshifted
CF.widget("KeyA", "Unshifted").scheduleActions();
else if (keyboardState == 1) // shifted
CF.widget("KeyA", "Shifted").scheduleActions();

will work in that it will invoke the action lists in the relevant "KeyA" button.  But it can't be used to set the keyboard state to 0 or 1 as "set the keyboard state to 0 or 1" is not an action and, by definition, is not part of your action list in the "KeyA" button.

Perhaps your confusion comes from the fact that, oddly, the way that one adds prontoscript to a button is to go to the action tab, then press the prontoscript button in the top right hand corner, then write prontoscript commands in the window that appears.  But that window is actually nothing to do with actions and the prontoscript commands that you put there can only be invoked by actually pressing the button itself.
OP | Post 20 made on Monday January 2, 2012 at 10:42
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
Guy, you have the patients of a saint. Thanks for sticking with me….

Your explanation makes more sense to me know (I think!)

I will need to do some research to understand when to use scheduleActions over executeActions though!

On January 2, 2012 at 09:27, Guy Palmer said...
Steve,

The code you have written:

if (keyboardState == 0) // unshifted
CF.widget("KeyA", "Unshifted").scheduleActions();
else if (keyboardState == 1) // shifted
CF.widget("KeyA", "Shifted").scheduleActions();

will work in that it will invoke the action lists in the relevant "KeyA" button. But it can't be used to set the keyboard state to 0 or 1 as "set the keyboard state to 0 or 1" is not an action and, by definition, is not part of your action list in the "KeyA" button.

Perhaps your confusion comes from the fact that, oddly, the way that one adds prontoscript to a button is to go to the action tab, then press the prontoscript button in the top right hand corner, then write prontoscript commands in the window that appears. But that window is actually nothing to do with actions and the prontoscript commands that you put there can only be invoked by actually pressing the button itself.

Ok I think I’m still with you, in so much that I can’t use the set variable to check my keyboard is switching with that .scheduleActions code. However I could use jump to another page with the actions list on both KeyA on the Unshifted & Shifted pages…. Correct?

I have tried this and it’s still spitting out an error:-

ProntoScript error: TypeError: CF.widget("KeyA", "Unshifted") has no properties
Offending button script: Tag: 'KeyA'
Offending line #3: "CF.widget("KeyA", "Unshifted").scheduleActions();".

Just to confirm. I have an overlay which is a clone of two additional pages. One called Unshifted and the other Shifted. I have a key on each all called KeyA. On the overlay KeyA has the following code:-

if (keyboardState == 0) // Unshifted
CF.widget("KeyA", "Unshifted").scheduleActions();
else if (keyboardState == 1) // Shifted
CF.widget("KeyA", "Shifted").scheduleActions();

Now on the Unshifted page, KeyA, I have set the following action:-
Jump: Home – Test1

On the Shifted page, KeyA, I have set the following action:-
Jump: Home - Test2

On my tests I am pressing KeyA on the overlay expecting it to action the code on either KeyA on the Unshifted or KeyA on the Shifted page. (Determined by the variable keyboardState set by the Shift key on the overlay)

Either I still completely misunderstand or I have done something wrong.

Can I apologise for the frustration I must be causing you….

Steve
Post 21 made on Monday January 2, 2012 at 12:10
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,792
Steve,

I think you likely have issues where you may not have setup the ProntoScript names (aka tags) properly on all pages and widgets.

In your activity script, you should have the following:

var keyboardState = 0;

Now, in your Overlay page, you should add a button 'Shift' and put in the following prontoscript for the button.

if (keyboardState == 0)
keyboardState = 1;
else
keyboardState = 0;


To be able to add ProntoScript to the UI button, you must press the 'PS' button on the top-right of the Actions tab toolbar of the Properties dialog. Add your script, and optionally give this button a ProntoScript name.

Finally, on your pages 'Unshifted' and 'Shifted', be sure you assigned the ProntoScript Name and not the label (the label appears in the tree view on the left) based on whether page is Unshifted or Shifted. Next, on each of your 'KeyA' buttons, make sure you assigned the ProntoScript name (aka tag) by clicking the 'PS' button on the top-right of the Actions tab toolbar of the Properties dialog. The ProntoScript name you should assign to both buttons is 'KeyA'.

Now, for the differences between scheduleActions and executeActions, please run a search for both keywords. I have included some relevant threads here as well.

[Link: remotecentral.com]

[Link: remotecentral.com]

If your actionList contains a Page Jump, you should use scheduleActions otherwise, you must use Javascript try/catch block to avoid logging an error that is emitted when Page Jump occurs to the Diagnostic Log.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 22 made on Monday January 2, 2012 at 12:53
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
Lyndel,

Thank you so much,

My errors were:-

1) I put the code

if (keyboardState == 0) // unshifted
CF.widget("KeyA", "Unshifted").scheduleActions();
else if (keyboardState == 1) // shifted
CF.widget("KeyA", "Shifted").scheduleActions();

on my Overlay in KeyA instead of the Shift button.

2) Stupidly of me, I didn’t assign a Prontoscript name to both 'Unshifted' and 'Shifted' pages.

With these corrections the page switch is now working!

It now leaves me to clean up the keyboard keys and set the correct actions.

Again, Lyndel and Guy, thank you very much for sticking with me on this, it’s much appreciated.

Brilliant…….

Steve
Post 23 made on Monday January 2, 2012 at 14:22
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,792
Based on what you were saying earlier, I kinda figured you missed tagging a page or a button.

Regarding your comment about errors. You had said that you wanted to do a keyboard early on in this thread and so I gave you the script code that should go in the shift button such that when you press the 'A' (KeyA) key on the keyboard that it would execute one of 2 actions. The code in the Shift button should be used only to change the state of the variable (shift vs unshift vs ctrl, etc) and then of course change the labels on all your other Key(x) buttons. The exercise of writing that code is left for exploration.

Glad you are up and going now.

Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 24 made on Monday January 2, 2012 at 17:18
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
Thanks again Lyndel, It was nice to nail this one. I'm confident I can experiment and get the rest of the coding to work.

Famous last words ah!

Steve
OP | Post 25 made on Sunday January 8, 2012 at 03:40
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
Guys back for help again!

I have the above working and sending my correct scheduleActions() depending on if the shift key was pressed or not, ok.

I would also like the ability to switch to executeActions() instead of the scheduleActions() based on the state of a variable.

The reason for this:-
I am hoping to code the keyboard to send commands via TCP/IP using the scheduleActions() Providing the TCP/IP socket is connected, else fall back to IR.

I haven’t figured out the code to check the socket connection state yet (that comes later), but would like to get it working by manually changing the variable for now.

Can anyone give me a pointer on how to go about this, if at all possible?

Thanks

Steve
Post 26 made on Sunday January 8, 2012 at 09:22
Guy Palmer
Active Member
Joined:
Posts:
June 2008
647
As per earlier in the thread, I'm not clear exactly what you are referring to when you talk about "TCP/IP".  If it really is TCP/IP, as opposed to wifi RS232 or wifi extenders, then I think the logic is:

a. Try to send the TCP/IP command.

b. If this fails, assume that there is no TCP/IP connection and invoke the IR actionlist.
Post 27 made on Sunday January 8, 2012 at 14:58
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,792
You cannot execute any script (including TCP/IP send) via scheduleActions() or executeActions().
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 28 made on Sunday January 8, 2012 at 17:15
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
On January 8, 2012 at 09:22, Guy Palmer said...
As per earlier in the thread, I'm not clear exactly what you are referring to when you talk about "TCP/IP". If it really is TCP/IP, as opposed to wifi RS232 or wifi extenders, then I think the logic is:

a. Try to send the TCP/IP command.

b. If this fails, assume that there is no TCP/IP connection and invoke the IR actionlist.

Guy, you are correct I do mean “TCP/IP” I have this bit working already using prontoscript. My problem is I’m not sure where to put the IR command. I assume I put it under the Actions tab for the button on the overlay “KeyA”? Having said that I also have prontoscript code on the same button so where would I tell the “remote control” to call which action with an if statement?

Here the prontoscript i'm using on "KeyA"

// 0 = Unshifted (low) 1 = Shifted (Caps)

if (keyboardState == 0) // Unshifted

CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Send Test1 Text!"));

else if (keyboardState == 1) // Shifted

CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Send Test 2 Text !"));
OP | Post 29 made on Sunday January 8, 2012 at 17:21
Stealth
Long Time Member
Joined:
Posts:
December 2003
45
On January 8, 2012 at 14:58, Lyndel McGee said...
You cannot execute any script (including TCP/IP send) via scheduleActions() or executeActions().

Hello Lyndel,

I’m confused as I am already using prontoscript to send TCP/IP commands and it appears to be working ok.

This is what I’m using on “KeyA” of my overlay:-


// 0 = Unshifted (low) 1 = Shifted (Caps)

if (keyboardState == 0) // Unshifted

CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Not Shifted !"));

else if (keyboardState == 1) // Shifted

CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Shifted Pressed !"));



Do you mean I can’t use both types of actions (prontoscript and IR) on the same key (even with an if statement)?

Thanks

Steve
Post 30 made on Sunday January 8, 2012 at 19:50
Guy Palmer
Active Member
Joined:
Posts:
June 2008
647
I am finding it difficult to say anything useful because I simply don't understand your code.

As I understand it, widget.scheduleActions() is a method which simply says "execute the actionlist of the widget.  So:

a. It doesn't have any parameters.  So, I don't understand what your parameter TCPCommand ("chars:Send Test1 Text!") is doing, or trying to do.

b. It is nothing to do with TCP/IP.

So, your code:

if (keyboardState == 0) // Unshifted

CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Send Test1 Text!"));

else if (keyboardState == 1) // Shifted

CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Send Test 2 Text !"));

is effectively:

if (keyboardState == 0) CF.widget("KeyA","Unshifted").scheduleActions();

else if (keyboardState == 1) CF.widget("KeyA","Unshifted").scheduleActions();

In other words:

if keyboardState is either 0 or 1 then execute the actionlist of button "KeyA" on page "Unshifted".
Page 2 of 3


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse