|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Rectangle Advanced Cheater Reputation: 1
Joined: 23 Feb 2013 Posts: 73
|
Posted: Wed May 15, 2013 10:22 pm Post subject: Grab text from another window? (UPDATED) |
|
|
I have an application which monitors the temperature of my CPU and GPU.
I also have a trainer which hooks into a D3D window and is able to display some text upon pressing a key combination.
What I would like to do is grab the temperature readouts from the application which monitors them, and use this data as the text to display in the D3D application.
I have used Spy++ to retrieve information about the static text objects in the monitoring application's window.
The window class for these objects does not change, and therefore it wouldn't be too hard to grab the text from them using a few Win32 API calls.
But I'm not certain how to do this via LUA in CE...
Any ideas?
UPDATE:
Okay so I found out about the alien lua extension, extracted it to my CE path, and have successfully retrieved the parent window using the following lua script:
Code: | local parentWindowClassName = "MyClassName"
local parentWindowTitle = "MyWindowTitle"
local format = string.format
require[[alien]]
local user32 = alien.load("user32.dll")
local FindWindow = user32.FindWindowExA
local GetWindowText = user32.GetWindowTextA
FindWindow:types{ ret = 'long', abi = 'stdcall', 'long', 'long', 'string', 'string' }
GetWindowText:types{ ret ='long', abi = 'stdcall', 'long', 'pointer', 'int' }
local parentWindow = FindWindow(0, 0, parentWindowClassName, parentWindowTitle)
local buffer = alien.buffer(512)
GetWindowText(parentWindow, buffer, 511)
local text = tostring(buffer);
print(format("Window Handle: %d, Caption: \"%s\"", parentWindow, text)) |
But now I'm having trouble getting the HWND of the static label control belonging to the parent HWND, since FindWindowEx returns 0 when I use the parent HWND to search for a child control.
Anyone know of an alternative to grabbing the HWND of a child conrtol?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25291 Location: The netherlands
|
Posted: Thu May 16, 2013 2:26 am Post subject: |
|
|
Is the caption or classname you provide correct?
Something else you could try is the GetWindow api.
GW_CHILD to get the first child
GW_HWNDNEXT to get the next sibling
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Rectangle Advanced Cheater Reputation: 1
Joined: 23 Feb 2013 Posts: 73
|
Posted: Thu May 16, 2013 3:21 am Post subject: |
|
|
I figured out the issue.
FindWindowEx only returns child windows 1 level down from the parent window, and the target controls are 3 levels down from the parent window.
So I just used FindWindow on each root node of the target control, then used EnumChildWindows on that window handle to get the correct child control window handles.
I had to do it this way because FindWindowEx requires knowledge of both the window class name AND window titles, but the desired static text controls change their captions...
And if I already knew those captions, then I would have no need for any of this functionality in the first place.
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|