Hi new to keyboard maestro.. I want help with a macro.. I need to copy text that will always be between to words.. The paragraph will always start with the word Conclusion and end with the word normal, I want to only copy the words in between conclusion and normal. Any thoughts ?
I suppose this would do the job. All you have to do is have the user press CMD-C while the text is selected, and you will get the result stored in a variable called TheResult.
If this isn't sufficient, you need to explain why not. Is the macro supposed to find the candidate string itself? If so, you may have to explain what app the string is contained in.
I was gonna give a RegEx example as well. If you ever need to change this just use AI to ask for what to change. It has gotten pretty good with this though I have finally after all these years gone through multiple RegEx courses to understand what that gobblygook was I was using in my code from others.
To extract the text between the words "Conclusion" and "normal" using regular expressions (RegEx), you can use the following pattern:
RegEx Pattern:
regex
CopyEdit
(?<=Conclusion)(.*?)(?=normal)
Explanation:
(?<=Conclusion)
is a positive lookbehind – it ensures that the match is after the word "Conclusion" but doesn't include it.(.*?)
is a non-greedy capture group – it captures everything up to the next condition.(?=normal)
is a positive lookahead – it ensures the match is before the word "normal" but doesn't include it.
Thanks everyone.. Its my fault for not explaining better what I needed.. I wanted to parse the text on screen, its a repetitive task where I want to copy the text between conclusion and normal into the clipboard so I can paste somewhere else..
You still haven’t said what app contains your text, and you haven’t said what app is supposed to receive your text. And you haven’t said what needs to be done after each paste. I need to understand the problem before I can help with the solution.
I am working on citrix workspace where i remote into work. I read lots of studies and there is a repetitive task where i need to copy the results of a test and paste it somewhere else.. The study is an echocardiogram, the part of the study I need to copy is the result and then copy it into a patients note.. all is done in citrix workspace. The part that I need to copy is always between the words Conclusion and the word Normal.. I would like the results to be held in the clipboard so that when I open the patients note I just have to paste the result.. Thanks for the help : )
I don't have Citrix, so I can't propose a solution for you, because I can't see the app in action. From what I read, it's not very AppleScript-compatible. But if you do one of the following things, I might be able to help: (1) show a video of yourself doing the work manually; (2) document all the keystrokes and decisions that you make as you do some of the work.
Macroing a remote connection is... difficult.
Does the app support triple-click for paragraph selection? Does ⌘C
work? If so, a simple solution might be to position the pointer over the paragraph then run:
Paragraph Parser.kmmacros (3.1 KB)
You'll probably have to fiddle with either the regex or add a "Filter: Trim whitespace" action -- you make no mention of anything between "Conclusion" and the first word you want or the last word and "normal", but I suspect there'll be some whitespace or something...
I second that after trying with several different solutions including Apple Remote Desktop (ARD). Very hit and miss because there are so many things they are trying to do to be native like you are working on the remoted in computer but where they each draw the line and how low level they take over your computer to be the other computer varies.
Like @Nige_S suggested simple keystrokes might work. Often there are preferences for such things and key remappings so check if you have control over some shortcuts and what level of control the app takes over and you will likely find a solution.