Paste clipboard in selected field does not happen

I am trying to paste a word copied into the clipboard into the search field for DevonAgent. I select the word the start the KBM macro. Two conditions are possible when I make this command.

Condition a. DevonAgent is open. The open window is variable, so I am trying to quit DevonAgent. Then, start DevonAgent again so theoretically the cursor will be in the field that I need. I start a new search window and it never happens but I want to paste the clipboard word in that window.

Condition b. DevonAgent is not open. So, I need to open it and start the a new search window and the rest of the above process.

What happens is the new search window opens and the old search word appears highlighted. The process of pasting from the clip board does not occur.

This is the macro that does not copy the clipboard.

Hey Ellenm,

That sort of defeats the purpose of automation, because it's sloooow.

If you were going to pursue that method you'd want to simply close windows and then start a new search.

DevonAgent is fairly AppleScriptable, so with its dictionary, a little help from UI-Scripting, and KM to glue it together we get the following macro.

It was a bit challenging to get right, but there you go.

-Chris

DevonAgent { Search using Clipboard Content }.kmmacros (6.4 KB)

OMG It worked. And so simple.
You gave me a term UIscripting.
I found this site describing the process. http://www.makeuseof.com/tag/applescripts-ui-scripting-mac/
Looks awfully heavy, but I will think about it. Anyway, I know that if I try, you guys will set me in the right direction. Keep trying and maybe I will learn something. For now, thank-you so much.
Ellen

Hey Ellenm,

:smile:

DevonAgent's AppleScript dictionary has a couple of quirks that I've now learned how to work with, so I'll post an even more simple script shortly.

As for UI-Scripting I would not get seriously into it without good reason. Keyboard Maestro and regular AppleScript will do a lot of those jobs.

And as Angela says: “Brush Up On Basic Applescript First.”

I've been using AppleScript for 20 years, and I think UI-Scripting is Machiavellian in complexity. Since I have to use it fairly regularly I bit the bullet and bought Bill Cheeseman's UI Browser utility ($55.00 U.S.) The price seemed pretty steep, but UI Browser has saved me so much time and aggravation it was money well spent.

-Chris

1 Like

Hi Chris,

Yes, please I would love to see your redesign of the macro that you put up. I would have never have guessed the macro steps that you designed. So, before trying to learn Greek (Applescript), I want to look at many more scripts that you experts have made. Is there some place where common macros are kept? I am getting so I can modify simple macros. Or at least I will try.

Making macros seem a bit like learning to cook. You have to taste a dish prepared by an able cook first to get the gist of what to think about when actually cooking. Before cooking the next step is to look at some receipes. Even better is watching an able cook in action. (youtube).

(BTW, the macro you made to lookup a word in DevonAgent does not work if DevonAgent is open. So, I am going to add closing the program first. I suppose if it is not open, it will just continue.)

Best,
Ellen

Hi Chris,

If I ran the macro that you wrote, I get the following message.

System Events got an error: Can’t get text field 1 of window 1 of application process “DEVONagent Pro”. Invalid index.

It works fine for the first search. But, the above message appears for the next search. I think it is necessary to close DevonAgent for the next search and to start fresh.

Are you using a program to write the apple script?

Best,
Ellen

Hey Ellenm,

What version of OSX are you using?

What version of DevonAgent?

I'm guessing you're using Yosemite, and that is the problem. (I’m on Mavericks.)

Not really, but it's definitely simpler in several ways.

Of course.

The Applescript Editor comes stock in OSX, although I believe they've changed the name again to Script Editor in 10.10.

I personally use Script Debugger — a commercial AppleScript Editor/Debugger.

I'll have some time to work on this later today.

-Chris