Hi all,
do you know any funciton in Ms word for key press?
Regards,
thirith.
Printable View
Hi all,
do you know any funciton in Ms word for key press?
Regards,
thirith.
Without api, the unreliable SendKeys Method:
VB Code:
Option Explicit Sub SendKeysMethod() SendKeys "H", True SendKeys "E", True SendKeys "L", True SendKeys "L", True SendKeys "O", True End Sub
thanks,Quote:
Originally Posted by JustinLabenne
i mean when user type any text in the word document.
can we get the character of press in the documents?
With the API it is either SendMessage, PostMessage, or Keybd_event APIs. ;)
If you want to simulate a keypress you can also just use the TypeText method. ;)
Oh, ok. Then you can create an event and trap for any changes or do a keyboard hook but it would only have to be hooking while word is the active app. ;)
Could you please give me some example code for me?Quote:
Originally Posted by RobDog888
I dont think I can give an example because its a bit involved and I am talking in logic only.
GetAsyncKeyState API will do a global hook on the keyboard. For each keypress you would need to get the actie application and see if its word, but then they could be pressing a shortcut key sequence like for saving copy/paste that might not result in a document change.
What exactly are you trying to do as there may be a better solution to this.? ;)