How to bind _special_ shortcut keys to a Command programmatically?
From: msnews.microsoft.com (-_at_hotmail.com)
Date: 08/21/04
- Previous message: msnews.microsoft.com: "Re: How to add a _built-in_ Command to a CommandBar programmatically?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 21 Aug 2004 13:16:35 +0200
Hi,
I would like to write a short macro, which programmatically sets some of my
favorite Command shortcut keys.
What I figured out that it can be done via assignment to Command object's
Bindings array property.
For example if I want to assign 'Ctrl + D' to Edit.GotoDefinition command I
execute the following program code:
DTE.Commands.Item("Edit.GoToDefinition").Bindings = New Object()
{"Global::Ctrl+D"}
...and it works properly.
The problem is that I have two "ezoteric" favorite Shortcut key:
1) Ctrl + Num + ( The second plus means the plus on numeric keypad.)
2) Ctrl + 5 (This is the five key on numeric keypad, with _num lock off_)
Note, that both assignments can be done with no problem interactively in the
user interface, I've been using them for years.
Theese two keys introduce similar, but a little different problem.
Both end with 'Invalid parameter' error message.
When we inspect 1) it seems to be the second '+' sign fools the parser
algorithm.
But what is the expected syntax in this case?
The 2) is more complicated. The full story is that if I set this key
interactively, it works, but the user interface displays
not 'Ctrl + 5' but 'Ctrl +'.
Also if I inspect the Commands Bindigs array with a debugger after this
interactive setting, I can see a one element string array, and the first
element's value is "Ctrl +".
Of course trying to execute the
DTE.Commands.Item("Edit.ToggleOutliningExpansion").Bindings = New Object()
{"Text Editor::Ctrl+"}
leads to an error message.
Q: How can I assign this two key programmatically?
Q': The problem is not only about this two keys. The main problem is, that
inspecting and saving the Command's Binding array content, and later
restoring this values does not work in some cases because the Bindings does
not accept the original found values:
Two sample:
'Global::Ctrl+Num +"
or
"Text Editor::Ctrl+"
Any idea?
thx for help
- Previous message: msnews.microsoft.com: "Re: How to add a _built-in_ Command to a CommandBar programmatically?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|