I write an add-in for word in c#.
I want to hook keyboard and catch ctrl-c and read text copied to clipboard.
My add-in could found ctrl-c by using code below,
//C# code:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
.
.
.
Application.KeyBindings.Add(Word.WdKeyCategory.wdKeyCategoryCommand, "KeyCode1",
Application.BuildKeyCode(Word.WdKey.wdKeyControl , Word.WdKey.wdKeyAlt , Word.WdKey.wdKeyD));
}
public void CallKey(int i)
{
switch (i)
{
case 1:
MessageBox.Show("Ctrl+C");
break;
}
}
//VBA code:
Function GetAddin() As Object
On Error Resume Next
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns(“WordKeyBinding”)
Set automationObject = addIn.Object
Set GetAddin = automationObject
End Function
Public Sub KeyCode1()
On Error Resume Next
GetAddin.CallKey 1
End Sub
Now my problem is when I press ctrl-c, the message box is displayed but nothing copy to clipboard! what should I do?