Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C++ get text of SysListView32(LVS_OWNERDATA+LVS_OWNERDRAWFIXED) items from other applications

ilqar200

New Coder
Hello. I apologize in advance if I created the topic in the wrong place, because I think that my task is directly or indirectly related to WinApi. I will describe the task:
I am programming an imitation of manual work in applications for working on financial markets (Metatrader 4 and 5). I use AutoIt for this. I need to read the text of the SysListView32 elements. I wrote the following code for this purpose.
Code:
#include <WinAPI.au3>
#include <Memory.au3>
#include <ListViewConstants.au3>
Local $pid=        ; here i write id of needed process
Local $hwnd=      ; here i write handle of SysListView32
Local $maxtext=    ;here i write max number of chars
Local $hprocess=_WinAPI_OpenProcess($PROCESS_ALL_ACCESS,False,$pid)
Local $plv=_MemVirtualAllocEx($hprocess,Null,$maxtext+60,$MEM_COMMIT,$PAGE_READWRITE)
Local $rectext=DllStructCreate("char ["&$maxtext&"]")
Local $lv=DllStructCreate($tagLVITEM)
$lv.Mask=$LVIF_TEXT
$lv.Item=0
$lv.SubItem=0
$lv.Text=$plv+60
$lv.TextMax=$maxtext
_WinAPI_WriteProcessMemory($hprocess,$plv,DllStructGetPtr($lv),60,Null)
_SendMessageA($hwnd,$LVM_GETITEMA,0,$plv)
_WinAPI_ReadProcessMemory($hprocess,$lv.Text,DllStructGetPtr($rectext),$maxtext,Null)
_MemVirtualFreeEx($hprocess,$plv,0,$MEM_RELEASE)
ConsoleWrite(DllStructGetData($rectext,1))

The problem is that the above code only gets the text if the SysListView32 has either LVS_OWNERDATA or LVS_OWNERDRAWFIXED style. But this code is not getting text of SysListView32 elements with combined LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles.
Well here's the question:
How to get item text from SysListView32 from another application with both LVS_OWNERDATA and LVS_OWNERDRAWFIXED styles at the same time?
I would like to get some direction of action or example code (doesn't matter on AutoIt). Thank you.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom