CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Building Interactive UIs with ASP.NET Ajax: Rebinding Client-Side Events After a Partial Page Postback
  • Speed Up Repetitive Insert, Update, and Delete Query Statements
  • Binding Data to Silverlight 4.0 Controls Using ASP.NET MVC Framework 2.0
  • ADO.NET Data Services in the .NET Framework

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old December 8th, 2009, 03:06 PM
    mister_sulu mister_sulu is offline
    Junior Member
     
    Join Date: Dec 2009
    Posts: 3
    mister_sulu is an unknown quantity at this point (<10)
    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
    Reply With Quote
      #2    
    Old December 8th, 2009, 03:49 PM
    hoxsiew hoxsiew is offline
    Elite Member
     
    Join Date: Feb 2005
    Posts: 2,112
    hoxsiew is a glorious beacon of light (400+)hoxsiew is a glorious beacon of light (400+)hoxsiew is a glorious beacon of light (400+)hoxsiew is a glorious beacon of light (400+)hoxsiew is a glorious beacon of light (400+)hoxsiew is a glorious beacon of light (400+)
    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).
    Reply With Quote
      #3    
    Old December 8th, 2009, 04:11 PM
    Skizmo's Avatar
    Skizmo Skizmo is online now
    Elite Member
     
    Join Date: Sep 2004
    Location: Holland (land of the dope)
    Posts: 3,340
    Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)
    Re: Paste text into console

    Quote:
    ...and don't have access to Spy++ *cry*
    Freeware spy++ clone.
    Reply With Quote
      #4    
    Old December 8th, 2009, 06:59 PM
    VladimirF VladimirF is offline
    Elite Member
    Power Poster
     
    Join Date: Aug 2000
    Location: Del Mar, California, USA
    Posts: 4,844
    VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)
    Re: Paste text into console

    Quote:
    Originally Posted by mister_sulu View Post
    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.
    Enjoy!
    Don't know if that other free tool will be more useful...
    Attached Images
     
    __________________
    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...
    Reply With Quote
      #5    
    Old December 8th, 2009, 07:23 PM
    VladimirF VladimirF is offline
    Elite Member
    Power Poster
     
    Join Date: Aug 2000
    Location: Del Mar, California, USA
    Posts: 4,844
    VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)VladimirF has a brilliant future (2000+)
    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...
    Reply With Quote
      #6    
    Old December 9th, 2009, 08:31 AM
    mister_sulu mister_sulu is offline
    Junior Member
     
    Join Date: Dec 2009
    Posts: 3
    mister_sulu is an unknown quantity at this point (<10)
    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
    Reply With Quote
      #7    
    Old December 9th, 2009, 09:57 AM
    OReubens OReubens is offline
    Elite Member
     
    Join Date: Apr 2000
    Location: Belgium (Europe)
    Posts: 2,461
    OReubens is a glorious beacon of light (400+)OReubens is a glorious beacon of light (400+)OReubens is a glorious beacon of light (400+)OReubens is a glorious beacon of light (400+)OReubens is a glorious beacon of light (400+)OReubens is a glorious beacon of light (400+)
    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.
    Reply With Quote
      #8    
    Old December 9th, 2009, 10:08 AM
    mister_sulu mister_sulu is offline
    Junior Member
     
    Join Date: Dec 2009
    Posts: 3
    mister_sulu is an unknown quantity at this point (<10)
    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
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:33 AM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.