Trouble with AppleScript

 I try to run the following script:

 

tell application "iRed2" to perform action Code "1" of Device "Dream/Satellite TV"

 

but I get the following error:

' iRed2 got an error: Can't get code "1" of Device "Dream/ Satellite TV". '

But in iRed2

  • under Device Makes I have 'Dream'
  • under Device Names I have 'Satellite TV'
  • under IR Codes I have '1'

Any ideas?

 

 

Solution Found

 The error was in the name of the code. It appears that the name is padded with a number of invisible characters. To find out therefore what the true name is, I ran the following command:

 

name of every Code of Device "Dream/Satellite TV" of Remote "Dream TV"

 

This gave me the following output:

 

 

{"mute  ", "power    ", ... etc

 

So I copied the content including the quotes for each of these codes and assigned them to the original script. It now works!

 

 

 

 

invisible characters?

 I don't know where these "invisible characters" came from.

Please note that at the bottom of the Action Editor there is a text field "Name for scripts". This field takes precedence over the action name. That's useful if you have special characters as code names, e.g. for "Volume Up...". 

And, there's a popup menu at lower right which gives you a line of AppleScript right to be used. Please see this manual page for details.