Solved

Changing application components with Handle

Posted on 2008-10-31
19
257 Views
Last Modified: 2013-11-23
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??
0
Comment
Question by:Ventura_v
  • 9
  • 9
19 Comments
 

Author Comment

by:Ventura_v
ID: 22852025
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??
0
 
LVL 7

Expert Comment

by:ahalya
ID: 22862540
Did you try WinSight that came with Delphi ?
0
 

Author Comment

by:Ventura_v
ID: 22869693
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??
0
 
LVL 16

Expert Comment

by:CodedK
ID: 22884626
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 :

http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_11451658.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.
0
 
LVL 16

Expert Comment

by:CodedK
ID: 22884646
Sorry the previous source was for getting the text.
Check this :
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21557898.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;
0
 

Author Comment

by:Ventura_v
ID: 22888100
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...
0
 
LVL 16

Expert Comment

by:CodedK
ID: 22888223
Yes upload it please.
0
 

Author Comment

by:Ventura_v
ID: 22888374
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
0
 
LVL 16

Expert Comment

by:CodedK
ID: 22889225
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.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Ventura_v
ID: 22889975
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...
0
 
LVL 16

Accepted Solution

by:
CodedK earned 500 total points
ID: 22893036
Good morning Ventura_v

You don't have to calculate the position in the screen for each cell !

Based on the assumption that you know how many rows and lines the table has then...
Just go up and left... Send 500 up arrow keys and 500 left... That will focus the top left cell for sure.
Then hit CTRL key and C key and you'll have the contents copied to the clipboard...
Then paste it wherever you want.
Move to the next cell. One right key then Ctrl+C. And so on.

This will be difficult though and time consuming. Reconsider if you are going to work this way.. is it necessary?

I don't know if you check WinSpy++..
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... But the problem is that it carries all the info of the table. I dont know if you can strip those out.

Hope this helps.
0
 

Author Comment

by:Ventura_v
ID: 22894341
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?? =)
0
 
LVL 16

Expert Comment

by:CodedK
ID: 22894369
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.,
0
 

Author Comment

by:Ventura_v
ID: 22900612
>>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??
0
 
LVL 16

Expert Comment

by:CodedK
ID: 22902304
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.
0
 

Author Comment

by:Ventura_v
ID: 22904941
Hmm, i tested it with Excell and it copies as an image =\
Probably it will do the same with the homebroker right??
0
 
LVL 16

Expert Comment

by:CodedK
ID: 22904996
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.
 
0
 

Author Comment

by:Ventura_v
ID: 23210220
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
0
 
LVL 16

Expert Comment

by:CodedK
ID: 23210524
Thanks Ventura_V.
Sorry for that :/
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now