Using the Function Keys only with AdxKeyboardShortcuts (without Ctrl or Shift)

Add-in Express™ Support Service
That's what is more important than anything else

Using the Function Keys only with AdxKeyboardShortcuts (without Ctrl or Shift)
 
Peter Domke




Posts: 21
Joined: 2009-06-28
Hi Eugene,
thanks for the update. The FileSaveAs with id 748 is now catched. However, the F12 key still defaults to the standard behaviour and isn't catched by the ADX control. Since my client will stay with Office 2003 up to 2011, it would be great to have a solution for that sometimes.
Peter
Posted 29 May, 2010 07:36:43 Top
Peter Domke




Posts: 21
Joined: 2009-06-28
Hi Eugene,
I've stumbled about another problem, which may be connected.
During startup, in my old VBA-based add-in, I remove some Word shortcuts which are considered as not necessary or couterproductive. I ported the VBA code to the VS add-in in this way:


  Private Sub AddinModule_AddinStartupComplete(ByVal sender As Object, ByVal e As System.EventArgs) _
   Handles Me.AddinStartupComplete
        Call RemoveShortCuts()
    End Sub

    Private Sub RemoveShortCuts()
        Dim objWord As Microsoft.Office.Interop.Word.Application
        objWord = Me.HostApplication
        With objWord
            .CustomizationContext = .NormalTemplate
            '** Remove Ctrl+W (Close Document)
            .FindKey(KeyCode:=.BuildKeyCode(Word.WdKey.wdKeyControl, _
 X Word.WdKey.wdKeyW)).Disable()
            '** Remove Ctrl+K (Ins ert Hyperlink)
            .FindKey(KeyCode:=.BuildKeyCode(Word.WdKey.wdKeyControl, _
 X Word.WdKey.wdKeyK)).Disable()
        End With
    End Sub


This code works without error. Word starts fine, and the shortcuts are correctly removed. But IF YOU AUTOMATE WORD (e.g. from a VS application or from another Office application, it remains unvisible, even if you send Application.Visible = True.

You may check this in an Excel spreadsheet, to which you add a VBA module and this:

Sub test()
Dim w As Object
Se t w = CreateObject("Word.application")
w.Visible = True
End Sub

If you open the Windows Task Manager, you'll see WINWORD.EXE in memory, but not visible.
Tested with Office 2003 and Windows XP.

If you remove the KeyBindings call and recompile the add-in, all works fine.

Any ideas, how the Add-in Express runtime can effect this behavior?
Kind regards
Peter
Posted 29 May, 2010 16:06:42 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Peter,

The point is that F12 is used in Word for calling the Save As dialog. That is why Add-in Express cannot intercept it.

As for the other problem with the Visible property, we have not tested it yet that is why I cannot say how Add-in Express runtime can affect the behavior. Can you reproduce that issue with a VSTO based add-in?
.NET, Extended MAPI, Windows Phone & RT
Posted 31 May, 2010 11:46:16 Top
Peter Domke




Posts: 21
Joined: 2009-06-28
Hi Eugene,

as for the Visible property: I removed/unregistered my Adx add-in and created a basic VSTO Word add-in. Here, the subroutine to remove the key bindings is called in the ThisAddin_Startup procedure. Same effect if I automate Word from Excel, i.e. the Word process remains invisible after startup. So it seems really to be a bug in the Word environment undependently from the loader used.
I know that a common way to circumvent the KeyBindings problem in Word is to deliver - together with the COM add-in - a Word global DOT template to the startup folder, in which VBA code captures the keys and hooks them to commandbarbuttons. I've seen this solution already in the time of VB6 COM add-ins. However, since ADX supports the capture of shortcuts, I hoped that I don't need to recurr to this workaround.

Which leads me to your comment on F12: I don't understand exactly what you mean with
The point is that F12 is used in Word for calling the Save As dialog. That is why Add-in Express cannot intercept it.

because other keys, e.g. Ctrl+F12, are intercepted by Word too (Ctrl+F12 = FileOpen). In my understanding the Adx Keyboard Shortcuts are a tool to overwrite the application settings, so if you can overwrite Ctrl+F12, why not F12 itself?

Best regards
Peter
Posted 01 Jun, 2010 02:04:32 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Peter,

You can set F12 for the ShortcutText property of the AddinExpress.MSO.ADXKeyboardShortcut component manually (I typed F12 instead of selecting it from the drop down list in the Properties window of Visual Studio). Just tested it on my PC - it works as expected!

Please try the same and let me know if it worked for you.
.NET, Extended MAPI, Windows Phone & RT
Posted 01 Jun, 2010 11:24:44 Top
Peter Domke




Posts: 21
Joined: 2009-06-28
Hi Eugene,
thanks very much! That's the solution.
I'd never guessed that the text in the property field was editable, however, it's written in the manual p.103:
Then, in the Properties window for the Keyboard Shortcut component, you choose (or enter) the desired shortcut in the ShortcutText property.


I'm glad that we've found a solution, after some difficulties. I think we can close this discussion.
I appreciate your services.

Kind regards
Peter Domke
Posted 01 Jun, 2010 13:49:50 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
You are welcome, Peter :-)
.NET, Extended MAPI, Windows Phone & RT
Posted 02 Jun, 2010 03:48:34 Top