Link to home
Start Free TrialLog in
Avatar of Ventura_v
Ventura_v

asked on

Changing application components with Handle

Hello Experts,

I'm using the program WindowSE to get the component handle in the application. With other application I can change normally with SendMessage, but this one when I try nothing happens... Maybe the process is protected??

Are there some ways to do it??
Avatar of Ventura_v
Ventura_v

ASKER

Hmm, I already got it... but now I have another doubt...
 
In the target app. there are a LOT of child handles... And their classname is usually the same... How can I get the handle of a specific component, without have to change it's value and then scan the memory...
 
Is there some program that can help me??
Did you try WinSight that came with Delphi ?
Yeah... It didn't help... There is a windows in this app that simulates a sheet like excel... I was trying to write/read (more important read) data in those cells...
 
Any ideas??
Avatar of CodedK
Hi Ventura_v

You are out of luck if it is a .NET application. Some times WinDowSE has problems to catch a component inside a Panel....
Anyway you can find a plethora of apps like WinDowSE.
My suggestion is to build one yourself....
You can capture the name easily, check this out :

https://www.experts-exchange.com/questions/11451658/Catch-the-Text-under-The-mouse.html

procedure TForm1.Timer1Timer(Sender: TObject);
var
  Point : TPoint;
  H : LongInt;
  Text : PChar;
begin
  Form1.BringToFront;
  GetCursorPos(Point);
  H := WindowFromPoint(Point);
  GetMem(Text, 300);
  SendMessage(H, WM_GETTEXT, 300, LongInt(Text));
  Edit1.Text := Text;
  FreeMem(Text);
end;

Set the timer component to about 100 interval or something for it to work better.

This way you will know what went wrong.

If this doesn't work then i will give you a list of similar apps that can do that.
Sorry the previous source was for getting the text.
Check this :
https://www.experts-exchange.com/questions/21557898/get-the-wincontrol-under-the-mouse-system-wide.html

procedure TForm1.Timer1Timer(Sender: TObject);
var
  pt : TPoint;
  wnd : cardinal;
  txt1 : array [0..255] of char;
  txt2 : array [0..255] of char;
begin
// if you use 'controls' unit, then you may use Mouse.CursorPos instead of variable 'pt'
// in that case GetCursorPos() is not necessary
GetCursorPos(pt);
wnd := WindowFromPoint(pt);
GetClassName(wnd, @txt1[0], sizeof(txt1));
GetWindowText(wnd, @txt2[0], sizeof(txt2));
if txt2 = '' then begin // sometimes wm_gettext works when GetWindowText() does not work
  SendMessage(wnd, wm_gettext, sizeof(txt2), integer(@txt2[0]));
end;
label1.Caption := format('handle: %.8x'#13#10'class: %s'#13#10'text: %s', [wnd, txt1, txt2]);
end;
Yeah, i guess the handle is the same for the whole table... Is there any other way to do it??
 
If you want I can upload the app so you can analyse it better... It's in portuguese, but I'll show you where exactly i'm having problems... Or a screenshot if you want...
Yes upload it please.
http://rapidshare.com/files/160952638/BIDS-4.0.3184.35770-Setup.exe.html
 
Once you install it, go to "Arquivo --> Novo --> Livro de oferta" or Ctrl + L... Then you'll see the table i'm trying to manipulate...
 
Note that it is a homebroker, so you'll have to have an account to get the numbers in there... But if you can use sendmessage or anything else to put a value in a specific cell, i'll probably be able to do it to get the containt of that cell right??
 
Thanks for the attention
Ok its a .NET application.
Use WinSpy++ to get the handle of the table. The table only though, :/
("WindowsForms10.Window.8.app.0.378734a")

To manipulate the cells you can send keystrokes (up & down cursor) and then send what you need to send or read the text.

There are not many things you can do with a .NET app. It doesnt act like the usual 32bit app you know.
Ok, the sending I think I understand... I'll just have to make a functions that calculates the position in the screen to each cell, then i simulate a mouse click and send the keystroke... But what about Read??
 
Other thing.... Since my program will have to read all changes of all stocks, it would have to be very fast... I thought about WriteProcessMemory and ReadProcessMemory, but then i couldn't think how to get all memory addresses and their length... I guess there is a function in this program called Link DDE... It should export those values to Excel, then it would be easier.
 
The problem is that my friend told me that it only exports the first row, then the indicator i have needs all of them...
 
PS: i didn't try this yet because my account in their website is not ready yet, and i wanted to get something done in case it doesn't work...
ASKER CERTIFIED SOLUTION
Avatar of CodedK
CodedK
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmm, I'll just paste it into excel, so I guess it really doesn't matter if it copies the whole table... i'll just have to delete a few rows from delphi code...
 
Can you wait until my registration in the website is ready, so i can test it, to get the points?? =)
Take your time, no problem.
I couldn't test it either, my only fear is that it might copy it as an image... but i don't think so.,
>>But it can copy all the table with the handle "WindowsForms10.Window.8.app.0.378734a".
So i guess a simple SendMessage CTRL+C to the table handle will copy the whole table then you can paste it in excell.
 
Doesn't the cells have to be selected to copy??
Goodmorning

If you use WinSpy++ you will see among the tabs there is a copy to clipboard function.
I am at work right now, i cant tell you which tab exactly. By selecting the whole table and click copy it copies to clipboard ALL the table, there is no need for individual cells to be selected !

You should work the same way like WinSpy++ , focus to the table handle and send a copy to clipboard message.

Try this and tell me if it works.
Hmm, i tested it with Excell and it copies as an image =\
Probably it will do the same with the homebroker right??
Right...
So the only thing possibly from this point is to do it like i said from the start.
Sending arrow keys and the Control+C hoping that this will work or build some OCR for the image.
Another thing you could do is ask for some developer source form the author of this application.

You don't have many options for this. Sorry.
 
Sorry for the delay CodeK, but i think it all blew... I coudn't get my registration done... Anyway, thanks for your help... I'll just give you the point ;D
Thanks Ventura_V.
Sorry for that :/