Other program access and data extraction
-
Hello. I'm trying to get text data from another program. The window handle was found. Please check the image link. CLICK Here - Attach Image Link But I'm not sure what to do next. Should I use something similar to the GetDlgCtrlID method? I do not know. The return is -1. Please advise. thank you.
-
Hello. I'm trying to get text data from another program. The window handle was found. Please check the image link. CLICK Here - Attach Image Link But I'm not sure what to do next. Should I use something similar to the GetDlgCtrlID method? I do not know. The return is -1. Please advise. thank you.
There are similar questions/discussions in different forums. Have a look at [python - Need a way to access control in a window with control id using pywinauto - Stack Overflow](https://stackoverflow.com/questions/40252343/need-a-way-to-access-control-in-a-window-with-control-id-using-pywinauto)
-
Hello. I'm trying to get text data from another program. The window handle was found. Please check the image link. CLICK Here - Attach Image Link But I'm not sure what to do next. Should I use something similar to the GetDlgCtrlID method? I do not know. The return is -1. Please advise. thank you.
cocaya wrote:
the GetDlgCtrlID method
That will only return a valid id if the handle is that of an actual dialog control. But even if it does, the id will not be of any use. To get the text of a Window in another process, you must send the WM_GETTEXT message (Winuser.h) - Win32 apps | Microsoft Docs[^] to it. But you first need to know that the Window contains valid text.
-
cocaya wrote:
the GetDlgCtrlID method
That will only return a valid id if the handle is that of an actual dialog control. But even if it does, the id will not be of any use. To get the text of a Window in another process, you must send the WM_GETTEXT message (Winuser.h) - Win32 apps | Microsoft Docs[^] to it. But you first need to know that the Window contains valid text.
*CLICK here : Attach Image Link handle => 0x001229e8 GetControlText(IntPtr hWnd){ // Get the size of the string required to hold the window title (including trailing null.) Int32 titleSize = SendMessage((int)hWnd, WM_GETTEXTLENGTH, 0, 0).ToInt32(); // If titleSize is 0, there is no title so return an empty string (or null) if (titleSize == 0) return String.Empty; StringBuilder title = new StringBuilder(titleSize + 1); SendMessage(hWnd, (int)WM_GETTEXT, title.Capacity, title); return title.ToString(); } Thanks reply, but When this function is executed, String.Empty is returned. How can I get grid table values?? I desperately want to solve it. please help me..
-
*CLICK here : Attach Image Link handle => 0x001229e8 GetControlText(IntPtr hWnd){ // Get the size of the string required to hold the window title (including trailing null.) Int32 titleSize = SendMessage((int)hWnd, WM_GETTEXTLENGTH, 0, 0).ToInt32(); // If titleSize is 0, there is no title so return an empty string (or null) if (titleSize == 0) return String.Empty; StringBuilder title = new StringBuilder(titleSize + 1); SendMessage(hWnd, (int)WM_GETTEXT, title.Capacity, title); return title.ToString(); } Thanks reply, but When this function is executed, String.Empty is returned. How can I get grid table values?? I desperately want to solve it. please help me..
-
It depends on how that grid controls its content. A simple WM_GETTEXT message is unlikely to return anything. If it is a Windows ListView then you could try some of the LVM_GETxxx messages: List View Messages - Win32 apps | Microsoft Docs[^].
Thanks for the advice. I tried the following, but the return value is 0. int nTextLength = SendMessage(hwnd6, WM_GETTEXTLENGTH, 0, 0).ToInt32(); How should I approach it?ㅜ.ㅜ CLICK Here : MS inspect.exe capture.
-
Thanks for the advice. I tried the following, but the return value is 0. int nTextLength = SendMessage(hwnd6, WM_GETTEXTLENGTH, 0, 0).ToInt32(); How should I approach it?ㅜ.ㅜ CLICK Here : MS inspect.exe capture.
1. Why are you calling
ToInt32
on a value that is already anint
type? 2. IfWM_GETTEXTLENGTH
returns zero, then that tells you the Window is not a Text type. As I said yesterday, if the contents are shown in a grid then you need to find out what actual control it is, and use the control's methods to extract the contents.