On Nov 10, 2015, at 04:23, Robert Livingston <[email protected]> wrote: > Thanks for chiming in. The problem is that I have to monitor the > replacements. Sometimes they are appropriate. Sometimes not. > > What I am doing is editing an OCR'ed document. There are certain patterns > that are commonly errors but sometime legitimate.
______________________________________________________________________ Hey Robert, Scope out my Keyboard Maestro macro: Toggle Between Window 1 and Window 2 in any Application <https://forum.keyboardmaestro.com/t/toggle-between-window-1-and-window-2-in-any-application/1960> Find can also be scripted: tell application "BBEdit" tell text of front text window find ".*have.*" options {search mode:grep, case sensitive:false, starting at top:true} with selecting match end tell end tell Although this does NOT populate the Find Window. Populating the Find Window is possible with AppleScript if a bit overly complicated, although this is waaay faster and more reliable than driving the UI with Keyboard Maestro. ------------------------------------------------------------ set findString to "partial workaround" set replaceString to "partial work-around" tell application "BBEdit" select insertion point before text of front text window if visible of find window = false then open find window else if index of find window > 1 then set index of find window to 1 end if tell find window set text 1 to findString set text 2 to replaceString end tell set index of window 2 to 1 end tell ------------------------------------------------------------ The Find Window has to be OPEN and FRONTMOST for the changes to stick. The script manages that way faster than you can by hand. If you're integrating with Keyboard Maestro then you may need to get/set KM variables: --------------------------------------------------------------------- # Keyboard Maestro — Get value of variable "<variable name>" --------------------------------------------------------------------- tell application "Keyboard Maestro Engine" set kmVariableName to "X" if length of (get variables whose name is kmVariableName) = 1 then set myValue to value of variable kmVariableName else error "Variable '" & kmVariableName & "' does not exist!" end if end tell --------------------------------------------------------------------- # Keyboard Maestro — Set value of variable "<variable name>" --------------------------------------------------------------------- tell application "Keyboard Maestro Engine" set kmVariableName to "myVariableName" try set value of variable kmVariableName to myText on error make new variable with properties {name:kmVariableName, value:myText} end try end tell --------------------------------------------------------------------- The Find Window options (checkboxes) can be managed via AppleScript and System Events: ------------------------------------------------------------ property findOptionsOn : true if findOptionsOn then --------------------------------------------- # Turn ON all find-options. --------------------------------------------- tell application "BBEdit" if front window is not find window then open find window tell application "System Events" if quit delay is not 0 then set quit delay to 0 tell application process "BBEdit" set frontmost to true tell UI element 6 of window "Find" tell checkbox "Case sensitive" if its value = 0 then click end tell tell checkbox "Entire Word" if its value = 0 then click end tell tell checkbox "Grep" if its value = 0 then click end tell tell checkbox "Selected text only" if its value = 0 then click end tell tell checkbox "Wrap around" if its value = 0 then click end tell end tell end tell end tell # close find window end tell else --------------------------------------------- # Turn OFF all find-options. --------------------------------------------- tell application "BBEdit" if front window is not find window then open find window tell application "System Events" if quit delay is not 0 then set quit delay to 0 tell application process "BBEdit" set frontmost to true tell UI element 6 of window "Find" tell checkbox "Case sensitive" if its value = 1 then click end tell tell checkbox "Entire Word" if its value = 1 then click end tell tell checkbox "Grep" if its value = 1 then click end tell tell checkbox "Selected text only" if its value = 1 then click end tell tell checkbox "Wrap around" if its value = 1 then click end tell end tell end tell end tell # close find window end tell --------------------------------------------- end if ------------------------------------------------------------ But this is painfully slow. Keyboard Maestro's Press Button action combined with If (button-condition) Then is tremendously faster. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
