• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

Windows Handle Question

Hi guys,

I don´t now if it´s even possible to do this,but anyway...

I now how to get a handle to a specific window. But I always have to now the name of it, like 'Shell_TrayWnd' for the tasbar.
But first how do I now the names of other windows?
for example: Bevor I recieve my Mails in Outlook I set it up so that I always have to enter my password.

Is there a chance to get a handle to this "Password-Input-window" and to send my password-string from my app directly in to the password editfield?
How do I now the name of this window and how can I access this special edit field where the password belongs into?

I now its a little crazy example but anyway,just for understanding this window-handle-stuff

Thanks a lot
0
Scotchman
Asked:
Scotchman
  • 4
  • 2
  • 2
1 Solution
 
Lukasz LachCommented:
Sure you can...
Have a look at my accepted answer on
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20495095.html
You can make yourself a list of windows and child windows with that. Then simply Use FindWindow and FindWindowEx of which an example will you find on that page too :-)
0
 
ScotchmanAuthor Commented:
I never worked with handles bevor,so am I right that a I can´t get a HANDLE only on windows but also on editboxes etc.?

If my understanding is right I use FindWindowEx to get a handle to window-CHILDS. Is a edit-box such a child,to?

I also found this:
(If I am right, EditWnd gets a handle to a edit-box,is that right???? )

function ChangeWndFirstEditText(Wnd: HWND; const Text: string): boolean;
var EditWnd: HWND;
begin
     Result:=False;
     EditWnd:=FindWindowEx(Wnd, 0, 'EDIT', nil);
     if EditWnd=0 then
          exit; // edit not found
     Result:=SendMessage(EditWnd, WM_SETTEXT, 0, Integer(PChar(Text)))<>0;
end;
0
 
Wax0rCommented:
Hi,

Yes, the controls have handles as well, you can also for example get the handle of the Listview in the NT/XP/2k taskmanager if you wanted to.

I don't think that code is correct because if I remember correctly the 3rd parameter of FindWindowEx is a CLASS, and editboxes aren't of the 'edit' class variety i'm affraid :)

What you should do is get an API spy and hover it over that password dialog - the api spy will tell you what class that edit box is so that you can check for the appropriate class and return according results.

(E.g. it could be TEdit).

0
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!

 
ScotchmanAuthor Commented:
API Spy, i never heard about that bevor,but sounds interesting. i will check it out...
0
 
Wax0rCommented:
There's one that comes with Delphi  I think. Then there's one that comes with Visual Studio.. and there's quite a few of them available for free on the web as well;

http://www.matcode.com/apis32.htm
http://www.patorjk.com/progapispy.htm
http://www.programfiles.com/Default.asp?LinkId=8383
0
 
ScotchmanAuthor Commented:
I used WinSight to listen for the window names, and it worked so far,but I still had no look getting the name of the Edit field. I also used ApiSpy,but it only gave me the names of the usable procedures or functions....
0
 
ScotchmanAuthor Commented:
Got it now. But one last question:
In my case I have TWO windows with ne same class name which only differ in the window text.
Is there a chance to skip to the next window with the same class name if the first isn´t the right one?I can check this with the window name...
0
 
Lukasz LachCommented:
second parameter in FindWindow is a Window Caption. When using EnumWindowProc use GetWindowText to get it's caption...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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