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

Creating a macro - Writing a Script - Using the API

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

Postby p.cherevin » Sat May 18, 2019 8:00 pm

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)

Postby p.cherevin » Sat May 18, 2019 8:59 pm

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/viewtopic.php?p=55924#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)

Postby p.cherevin » Sat May 18, 2019 11:27 pm

Basic only

Code: Select all   Expand viewCollapse view
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
p.cherevin
 
Posts: 3
Joined: Sat May 18, 2019 7:17 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests