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 3 of 3
Topic:
[SOLVED]Change multiple key actions on press of a key
This thread has 36 replies. Displaying posts 31 through 37.
Post 31 made on Sunday January 8, 2012 at 21:23
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,899
You cannot invoke script on a secondary widget using scheduleActions or executeActions..... Script can only be invoked from a press of a UI button.

So, you'd do something like the following:

try
{
if (keyboardState == 0) // Unshifted
mySocket.send("a"); // assumes that socket variable is in scope.
else if (keyboardState == 1) // Shifted
mySocket.send("A"); // assumes that socket variable is in scope.
}
catch(e)
{
if (keyboardState == 0) // Unshifted
CF.widget("KeyA", "Unshifted").scheduleActions();
else if (keyboardState == 1) // Shifted
CF.widget("KeyA", "Shifted").scheduleActions();
}

Please have a look at this thread.

[Link: remotecentral.com]

In the past, I've had thread subject lines edited where tips/good info apply to include [PS]. The above link is one of those threads.

Here's another thread that explains how to do 2 different actions on a single UI button. Very similar to what you started with.

[Link: remotecentral.com]

I have authored several threads about the use of eval() and panel labels for purposes of storing common script in a configuration that can be executed later as needed.

If you need to execute a block of code instead of sending on a socket, you could use eval to execute script contained in panel label. For example,

CF.activity().eval(CF.widget('Script-KeyA', 'Unshifted').label);

where you create a Panel widget (with tag of 'Script-KeyA') on the same page (Unshifted page you previously created) containing Button with tag of 'KeyA'. The panel label could contain script. For example,

System.print("Hello World!!!");

Good luck.

Last edited by Lyndel McGee on January 8, 2012 21:43.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 32 made on Sunday January 8, 2012 at 22:03
Guy Palmer
Active Member
Joined:
Posts:
June 2008
647
Note that, although Lyndel and I have said rather different things, these things have all been consistent with each other.  In other words, I agree with the content of all of his posts thus far!
Post 33 made on Monday January 9, 2012 at 19:20
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,899
Thanks Guy. :-)
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 34 made on Tuesday January 10, 2012 at 15:08
Stealth
Long Time Member
Joined:
Posts:
December 2003
54
On January 8, 2012 at 19:50, Guy Palmer said...
I am finding it difficult to say anything useful because I simply don't understand your code.

Hello Guy,

Thank you for your reply. I’m still trying to pickup Javascript and Prontoscript so thanks for bearing with me on this.

I understand from your response that I’m using incorrect syntax i.e :-

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

And it should look more like:-

CF.widget("KeyA", "Unshifted").scheduleActions();

With the actions added to the button I’m using (KeyA) which is placed on another page (Unshifted).

TCPCommand is a function created to send text to a socket. I tried to put the above “function command” example directly on “KeyA” (on the page named “Unshifted”) but it would not work. Hence how I came about using the incorrect code I used, as it did appear to send the command ok. Having given this some more thought I was wondering if its not working due to the code for the TCPCommand function is on another page i.e. “Activity Properties”?

Here is the code used on "Activity Properties:-


var keyboardState = 0;

// Define variables
var Target_PC = CF.widget("Remote_PC_IP_Address", "PARAMETERS").label
var Target_Port = CF.widget("Remote_PC_PORT", "PARAMETERS").label
var return_data = "";
var Remote_PC_Socket = new TCPSocket(false);

// Write log if failure
Remote_PC_Socket.onIOError = function(e)
{
Diagnostics.log("Remote_PC_Socket failure: " + e);
};

// Capture return data
Remote_PC_Socket.onData = function()
{
return_data += read();
};

// Initialize Socket
function Initialize()
{
Remote_PC_Socket.onConnect = function()
{

};

// Connect to socket
Remote_PC_Socket.connect(Target_PC,Target_Port,3000);
}

function TCPCommand(command)
{
Remote_PC_Socket.write(command + "\r\n");
}

I’m currently lost and think I need to go back to the beginning and have a re-think!

My goal is to have an onscreen keyboard (talking to Media Center PC) on an overlay which can send both TCP/IP commands if a socket is connected else fall back to Media Center IR commands. Hence I need two commands on each keyboard button.
OP | Post 35 made on Tuesday January 10, 2012 at 15:23
Stealth
Long Time Member
Joined:
Posts:
December 2003
54
On January 8, 2012 at 21:23, Lyndel McGee said...
You cannot invoke script on a secondary widget using scheduleActions or executeActions..... Script can only be invoked from a press of a UI button.

| Please have a look at this thread.

[Link: remotecentral.com]

| Here's another thread that explains how to do 2 different actions on a single UI button. Very similar to what you started with.

[Link: remotecentral.com]

.

Hello Lyndel,

Again thanks for persevering with me!

A lot of what you said has gone over my head. I think I need to go back to basics and study my books, the guide and the links you kindly given me. After all this I hope I can get a better understanding of the code you have written for me and thus get it working properly.

Thanks again for all you contributions.

I will get this working! It can't beat me!

Cheers

Steve
Post 36 made on Tuesday January 10, 2012 at 20:33
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,899
Put the TCPCommand function in the activity that contains the overlay and voila, it will work just fine.

If not, you must resort to putting the function markup in the a panel label and using something like eval() to compile the function so that it is addressable when you press your UI button.

You cannot put the function in the ProntoScript tab of 'KeyA' on either your 'Shifted' or 'Unshifted' page. All ProntoScript MUST be in the UI button on your overlay.

Regards,
Lyndel McGee
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 37 made on Saturday January 21, 2012 at 04:33
Stealth
Long Time Member
Joined:
Posts:
December 2003
54
I like to say a big thank you to Lyndel for helping me off list to understand and resolve my problem.
I now have this working correctly with the following code!

// 0 = Unshifted 1 = Shifted

if (keyboardState == 0) // Unshifted
if (Remote_PC_Socket.connected)
TCPCommand ("chars:Test Text Send… Lowercase Selected !");
else
CF.widget('KeyA', 'Unshifted').scheduleActions();
else if (keyboardState == 1) // Caps_Keyboard
if (Remote_PC_Socket.connected)
TCPCommand ("chars: Test Text Send… Caps Selected !");
else
CF.widget('KeyA', 'Shifted').scheduleActions();


Thank you very much Lyndel

Steve
Page 3 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