Page 1 of 1
Simple Keyboard Macro
Posted: Thu Feb 28, 2008 12:50 am
by papafox
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!
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 1:25 am
by Villeroy
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
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]
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 3:04 am
by kingfisher
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.
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 8:46 am
by Bhikkhu Pesala
Try the free utility
AutoHotkey
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 9:46 am
by probe1
Bhikkhu - kingfisher uses Linux ...
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 10:11 am
by Bhikkhu Pesala
Kingfisher is not asking the question, and the OP hasn't told us what OS he/she is using.
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 11:32 am
by kingfisher
On further reflection, I think papafox wants a listener which will respond to CTRL + comma
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 1:04 pm
by Villeroy
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".
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 10:06 pm
by papafox
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.
Re: Simple Keyboard Macro
Posted: Thu Feb 28, 2008 11:29 pm
by papafox
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