Just Getting Started Looking for Help

I am trying to write a micro that will do the following:

  1. Get the data in the clipboard to the javascript
  2. Run a javascript to select the information I want
  3. Run a URL with the results of the javascript as part of the URL

How do I get the clipboard data as input to the javascript
How do I get the results of the javascript to the URL

Maybe I currently don't know even how to ask a decent question?

Roger

Hey Roger,

You're running your JavaScript in a web browser? Which one?

-Chris

It's not in a browser I think it is in a file similar to a AppleScript file?

Here is one way I run. The AppleScript gets the clipboard runs a JavaScript then puts it back into the clipboard.

Got it did not need to run the java script. Smart app!!

Hey Roger,

You're running an Automator workflow?

You didn't post the workflow file (zipped) or show an image of it, so there's no way we can tell what you're doing.

If you review your first post you'll see that there's no possible way we could have figured out what you were doing from the given description.

If you haven't read this it's worth a couple of minutes of your time.

Tip: How Do I Get The Best Answer in the Shortest Time?

I'm glad you discovered a way to perform your task with Keyboard Maestro.

Note there are also search and search-replace actions.

And Keyboard Maestro has its own JXA action.

// --------------------------------------------------------
// Get the Clipboard
// --------------------------------------------------------

(() => {

   const currentApp = Application.currentApplication();
   const stdAdditions = (currentApp.includeStandardAdditions = true, currentApp);
   let clipboardStr = stdAdditions.theClipboard();
   
   return clipboardStr; 

})();

// --------------------------------------------------------
// Set the Clipboard
// --------------------------------------------------------

(() => {

   const currentApp = Application.currentApplication();
   const stdAdditions = (currentApp.includeStandardAdditions = true, currentApp);
   
   let theStr = "Now is the time for all good men to come to the aid of their country."
   
   currentApp.setTheClipboardTo(theStr);


})();

// --------------------------------------------------------

So – as you can see there are many options.

-Chris

Thanks Chris. I will read the suggestions. And yes there are many options. I am learning and appreciate your patience.

Roger

1 Like