[Solved] Macro to switch "mouse as pen" in Impress

Creating a macro - Writing a Script - Using the API

[Solved] Macro to switch "mouse as pen" in Impress

Postby Deemar » Sat Mar 23, 2013 12:15 am

I'm looking for some sort of way to be able to turn the mouse as pen feature on or off in the middle of an Impress presentation. The method of using right click and selecting from the menu is undesirable, I'd prefer to do it another way. Does this macro exist somewhere already? Should I write it instead?

If I do have to write it I have a couple of questions. Do I need to write it in the macro generator or would I write it in a separate program and then run that program externally? Do I do this by importing the UNO API into Eclipse? I'm totally confused how this works, thanks.
Last edited by Hagar Delest on Tue Mar 26, 2013 12:54 am, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 3.1 on Windows Vista / NeoOffice 2.2.3 with MacOS 10.4 / OpenOffice 2.4 on Ubuntu 9.04
Deemar
 
Posts: 3
Joined: Sat Mar 23, 2013 12:10 am

Re: Looking for a macro to switch "mouse as pen" in Impress

Postby hanya » Sat Mar 23, 2013 5:38 am

Hi,
Code: Select all   Expand viewCollapse view
Sub SwitchToUsePen
  oController = ThisComponent.getPresentation().getController()
  If NOT IsNull( oController ) Then
    b = NOT oController.UsePen
    oController.UsePen = b
    If b Then
      oController.PenColor = RGB(0, 255, 0)
    End If
  End If
End Sub

Store this code into Basic library and assign it to key combination.
I wonder is there any way to change line width of pen through API.
 Edit: Unused line was removed. No API is there, simply the attribute PenWidth is not exported through the API. 
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Looking for a macro to switch "mouse as pen" in Impress

Postby Deemar » Mon Mar 25, 2013 10:27 pm

Thank you, that code worked great except in order to use it, I need to right click and select 'mouse as pen' to get the pen out. Then my keyboard shortcut (CTRL+h) for the macro works perfect. It switches the pen on and off with ease. However I do have to right click and select that option before it works. Is there another line of code to add in order to switch it on without having to do that?
OpenOffice 3.1 on Windows Vista / NeoOffice 2.2.3 with MacOS 10.4 / OpenOffice 2.4 on Ubuntu 9.04
Deemar
 
Posts: 3
Joined: Sat Mar 23, 2013 12:10 am

Re: Looking for a macro to switch "mouse as pen" in Impress

Postby Deemar » Mon Mar 25, 2013 11:09 pm

I got it, I just needed to click the slideshow to select the window. For some reason the slideshow isn't the focused window when it starts, you need to click it first. Weird.
From searching around the internet before this, I suspect there will be quite a few people finding this thread in a search and benefiting from your code. Thanks!
OpenOffice 3.1 on Windows Vista / NeoOffice 2.2.3 with MacOS 10.4 / OpenOffice 2.4 on Ubuntu 9.04
Deemar
 
Posts: 3
Joined: Sat Mar 23, 2013 12:10 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests