Click here to Skip to main content
15,900,254 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
But can't send "Ctrl + N" key
Can anyone help me? I need to send the key without focus

What I have tried:

VB
PostMessage (hwnd, WM_SYSKEYDOWN, Keys.F, 2 ^ 29) 'Working - Alt + F
PostMessage (hwnd, WM_CHAR, Keys.A, & H1C0001) 'Working - Shift + a = A
PostMessage(hwnd, WM_KEYDOWN, VK_CONTROL, vbNull) '4 Not working
PostMessage(hwnd, WM_KEYDOWN, Keys.N, vbNull)
PostMessage(hwnd, WM_KEYUP, Keys.N, vbNull)
PostMessage(hwnd, WM_KEYUP, VK_CONTROL, vbNull)
Posted
Updated 21-Mar-19 21:32pm
v2
Comments
[no name] 21-Mar-19 11:55am    
Why didn't you show the codes you used for "CTRL + N"? Wasn't that the question?
[no name] 21-Mar-19 12:41pm    
Maciej Los 21-Mar-19 18:51pm    
Sounds like an answer.
5ed!
[no name] 21-Mar-19 19:01pm    
Dear Maciej
Ok I try it. Even it was a lucky google shot :)
Thank you for pushing me on that ;)
Bruno
Maciej Los 21-Mar-19 19:09pm    
You're very welcome.
Cheers!
Maciej

See here: c# - Sending CTRL-S message to a window - Stack Overflow[^]

What I understand from the accepted answer is, to send "Ctrl&key" messages (and most probably also "shift&key" etc. you can not use PostMessage.

Therefore check accepted answer, it looks promising for you.

I hope it helps.
 
Share this answer
 
v2
Comments
Maciej Los 21-Mar-19 19:08pm    
5ed!
[no name] 21-Mar-19 19:08pm    
Thank you very much!
Bruno
I'm not a follower of such of programming...

I'd recommend to use standard methods to read/write text files. See:
Reading from Files in Visual Basic | Microsoft Docs[^]
Writing to Files in Visual Basic | Microsoft Docs[^]
Manipulating Files by Using .NET Framework Methods (Visual Basic) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900