Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2965 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a simple Applescript that works in Script Editor

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

I add this same script (with escape chars) to my RESOURCES::A_SCRIPT field inside FM.

The RESOURCES table is not connected to the other tables in the graph.

"tell application \"Keyboard Maestro Engine\" 
do script \"Search the Web\" 
end tell"

I've tried this with this field being defined as a Global Storage Field or not.  Similar problems with both.

I have an FM Script called EXECUTE:

Perform Applescript (RESOURCES::A_SCRIPT)

When I run this FM Script I get an error message:

"Error: -2741" / "Expected EOL but found Command Name"

I've have tried rebooting my Mac.

Any ideas?

 

 

Posted (edited)

If you're using a text field to hold your ApppleScript, then you shouldn't need to escape anything. Just copy-paste the script as is from Script Editor into the field. Do not add quotes, either.

 

Edited by comment
Posted (edited)

Doesn't work.

I just copied the exact same (working) script from Script Editor into the FM Global Storage Text Field (no escape chars or double quotes).

Not accepted.  "Specified Field not found" when "Tell Application" is highlighted.

Edited by fm8443
Posted

We are having a communication problem here. There is no way you can get such error when pasting into a text field. You are obviously pasting into a calculation window, but I cannot tell in what context.

Posted (edited)

Yes - its a calculation window that delivers a text result. 

Not following how to put this code into a Text field without quotes?

Edited by fm8443
Posted

OK I've added this to the FM Script (Native Applescript panel):

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

It now works.

But how do I remove this code into a FM RESOURCES::A_SCRIPT field and then have it work similarly?

(I want to do this to build up to a more complex Applescript with parameters from FM.)

 

I've turned RESOURCES::A_SCRIPT field into a Text field and tried pasting the text of the Applescript into the DATA panel (or the CALC panel) of the Auto-Enter screen.  

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

I then reference this from the FM Script.  Still get the "Error: -2741"

Posted
1 minute ago, fm8443 said:

(I want to do this to build up to a more complex Applescript with parameters from FM.)

 

An example would be useful.  In general, you have two choices:

1. Paste the AppleScript into the global field, then select the Calculated AppleScript option and enter a calculation that modifies the text in the global text field to what you want;

or:

2. Do the entire calculation within the Perform AppleScript step; this is the only option that requires you to escape the AppleScript - and the escaped version would look like this:

"tell application \"Keyboard Maestro Engine\" ¶do script \"Search the Web\" ¶end tell "

Of course, this is just the beginning, before you insert the parameters.

 

Posted
7 minutes ago, comment said:

1. Paste the AppleScript into the global field, then select the Calculated AppleScript option and enter a calculation that modifies the text in the global text field to what you want;

Doesn't work for me.  Get error as above.

Do you men that I should paste the text of the Applescript into the DATA panel of the Auto-Enter screen of my RESOURCES::A_SCRIPT ?

tell application "Keyboard Maestro Engine" 
do script "Search the Web" 
end tell

And then reference this from my FM Script as this?

Perform Applescript (RESOURCES::A_SCRIPT)

I still get the "Error: -2741"


 

 
Posted (edited)
11 minutes ago, fm8443 said:

Do you men that I should paste the text of the Applescript into the DATA panel of the Auto-Enter screen of my RESOURCES::A_SCRIPT ?

No. You should paste it into the field itself. Place the field onto a layout, enter Browse mode, click into the field and paste. Do not specify any auto-enter options for the field.

 

Edited by comment
Posted
16 minutes ago, comment said:

No. You should paste it into the field itself. Place the field onto a layout, enter Browse mode, click into the field and paste.

OK done this on a new global text field.  Created clean new FM script as well.

Getting error -2741 "Expected EOL but found command name"

Also tried your #2 (escape chars etc) and I get no error message/no results!

Posted

Sorry, I don't know for sure what you did. Understand also that I don't have Keyboard Maestro, so I don't know what the expected result is here.

I suggest you take a look at this simple demo and see if you can take it from there.

SimpleAS.fp7

  • Like 1
Posted

Thanks for the file.  It works as expected.  It also works when I copy in my Applescript.  

The weird thing is that 12 hours later MY script now works with no error message as I repeatedly got last night.  I made no changes to it at all!

Didn't reboot Mac or restart FM or KM or Safari.

My setup looks exactly the same as yours except I run the FM Script from the FM menu (not from a button).  Thanks again.

Posted
14 minutes ago, fm8443 said:

The weird thing is that 12 hours later MY script now works with no error message as I repeatedly got last night.  I made no changes to it at all!

Maybe you have the first computer ever with the caprice feature...

Note that once you have finalized your AppleScript, you should move it from the global field and make it a self-contained calculation within the Perform AppleScroipt[] script step. Otherwise you will lose it if you clone your file.

Posted
1 hour ago, comment said:

Maybe you have the first computer ever with the caprice feature...

?  As in Clint Dempsey?  

Posted

Hmm ... they have "Caprice Is a Feature Of Dempsey's Game" as the headline -  but the word caprice is nowhere in the text, so it's hard to tell what they mean.

I meant simply that the computer could be acting "weird" because it's capricious. Which is just another way of suggesting that PIBKAC.

This topic is 2965 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.