Applescript:Menu Macro Question

Have a problem? A question? This is the place for answers from other Express users.
Post Reply
BFarr
Posts: 2
Joined: 2006-03-29 19:31:31

Applescript:Menu Macro Question

Post by BFarr »

I have a document in which I would like to change numbers appearing between brackets to a smaller font. In order to get this text into a non-contiguous selection, I can execute a PowerFind Pro search with the following search string: \[[0-9]+\]

Does anyone know whether it is possible to issue a PowerFind Pro search using the Menu Macro syntax in AppleScript?

If not, are there any other scripting solutions that pop to mind?

Thanks,
Brandon
Bob Stern
Posts: 182
Joined: 2006-03-12 12:32:47

Post by Bob Stern »

The Do Menu Macro command can open the Find dialog, but it cannot paste text into the Find and Replace fields. Below is an AppleScript to do this using Apple's awkward GUI Scripting commands.

Even GUI Scripting cannot set the setting of the Using popup menu to Power Find Pro because Nisus did not use standard Apple interface elements for the popup menus and the buttons in the Find dialog, so Apple's System Events cannot see these interface elements. Accordingly, my script ends with a reminder to set the Using popup before clicking the Find button.

In the following script, there should be a Tab character between the quotes on the line whose comment begins "Tab." You can delete this part of the script if you don't need to set the contents of the Replace field.

"Display dialog" works only if it is inside the "tell NWE" block.

BEGIN APPLESCRIPT:

set txtFind to "\\((.|\\s)*?\\)\\s*"
set txtReplace to ""


--Find string:
tell application "Nisus Writer Express v27b1"
activate
Do Menu Macro with macro "Use Selection for Find" --'Find What' field will be selected when open Find dialog.
Do Menu Macro with macro "Edit:Find:Find…" --open Find dialog.
set the clipboard to txtFind
Do Menu Macro with macro "Edit:Paste:Paste" --paste text to Find into dialog
end tell


--Replace string:
tell application "System Events"
tell process "Nisus Writer Express"
keystroke " " --Tab. Move cursor to Replace field in Find dialog.
end tell
end tell
tell application "Nisus Writer Express v27b1"
set the clipboard to txtReplace
Do Menu Macro with macro "Edit:Paste:Paste" --paste Replace text into Find dialog.


display dialog "Set \"Using\" popup to \"PowerFind Pro\"."
end tell
User avatar
martin
Official Nisus Person
Posts: 5230
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

It's not much help right now, but we're looking to make this easier to do using Express' built in Menu Macros (not AppleScript).
BFarr
Posts: 2
Joined: 2006-03-29 19:31:31

Future Release...

Post by BFarr »

Glad to hear it's being worked on. I was convinced to purchase based on everything else I've seen. I'll look for this in future updates.

Thanks,
Brandon

Mr. Stern, I've not had time to try your rec's yet, but will when time allows. Thanks.
Post Reply