|
-
Dec 1st, 2010, 05:48 AM
#1
Thread Starter
New Member
[RESOLVED] Windows Handle
Hello guys once again i am need of help T_T
I need to get the contents of a listbox (from other application)
to the current application that I'm developing. I searched and from
what I've found you can do that using the handle. I manage to get
the handle using spy++ (dragged the finder tool over it) , but i dont
know what to do next now that i have found the handle. I am coding
in vb.net 2008 language ... I already searched the forums but i don't know
if im using the correct keywords , there may be or none topics already posted
like this one...
If somebody can please help , thanks! god bless!
-
Dec 1st, 2010, 06:04 AM
#2
Re: Windows Handle
Everything you see on the screen - textboxes, listboxes, forms, buttons even desktop -- are windows (that's why the operating system is called like that, btw). Each window has an unique window handle (hWnd) - a 32 bit integer number (or 64 bit for x64) which can be used to identify the window among others. Each WinAPI function that works with windows takes this handle as a parameter. Handles are not persistent so each time a window is creates a new hWnd is assigned to it.
There is always a top-level window called desktop window and all other windows are child windows to it.
A form with a textbox is actually two windows (the form is a child window to the desktop window and the textbox is a child window to the form -- sometimes the hierarchy can be quite long -- 10+ levels).
To help users (programs actually) in finding the right window there are several WinAPI functions: EnumWindows, EnumWindowsEx, EnumChildWindows, FindWindow, etc.
In order to get a hWnd of your listbox you will need to get a hwnd of its parent - the program's main window and then enumerate its child windows to get the listbox.
P.S. What information is contained in that listbox? Maybe there is an easier way to get its contents and you don't really need to do all of the above.
-
Dec 1st, 2010, 06:11 AM
#3
Thread Starter
New Member
Re: Windows Handle
 Originally Posted by cicatrix
Everything you see on the screen - textboxes, listboxes, forms, buttons even desktop -- are windows (that's why the operating system is called like that, btw). Each window has an unique window handle (hWnd) - a 32 bit integer number (or 64 bit for x64) which can be used to identify the window among others. Each WinAPI function that works with windows takes this handle as a parameter. Handles are not persistent so each time a window is creates a new hWnd is assigned to it.
There is always a top-level window called desktop window and all other windows are child windows to it.
A form with a textbox is actually two windows (the form is a child window to the desktop window and the textbox is a child window to the form -- sometimes the hierarchy can be quite long -- 10+ levels).
To help users (programs actually) in finding the right window there are several WinAPI functions: EnumWindows, EnumWindowsEx, EnumChildWindows, FindWindow, etc.
In order to get a hWnd of your listbox you will need to get a hwnd of its parent - the program's main window and then enumerate its child windows to get the listbox.
P.S. What information is contained in that listbox? Maybe there is an easier way to get its contents and you don't really need to do all of the above.
omg thanks for the reply ... i'm a total noob
the listbox i am working on is a listbox of an email spider. my boss is not comfortable with it's functions so he decided to crawl it ourselves. the listbox contains urls in queue , so while that email spider is running , i would
check that listbox , copy it's contents and from there make a crawl function.
i just need to copy the contents of that listbox (from other app) and add it to my own listbox (my app)
-
Dec 1st, 2010, 07:22 AM
#4
Hyperactive Member
Re: Windows Handle
As Cicatrix said, first you will need to find the parent window handle, then the child window you require. For this I suggest Winspector software.
After you ge the handle of the listbox you can use SendMessage api.
You will find many examples on google : )
Cheers ^^
-
Dec 1st, 2010, 07:55 AM
#5
Re: Windows Handle
 Originally Posted by lordpuza
omg thanks for the reply ... i'm a total noob
the listbox i am working on is a listbox of an email spider. my boss is not comfortable with it's functions so he decided to crawl it ourselves. the listbox contains urls in queue , so while that email spider is running , i would
check that listbox , copy it's contents and from there make a crawl function.
i just need to copy the contents of that listbox (from other app) and add it to my own listbox (my app)
Is there any way to get the output from this spider into a file? Or if it's an e-mail spider then maybe you can interact with it directly via e-mail ?
-
Dec 1st, 2010, 08:56 AM
#6
Thread Starter
New Member
Re: Windows Handle
yes it can output the results (the emails searched by the spider)
but the listbox i'm working on contains urls on que that is being crawled by that spider.
btw thanks skatebone, I would try that winspector!
-
Dec 1st, 2010, 09:31 AM
#7
Re: Windows Handle
Winspector suggests you will need to obtain the window handle manually (with Winspector) each time you need it. And each time this window is created it will be different.
I asked about whether the spider can output the information you need from the listbox or is there any other way to get this information. You should only consider grabbing it from the listbox as a last resort when all other options are tested.
-
Dec 1st, 2010, 09:56 AM
#8
Thread Starter
New Member
Re: Windows Handle
oh sorry , the listbox im reffering to doesnt have the option to output it on a file. the only way i can get those data from the listbox is with the link tutorial that you provided (which is great help btw , i managed to get the parent but having difficulties in the child items)
-
Dec 1st, 2010, 10:45 AM
#9
Hyperactive Member
Re: Windows Handle
 Originally Posted by cicatrix
Winspector suggests you will need to obtain the window handle manually (with Winspector) each time you need it. And each time this window is created it will be different.
I asked about whether the spider can output the information you need from the listbox or is there any other way to get this information. You should only consider grabbing it from the listbox as a last resort when all other options are tested.
The handle does change! But thats why you use Find window and child windows apis 
Then using winspector one can get the child windows' names
I did something similar to this once.
-
Dec 1st, 2010, 12:34 PM
#10
Thread Starter
New Member
Re: Windows Handle
dear sir skatebone , yes the listbox's handle does change everytime your run it. do you have any links that can point me to a good tutorial on
manipulating other applications controls
im googling for hours so far from what ive learned (correct me if im wrong)
to achieve what im doing
1) findwindow <- finds the parent form using caption
2) enumwindowex <- enumerates child windows
3) when found pass it to the delegate function
4) do something with getdlgitem
to find the specific control im looking for (programatically) i would use user32 api
to do something once found , i would use sendmessage api? is that correct?
sorry for being noob and my bad english
-
Dec 1st, 2010, 12:36 PM
#11
Thread Starter
New Member
Re: Windows Handle
dear cicatrix and skatebone , thanx so much for all your replies! From here i think I just need more further reading.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|