Page 1 of 1
[Solved] Basic command for some shortcut keys (Calc)
Posted: Sat May 18, 2019 8:00 pm
by p.cherevin
Please tell me what are the macros commands for the shortcut keys (calc):
1. Cell edit mode (F2)
2. Overwrite Mode (Insert)
Thank you.
Re: Basic command for some shortcut keys (calc)
Posted: Sat May 18, 2019 8:59 pm
by p.cherevin
Found the answer myself
1. Cell edit mode (F2)
dispatcher.executeDispatch(document, ".uno:SetInputMode", "", 0, Array())
2. Overwrite Mode (Insert)
Thanks to google translate and fornelasa
https://forum.openoffice.org/es/forum/v ... 924#p55924
Re: [Solved] Basic command for some shortcut keys (Calc)
Posted: Sat May 18, 2019 11:27 pm
by p.cherevin
Basic only
Code: Select all
Sub TEST3
REM Simulate a RETURN Key press ( and -release ) in the current Window.
REM NB. This can cause the triggering of window elements.
Dim oKeyEvent As New com.sun.star.awt.KeyEvent
oKeyEvent.Modifiers = 0 REM A combination of com.sun.star.awt.KeyModifier.
oKeyEvent.KeyCode = com.sun.star.awt.Key.F2 REM 1280.
oKeyEvent.KeyChar = chr(0)
simulate_KeyPress( oKeyEvent )
oKeyEvent.Modifiers = 0 REM A combination of com.sun.star.awt.KeyModifier.
oKeyEvent.KeyCode = com.sun.star.awt.Key.INSERT REM 1280.
oKeyEvent.KeyChar = chr(0)
simulate_KeyPress( oKeyEvent )
oKeyEvent.Modifiers = 0 REM A combination of com.sun.star.awt.KeyModifier.
oKeyEvent.KeyCode = com.sun.star.awt.Key.HOME REM 1280.
oKeyEvent.KeyChar = chr(0)
simulate_KeyPress( oKeyEvent )
oKeyEvent.Modifiers = 2 REM A combination of com.sun.star.awt.KeyModifier.
oKeyEvent.KeyCode = com.sun.star.awt.Key.RIGHT REM 1280.
oKeyEvent.KeyChar = chr(0)
simulate_KeyPress( oKeyEvent )
End Sub
Sub simulate_KeyPress( oKeyEvent As com.sun.star.awt.KeyEvent )
REM Simulate a Key press ( and -release ) in the current Window.
REM NB. This can cause the triggering of window elements.
REM For example if there is a button currently selected in your form, and you call this method
REM while passing the KeyEvent for RETURN, then that button will be activated.
If Not IsNull( oKeyEvent ) Then
Dim oWindow As Object, oToolkit As Object
oWindow = ThisComponent.CurrentController.Frame.getContainerWindow()
oKeyEvent.Source = oWindow
oToolkit = oWindow.getToolkit() REM com.sun.star.awt.Toolkit
oToolkit.keyPress( oKeyEvent ) REM methods of XToolkitRobot.
rem oToolkit.keyRelease( oKeyEvent )
End If
End Sub