| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Paste text into console
Hi all:
I'm trying to paste a string into win32 cmd console for which I have the window handle. My issue is I can't send a sequence of keys with WM_KEYDOWN/CHAR/UP SendMessage()s and the console won't respond to a WM_PASTE. I've got the data into a global buffer on the clipboard (shows up in the MS Word viewer), but I'm not sure how to paste it into the console. I'd like to be able to do my usual SetWindowLong(GWL_WNDPROC) to figure out the messages sent to the console when I r-click and say 'Paste' from the pop-up menu, but a GetWindowLong(GWL_WNDPROC) returns 0 and any SetWindowHookEx()s never get any info. I assume the cmd console has some funky msgproc system, but I don't know it. I unfortunately am using Vis Studio Express and don't have access to Spy++ *cry* If anyone does have Spy++ and can post the sequence of msgs sent to a command prompt when they do a pop-up menu Paste, I'd really appreciate. Or some less clunky solution. Thanks in advance for your help. sulu |
|
#2
|
|||
|
|||
|
Re: Paste text into console
As far as I know, a command prompt "window" has no message pump. I imagine Windows does some trickery to get a menu and to select, cut, paste, etc. but without a message pump, there's nothing for spy++ to spy on. Spy++ properties show no menus or child windows associated with the "window". I'm afraid you'll have to try something else (of which I have no idea).
|
|
#4
|
|||
|
|||
|
Re: Paste text into console
__________________
Vlad - MS MVP [2007 - 2010] - www.FeinSoftware.com Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more... |
|
#5
|
|||
|
|||
|
Re: Paste text into console
I don’t have an answer, but would like to offer a suggestion.
Since we are talking about modified system menu, I would assume that the message is WM_SYSCOMMAND. Windows uses values 0xF000 to 0xF180; Wizard-generated code uses 0x0010 for a sample IDM_ABOUTBOX. Please note that the last digit must be 0. I would write a loop to bombard that CMD wndow with WM_SYSCOMMAND messages (with various wParam values) to see if anything will get pasted.
__________________
Vlad - MS MVP [2007 - 2010] - www.FeinSoftware.com Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more... |
|
#6
|
|||
|
|||
|
Re: Paste text into console
Skizmo: thanks for the link. I've actually been using that one, but, as far as I can tell, it doesn't have the ability to log messages going to a window, just displays the window's info. I appreciate it tho.
hoxsiew: I was afraid you were gonna say that. At least I'm not crazy =P VladimirF: Great advice. I'll try the WM_COMMAND bombard suggestion today. There's just something about bombarding Microsoft crap that makes a guy feel all warm and fuzzy. Will post if I find something out. sulu |
|
#7
|
|||
|
|||
|
Re: Paste text into console
Use SendInput()
A console does not have a messageloop (it sort of does, but for normal purposes it doesn't), so trying to make it respond to any type of message won't work. |
|
#8
|
|||
|
|||
|
Re: Paste text into console
FYI to all who are wondering:
To paste the clipboard to console window SendMessage(hConsoleWnd, WM_COMMAND, 0xFFF1, 0); The other popup menu commands are right around that. Vlad: I used your suggestion and just sent every wParam from 0x0000 to 0xFFFF, with a printf to see what wParam I was on when the paste appeared in the console. Luckily the next wParam is the 'Mark' menu command which stops the program from processing =) Thanks again all for the help. sulu |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|