Simple Keyboard Macro

Creating a macro - Writing a Script - Using the API

Simple Keyboard Macro

Postby papafox » Thu Feb 28, 2008 12:50 am

I wish to create a simple macro in writer for a key combination which is not supported by "customize keyboard". My goal is to move the cursor down one line by using the combination of the "Control" and "," keys. I know I can create the simple macro, but can I assign it to this key combination, and how do I do that?
Thx!
papafox
 
Posts: 6
Joined: Thu Feb 28, 2008 12:00 am

Re: Simple Keyboard Macro

Postby Villeroy » Thu Feb 28, 2008 1:25 am

The old forum is the best source of OOo code snippets:
http://www.oooforum.org/forum/viewtopic ... t=shortcut

referring to this interface:
http://api.openoffice.org/docs/common/r ... etKeyEvent
and these constant groups:
http://api.openoffice.org/docs/common/r ... t/Key.html
http://api.openoffice.org/docs/common/r ... ifier.html

 Edit: Since "simple macros" are impossible with this API 

Code: Select all   Expand viewCollapse view
Sub SetCtrlComma()
'Thanks to Carsten Driesner, Frank Sch�nheit, Paolo and ms777
Dim aKeyEvent As New com.sun.star.awt.KeyEvent
   sCommandURL = "vnd.sun.star.script:Standard.test_.CROAK?language=Basic&location=application"
   oDocCfgMgr = ThisComponent.getUIConfigurationManager()
   oShortCutManager = oDocCfgMgr.GetShortCutManager()
   With aKeyEvent
      .Modifiers = com.sun.star.awt.KeyModifier.MOD1
      .KeyCode = com.sun.star.awt.Key.COMMA
   End With
   oShortCutManager.setKeyEvent(aKeyEvent, sCommandURL)
   oDocCfgMgr.store()
End Sub
Sub CROAK
   Msgbox "BINGO"
End Sub

Pattern of sCommandURL:
vnd.sun.star.script:Library.Module.Routine?language=Basic&location=[application|document]
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27098
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Simple Keyboard Macro

Postby kingfisher » Thu Feb 28, 2008 3:04 am

On my version, it is not possible to assign CTRL + , It's a case of using the listed key bindings. You can probably move the cell pointer down just by using the down-arrow key.
Apache OpenOffice 4.1.6 on PCLinuxOS
User avatar
kingfisher
Volunteer
 
Posts: 2120
Joined: Tue Nov 20, 2007 10:53 am

Re: Simple Keyboard Macro

Postby Bhikkhu Pesala » Thu Feb 28, 2008 8:46 am

Try the free utility AutoHotkey
Idiot Compassion
LibreOffice 6.0.4 on Windows 10
User avatar
Bhikkhu Pesala
 
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

Re: Simple Keyboard Macro

Postby probe1 » Thu Feb 28, 2008 9:46 am

Bhikkhu - kingfisher uses Linux ...
Cheers
Winfried

DateTime2 extension: insert date, time or timestamp, formatted to your needs
User avatar
probe1
Volunteer
 
Posts: 277
Joined: Mon Oct 08, 2007 1:34 am
Location: Chonburi Thailand

Re: Simple Keyboard Macro

Postby Bhikkhu Pesala » Thu Feb 28, 2008 10:11 am

Kingfisher is not asking the question, and the OP hasn't told us what OS he/she is using.
Idiot Compassion
LibreOffice 6.0.4 on Windows 10
User avatar
Bhikkhu Pesala
 
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

Re: Simple Keyboard Macro

Postby kingfisher » Thu Feb 28, 2008 11:32 am

On further reflection, I think papafox wants a listener which will respond to CTRL + comma
Apache OpenOffice 4.1.6 on PCLinuxOS
User avatar
kingfisher
Volunteer
 
Posts: 2120
Joined: Tue Nov 20, 2007 10:53 am

Re: Simple Keyboard Macro

Postby Villeroy » Thu Feb 28, 2008 1:04 pm

kingfisher wrote:On further reflection, I think papafox wants a listener which will respond to CTRL + comma

This is what my macro does. When you run it against the current document Ctrl+, raises a message box "BINGO".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27098
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Simple Keyboard Macro

Postby papafox » Thu Feb 28, 2008 10:06 pm

Thanks for the quick responses!
I'm using Windows Vista 32 and need to create a keyboard shortcut so that when using writer the cursor moves down one line when I hit the Ctrl and "," keys. I have used this macro before in other programs and find it quicker than using a mouse to move the cursor in most instances. Although I'm not a programmer I am capable of using logic and will study your various responses to see if one suits my needs.
papafox
 
Posts: 6
Joined: Thu Feb 28, 2008 12:00 am

Re: Simple Keyboard Macro

Postby papafox » Thu Feb 28, 2008 11:29 pm

I've tried the AutoHotKey program as Bhikkhu Pesala suggested, and was able to construct a script that produces no error messages, but when I hit the "Ctrl" and the "," keys, Writer and another word processor I use respond as if I've hit the "Ctrl" and the "down arrow" keys together, rather than just the down arrow key. So, I'm still looking for a more elegant solution. Thanks all for efforts so far.
My AutoHotKey script:

Ctrl & ,::
SetKeyDelay -1
Send {Blind}{Down DownTemp}
return

Ctrl & , up::
SetKeyDelay -1
Send {Blind}{Down Up}
return
papafox
 
Posts: 6
Joined: Thu Feb 28, 2008 12:00 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 2 guests