How to capture what user is typing
-
Since you are wanting to receive notifications that something has happened you’d want to use the
beNotified()function instead ofmessageProc().That being said you won’t receive
WM_KEYDOWNnotifications. Those are handled by Notepad++/Scintilla. What you normally do is catch notifications from Scintilla that tells you the user has added (or removed) text by catching the SCN_MODIFIED notification which has the info you need (e.g. position, text). You can also catch SCN_MODIFYATTEMPTRO which tells you a read-only document was attempted to be modified…but I don’t believe this notification tells you what was actually attempted.If indeed you are actually needing the raw
WM_KEYDOWNnotifications there are ways of subclassing (superclassing?) the Notepad++ window and catching them before Notepad++ does…but that is beyond by Win32 API knowledge, but I do know some plugins do that. -
Thanks,
I already got notified. but the
notifyCode->chis always equals to0Can you please help to explain how can I check what user is typed?
-
You should read the documentation on those notifications.
SCN_MODIFIEDdoes not use thechfield, it uses thetextfield because the user could paste multiple characters (or delete a range of text).If indeed you do want individual characters only (and skip any paste/deletes) then you can catch
SCN_CHARADDEDnotifications which does usech. -
I want to be notified when user typed “backspace”, but maybe VK_BACK is the not correct value. or maybe it was not captured in SCN_MODIFIED/CHARADDED. any recommendation?
-
SCN_MODIFIEDdoes tell you when a character (or range of characters) is deleted, but not necessarily due to the backspace key. ThemodificationTypewill have theSC_MOD_DELETETEXTflag set.If you are needing to capture actual keyboard input and not just changes to the text document then you’ll have to go the subclassing/superclassing route.
-
Yes,
theBACKSPACEwill trigger the notification withSC_MOD_DELETETEXTbit in the modificationType. Thanks.I got another question.
Currently I bind the hotkey with the function using the menu. But is it possible to hide the menu or is there any another to link the hotkey and func? -
No it is only possible using the
FuncItemstructwhich requires a hotkey.Edit: Actually it doesn’t require a hotkey, however the struct is the only way to register functions with Notepad++…which automatically show up in the menu.
-
How to response the VK_ESCAPE? currently I am binding the ESC on the menu command, it works. but I was wondering whether I can filter the VK_ESCAPE somewhere or I can dynamically bind it as a hotkey for a function.
-
As far as I know you can’t dynamically bind shortcuts.
-
Hi Dali,
I was trying to intercept the user typing by receiving the notification when editor is read-only, so far, it works good. but read-only editor is not an ultimate solution, I wondering is there any way to ignore the key press on the editor and interact with the key pressing?
Regards, -
I’m not sure. I’m not saying it is impossible though, just don’t know how.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login