Need SendMessage Command to get List from a VB6 application - vb6

Hi I have a program that is built using VB6(I do not have the sourcecode, only executable), that has a listbox and will have couple of items in that listbox. I need to read contents of it using SendMessage. Please let me know if that is possible.

It's possible if it's a standard or at least documented listbox control. Usually one would use a "spy" program to examine the target app and obtain window titles/classes/etc. used to programmatically locate the window that is the listbox control. Then you just use SendMessage() to talk directly to the HWND of that control and get the info you need.
See similar question:
Read listbox content of from another application C#

Related

Tab key does not work in windows control added (.Net extension) in saleslogix windows

I have added a .Net windows form inside a saleslogix windows plugin, every thing is working fine but on pressing the "Tab" key inside this control, instead of going on the next textbox the control goes to next plugin.
I have searched it a lot and can not find a work around for this, when I added a browser control in another saleslogix windows plugin, the page inside this textbox has multiple text boxes in it. To my surprise on pressing the tab key it worked perfectly and control goes to the next text box.
Any help is much appreciated.
That's an entirely normal mishap when you use Winforms (and many other UI class libraries) in a host application. Navigation keys, like Tab and the cursor keys as well as shortcut keystroke keys, need to be recognized regardless which control has the focus. One way to do so would be to implement the KeyDown event handler on every single control. That's excessively painful of course.
So it doesn't work that way, the keystroke is recognized when it is received by the message loop, before it is dispatched to the control with the focus. Overriding the ProcessCmdKey() method is the general way to do this. The base method takes care of navigation and recognizing menu and button mnemonics.
Problem is, it isn't the .NET message loop that is receiving and dispatching messages. It is the host application that has the loop. And it doesn't know beans about ProcessCmdKey(). So it doesn't get called and navigation doesn't work.
It tends to work in a WebBrowser because it is an ActiveX control. Which is designed to interact with its host. In particular it negotiates to decide which one gets to process the key. The IOleInPlaceActiveObject::TranslateAccelerator() method does this. Not the kind of plumbing available in .NET and host apps are rarely written to provide an alternative.
You could consider the "excessively painful" solution but pretty unlikely you like the sound of it. There's only one other decent way to fix this, you must call ShowDialog() to display your form. Now it is the .NET loop that dispatches and the Tab and cursor keys work fine. That tends to be unwelcome advice, dialogs can be pretty awkward. If you are lucky and know what you're doing and the host can deal with it (usually not) then using a thread can take the sting out of the modality. Asking the vendor for advice, particularly the threading aspect, would be wise.

Is there a way to parent a standard Windows dialog inside another form?

I know it's possible to take a dialog that you built yourself and parent it on another form. But is it possible to parent a standard Windows system dialog on a form that you designed?
Specifically, I'm trying to set up a form with multiple tabs that provide different ways to obtain a reference to data used by the program. One of those tabs should represent the file system, and the ideal way to do this would be with the standard Open dialog that can be instantiated with the COM identifier CLSID_FileOpenDialog.
Is there any way to take a system dialog and cause it to appear parented on another window, without the border, title bar, etc?
There are ways to use a hook, either via SetWindowsHookEx() or SetWinEventHook(), to grab a system dialog's HWND, then you can do whatever you want with it, such as call SetParent(). But just because you CAN does not mean you SHOULD. System dialogs are designed to run as their own windows, not embedded in someone else's window. A better solution might be to use the same Shell display components that are used by Windows Explorer (and system dialogs) via IShellFolder::CreateViewObject() or SHCreateShellFolderView(), or find a third-party solution that does the hard work of interacting with the Shell for you.

Extracting text from application GUI

Is there anyway to extract text from application UI by using C++ or C# (lets say like the text on the UI of steam launcher ) ? I need extract the text in order to do some automation of the application.
Have a play around with spy++, it's a tool that comes with Visual Studio. If spy++ can dig down to see the UI elements then you can build a program that does the same.
You can do it winth winapi, there are scripting languages that makes it easier:
http://www.autoitscript.com/site/autoit/
Basicly you should locate somehow your control you want to read, spy++ is a good example, then read it either using its order in window hierarchy or class name.

read/capture Windows pop-up message in vb6?

Problem: Need to read/capture the text of Windows pop-up messages that is generated by non-VB applications.
Situation:
I've a VB6 app, part of which requires processing an excel workbook. A non vb-6 pop-up window (as attached screen) "FILE CONVERSION IN PROGRESS" comes up, while opening an new version of excel-sheet from an old MS Excel app. And automatically it closes alos.
Requirement: I want to capture that pop-up occurance in the code. And then write a conditional statement code for the 'cancel' button click event of that non vb-6 pop-up.
Can anyone suggest something?
You can access other applications with the following APIs:
FindWindow() to locate the main window of what you're looking for
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx
GetWindow() to navigate through the HWNDs of the application so you can get to the button
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633515%28v=vs.85%29.aspx
GetWindowText() to access the text from a control (it cannot be an Edit control)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633520%28v=vs.85%29.aspx
You'll want to use Spy++ (which can be downloaded) to see what the class name you're looking for when it comes up and to figure out the hierarchy to navigate properly.
You'll need to use the API Text Viewer to get the API declarations so you can use them in VB6 properly.

Applications hook

I would like to make some hook in windows programs. For instance, Vodafone application have some MSN like popup that can't be hiddent. So, in that way, I would like to create my option to hide or not this popups. Can anybody tell me some tutorials (basic first) how to do that?
Thanks in advice.
You have to create system wide windows hook with SetWindowsHookEx with first param WH_CBT. You can hook on HCBT_CREATEWND event and return non zero value and window will be destroyed, but first you have to somehow recognize that this is right window, maybe according to window title or something inside that title.
Another thing is that you can't use managed code and C# for system wide hooks, since you have to make unmanaged dll in witch hook will reside. So you have to use C++ or Delphi, and if you are not experienced in win32 programming that would probably be very complicated task.

Resources