Writing text to a separate command prompt window
BlitzMax Forums/BlitzMax Programming/Writing text to a separate command prompt window
| ||
I want to write a program in Bmax that can send keystrokes directly to an inactive command prompt window. Possible? |
| ||
Possibly. I'm pretty sure that there's some code in the code archives that shows how to stuff text from Blitzmax into a different application window (essentially shoving a string into the edit window of an open notepad process), which might work with a command prompt as well... (Note entirely sure, since the command prompt behaves different than most 'normal' windows, not sure if that will become a problem) |
| ||
It is a problem in AutoIt3, which is why I'm here :/ I'll take a look at it. Thanks. I found a B+ program for sending keystrokes, but that wouldn't work with an inactive window. |
| ||
If you need this for a practical purpose, check out http://www.autohotkey.com/ |
| ||
I saw that, and it works, but its syntax is foreign. I was hoping there was another option. |
| ||
Just in case it helps you, here's the code snippet that will send text to a new notepad session if it's open:Const WM_SETTEXT = $00C Const WM_COPYDATA = 74 Extern "Win32" Function FindWindow( lpClassName$z, lpWindowName$z ) = "FindWindowA@8" Function FindWindowEx( hwnd1:Int, hwnd2:Int, lpsz1$z, lpsz2$z ) = "FindWindowExA@16" Function SendMessage( hwnd, msg, wparam:Byte Ptr, lparam:Byte Ptr ) = "SendMessageA@16" Function GetLastError() End Extern 'win=FindWindow( "SciCalc", "Calculator" ) win=FindWindow( "NotePad", "Untitled - Notepad" ) edit=FindWindowEx( win, Null, "Edit", Null ) SendMessage( edit, WM_SETTEXT, Null, "16" ) |
| ||
I'm not sure how to get that to work with a prompt, but it looks like something that might do well. |
| ||
Note that the "Edit" field above actually is the name of the main textfield inside notepad. You can find out the names of those through a resource editor which will list them. In the case of the command prompt that may proof to be a showstopper, since those kind of windows are fairly different from normal GUI ones... |