Simple Keyboard Macro
Simple Keyboard Macro
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!
Thx!
Re: Simple Keyboard Macro
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
Pattern of sCommandURL:
vnd.sun.star.script:Library.Module.Routine?language=Basic&location=[application|document]
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
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 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
- kingfisher
- Volunteer
- Posts: 2123
- Joined: Tue Nov 20, 2007 10:53 am
Re: Simple Keyboard Macro
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.9 on Linux
- Bhikkhu Pesala
- Posts: 1253
- Joined: Mon Oct 08, 2007 1:27 am
Re: Simple Keyboard Macro
Try the free utility AutoHotkey
Idiot Compassion
LibreOffice 6.0.4 on Windows 10
LibreOffice 6.0.4 on Windows 10
Re: Simple Keyboard Macro
Bhikkhu - kingfisher uses Linux ...
- Bhikkhu Pesala
- Posts: 1253
- Joined: Mon Oct 08, 2007 1:27 am
Re: Simple Keyboard Macro
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
LibreOffice 6.0.4 on Windows 10
- kingfisher
- Volunteer
- Posts: 2123
- Joined: Tue Nov 20, 2007 10:53 am
Re: Simple Keyboard Macro
On further reflection, I think papafox wants a listener which will respond to CTRL + comma
Apache OpenOffice 4.1.9 on Linux
Re: Simple Keyboard Macro
This is what my macro does. When you run it against the current document Ctrl+, raises a message box "BINGO".kingfisher wrote:On further reflection, I think papafox wants a listener which will respond to CTRL + comma
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Simple Keyboard Macro
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.
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
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
My AutoHotKey script:
Ctrl & ,::
SetKeyDelay -1
Send {Blind}{Down DownTemp}
return
Ctrl & , up::
SetKeyDelay -1
Send {Blind}{Down Up}
return