[Solved] Basic command for some shortcut keys (Calc)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
p.cherevin
Posts: 3
Joined: Sat May 18, 2019 7:17 pm

[Solved] Basic command for some shortcut keys (Calc)

Post 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.
Last edited by Hagar Delest on Sat May 18, 2019 10:43 pm, edited 1 time in total.
Reason: tagged solved
OpenOffice 4.1.6
Windows 7 x64
p.cherevin
Posts: 3
Joined: Sat May 18, 2019 7:17 pm

Re: Basic command for some shortcut keys (calc)

Post 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
OpenOffice 4.1.6
Windows 7 x64
p.cherevin
Posts: 3
Joined: Sat May 18, 2019 7:17 pm

Re: [Solved] Basic command for some shortcut keys (Calc)

Post 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
OpenOffice 4.1.6
Windows 7 x64
Post Reply