Is it possible to override Excel keyboard shortcuts inside a custom task pane?
For instance I would like to capture the shortcut Ctrl+Space, but Excel already uses that shortcut inside a custom task pane, and the shortcut never reaches the KeyPressed event handler on my user control.
Other key combinations that Excel doesn't use reach my event handler just fine.
Is there a way to override this, maybe via the Windows API?
You can use the SetWindowsHookEx function from Windows API to set up a keyboard hook. But overriding the built-in keyboard shortcut is not a good idea. Anyway, you can read more about this and find a sample code in the Using shortcut keys to call a function in an Office Add-in article.
Related
I am very new to MFC. I am having following code for Copy and SelectAll shortcuts for CRichEditCtrl object.
ON_COMMAND(ID_EDIT_COPY, OnCopy)
ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
But I am not able to catch breakpoint for Copy (Ctrl+C) and SelectAll (Ctrl+A) in the functions which I wrote here as It is not getting executed.
Here CRichEditCtrl object is read only(Text is for read and not allowed to modified).
I also want to provide functionality of Text Selection with Mouse for CRichEditCtrl object.
Any idea on How to achieve this?
This actions are not executed with a WM_COMMAND value we know. Also the keystrokes are checked internally and handled internally.
Internally there are special window messages named WM_COPY and WM_PASTE for some actions that interact with the clipboard.
Afaik the selection (Select all) is done completely internal. you can try to subclass the RTF control and intercept the EM_SETSEL message.
If you want to intercept the keystrokes you can use PreTranslateMessage or you can again subclass the RTF control.
I know Visual Studio has a Command system for creating custom keyboard shortcuts. Is there anything similar for Excel?
Is there a way to access the collection(s) of possible 'actions', including those that can be triggered by keyboard shortcuts or menu items? And if so, are there any events for detecting them?
The purpose of the add-in is to track excel feature usage, preferably including activation time and context, and whether or not the user activated it via keyboard or a menu.
I have one MFC Application. there is one CBUTTON. I had write code create CDialog on CBUTTON click. If i am use DOMODAL method for creating cdialog then keyboard tab working fine but if i am use CREATE method then keyboard tab not working.
You probably are not calling the IsDialogMessage, which is required to ensure that modeless dialog boxes process keyboard input correctly.
This is not necessary with modal dialogs (i.e., those created by calling the DoModal method) because Windows handles it internally.
This doesn't make much sense as an explanation, though, because you're using MFC, which should ensure that IsDialogMessage is called in the message loop for modeless dialogs. That's the whole point of using a framework: it keeps you from forgetting details like this. I can't guess why it isn't working like it should for you; you didn't show us any code. Note that the Visual Studio wizards write the correct code for you automatically. It's recommended that you use them when adding new dialogs to your app.
Joseph Newcomer's article on Creating a Modeless Dialog Box with MFC might be helpful reading.
Because I like to make common actions quick to access, I'd like to define a hotkey, e.g. Alt+L to do "reply to all with history", to act on the selected email. I'm using Lotus Notes 8.5 under Windows. Currently I have to either click the Reply button and then click "Reply to All with History Only" or I have to press Alt+3 then cursor down several times and press enter. Actually, Alt+3 doesn't always work because if the email is opened in its own window then you have to use Alt+2.
I've pursued several solutions:
o I've looked for consistent hotkeys within Lotus Notes, but no luck. The shortcut key support in Lotus Notes is not very good, and you can't define custom shortcut keys.
o I've tried using AutoHotkey to send keystrokes to Lotus. You can do a reply by typing Alt+A to get to the Actions menu. Unfortunately, the accelerator keys underneath the Actions menu change whether you are in the email list or if the email is in its own window. Also, the Actions menu doesn't always drop down quickly, so timing the sent keystrokes is problematic.
o I've tried writing LotusScript Agents to do a reply all. I've learned there is a Shared Action named "Reply to All\Reply to All with History Only". I don't think there is a way to have an Agent call an existing Shared Action, so I guess I can just clone the Shared Action code into my Agent. That still leaves the problem of invoking the Agent via a hotkey.
o I haven't tried it yet, but I think the solution will be to create an Agent that can perform a reply all. Create a VBS script to use the Lotus Notes OLE/COM interface to invoke the agent then have AutoHotkey call the VBS file when a hotkey is pressed. FYI: AutoHotkey doesn't support COM directly. However AutoIt and I believe AutoHotkey_L do support both COM and hotkeys so I could use one of those languages.
I'm open to any suggestions, but I want a solution that is reliable. As mentioned, my current AutoHotkey solution fails sometimes because the Lotus GUI is not a very standard Windows GUI. As I understand it, the Lotus GUI is a Java/Eclipse application. I believe Lotus supports Eclipse plugins, so maybe that is an option.
I started with:
#IfWinActive Mail - Inbox - IBM Lotus Notes
!l:: Send {Alt}ayr
!r:: Send {Alt}ape
return
But have also included:
#IfWinActive ahk_class SWT_Window0
!l:: Send {Alt}ayr
!r:: Send {Alt}ape
!1::
!S:: Send !1
return
The above is to facilitate usage of the shortcuts even in mails with its own window... where the title text is diff. Hope it helps!
Here are the AutoHotkey shortcuts that I created, which are similar to those mentioned above. I used the hotkeys that I remember from outlook as a basis for them:
IfWinActive, IBM Lotus Notes
{
#IfWinActive New Message
{
^Enter::
SendInput, !1
return
}
#IfWinActive, Inbox
{
^r::
SendInput, !C+E
return
^+r::
SendInput, !A+Y+R
return
}
}
I'm using Notes 8.5, btw.
You might be able to make your life easier with a custom smarticon (toolbar button). I don't have 8.5 to test this on, but it works on Notes 6.
Go into the design view of the mail database, and open up the memo form. Then look for the action button you are trying to duplicate. Copy all the formula code (probably just a few lines). Then create a new toolbar button by right-clicking on a toolbar and choosing Toolbar properties. Paste the formula into the button and save.
This still doesn't get you the shortcut key trigger you're looking for, but perhaps in 8.5 you can assign a hotkey to a toolbar icon? If not, you could create an AutoHotKey script, triggered by a hotkey you choose, that simulates clicking the smarticon button using references relative to the current window. I think it would be consistent provided the toolbar is always in the same place.
Using the helpful "Alt a-y-r" approach above, I just wrote a tiny little AutoHotkey script to map alt+r and alt+l to the common usages:
#IfWinActive Mail - Inbox - IBM Lotus Notes
!l:: Send {Alt}ayr
!r:: Send {Alt}ape
return
Basic, but it works for 90% of my uses. I'm going to create hotkeys for everything using this method.
The obvious way is to press "ALT-A-Y-R" (reply to all with history) or "ALT-A-Y-E" (reply to all with history + attachments).
Pressing ALT-A will show you the hotkeys for each menu option on the Action menu. Might be different character if you are not using the English version.
I found myself here adapting from Outlook's Ctrl+R and Ctrl+Shift+R to reply or reply to all and looking for a way to reply to an email with a sensible number of key presses.
I found that by clicking File > Preferences, there is an option called:
Enable alternate keyboard shortcuts (for example Ctrl+R=Reply)
That solved most of my issue. Using Notes 9.
My problem is very simple, but implementation can be hard!
I want that my application (Windows Application:: Visual C# .net) is launched whenever the user uses some keys combinations (on his keyboard).
For example it types Ctrl+W+W and my application is launched, that's all, I want the simplest implementation, less code, memory...
Thanks :D
You would need to write a keylogger type application in conjunction with your app which monitors for keyboard events. Once your specific shortcut is triggered you could then load your application.
See here for information on how to capture keystrokes.
Create a shortcut to the application, and assign a hot-key combination to the shortcut. Depending on the O/S, not every keystroke combination can be assigned to a shortcut, e.g. you may be able to assign Ctrl+Alt+W but not Ctrl+W+W.
On Windows, you can create a shortcut (on the desktop) to your application.
When you open the properties of the shortcut, on the second tab (labeled "Shortcut"), you can assign a shortcut key. But you can use only Ctrl+Alt+key shortcuts.
I don't think this is possible in the way that you framed this question. What is possible, however, is to have your application run automatically on startup without showing any forms, have it hook into Windows to monitor all keystrokes (I'm not sure how to do that part, exactly) and then show a form when the user presses a particular sequence of keys.
So in other words, your application would have to be running from the time Windows starts, but only show itself (make a form visible) when the user clicks a particular key sequence.
Update: here is a link to an article that discusses how to do global keystroke capture using C#: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx.