Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

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??
0
Ventura_v
Asked:
Ventura_v
  • 9
  • 9
1 Solution
 
Ventura_vAuthor Commented:
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
 
ahalyaCommented:
Did you try WinSight that came with Delphi ?
0
 
Ventura_vAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CodedKCommented:
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
 
CodedKCommented:
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
 
Ventura_vAuthor Commented:
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
 
CodedKCommented:
Yes upload it please.
0
 
Ventura_vAuthor Commented:
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
 
CodedKCommented:
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
 
Ventura_vAuthor Commented:
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
 
CodedKCommented:
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
 
Ventura_vAuthor Commented:
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
 
CodedKCommented:
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
 
Ventura_vAuthor Commented:
>>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
 
CodedKCommented:
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
 
Ventura_vAuthor Commented:
Hmm, i tested it with Excell and it copies as an image =\
Probably it will do the same with the homebroker right??
0
 
CodedKCommented:
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
 
Ventura_vAuthor Commented:
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
 
CodedKCommented:
Thanks Ventura_V.
Sorry for that :/
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now