Hal Vaughan wrote:
I recorded a macro to select text, copy it to the keyboard, then to enter a new character. In the long run, I'm going to want a macro that selects the character before the cursor, then reads in that character so I can use it to compare to something else. When I'm done, I'd delete that character from the text, then enter in new text.

It'd work like autotext, but it'd also let me call another macro along the way, since there's a bug (as mentioned in another thread) in autotext that doesn't let you bind macros to it.

I'm using the code below to select the one character and copy it to the keyboard, then enter in another keypress. I've got a couple questions:

1) This all uses dispatch statements. I remember there were some issues with this previously, but that may have been with slot numbers or something like that. Am I safe writing my macro to dispatch commands, or will that get outdated? This will always be used from the keyboard, so there's no issue with the UI not being in use when I do this.

2) Once I've selected a character (or more text) or copied it to the clipboard, how can I read what that character is? I've looked at Andrew's Macro document, but I'm still putting all that info together and it uses objects, not the dispatcher. Is there a quick way, in Basic, to dump the selected text into a string?

Thanks for any help on this!


Hal
-----------------
rem Code for above discussion:

dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Count"
args1(0).Value = 1
args1(1).Name = "Select"
args1(1).Value = true

dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args1())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Text"
args3(0).Value = ":"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args3())

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
with te folowing dispacht code I place a graphic(who is in the clipboard) at the current cursor position,, same when you have text in the clibboard


dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())


hop it helps

Fernand

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to