Page 1 of 1

Getting text from winExplorer add?

Posted: Fri Aug 18, 2006 8:49 am
by acidburn
just want to know how to get the text from window explorer address using PB? anyone?

Posted: Fri Aug 18, 2006 9:30 am
by netmaestro
If you have its window handle, it's easier. However, if you don't, this snippet should return the Address Bar text of the first Windows Explorer window it finds:

Code: Select all

Global AddrText.s = Space(200) 

Procedure FindComboBox(win, void) 
  a.s = Space(200) 
  GetClassName_(win, @a, 199) 
  If a="ComboBox" 
    PokeW(@AddrText,199) 
    SendMessage_(GetWindow_(win,#GW_CHILD), #EM_GETLINE, 0, @AddrText) 
    ProcedureReturn 0 
  EndIf 
  ProcedureReturn 1 
EndProcedure 

win=FindWindow_("ExploreWClass", 0) 
If win
  EnumChildWindows_(win, @FindComboBox(), 0) 
  Debug AddrText
Else
  Debug "Can't find an Explorer window!"
EndIf

Posted: Fri Aug 18, 2006 10:18 am
by acidburn
@netmaestro

I'll try it now.. thank you very much..

Posted: Fri Aug 18, 2006 11:24 am
by srod
Nice code. :)

Posted: Fri Aug 18, 2006 2:47 pm
by acidburn
hello there

am having troubled with handle

when i changed this

Code: Select all

win=FindWindow_("ExploreWClass", 0)
to this

Code: Select all

win=FindWindow_(5309050,0) 
"can't find an Explorer Window"

when i try this

Code: Select all

win=FindWindow_(0,"My Documents") 
the result is this ==> Ç


sorry for my noobness, am not that good.. but am trying..

Posted: Fri Aug 18, 2006 2:55 pm
by srod

Code: Select all

win=FindWindow_(5309050,0) 
Why the value 5309050?

If you're using a global atom, then I think these are 16 bit values only, which means that 5309050 is out of range.

Posted: Fri Aug 18, 2006 4:08 pm
by acidburn
sorry foy my example, i used the exmple program code here for getting the handles

the result is here...
Handle = 8389476, Caption = M
Handle = 5309050, Caption = Default IME
Handle = 6357194, Caption = chords

still i dont get it... what is global atom? (excuse me for asking, its so embarassing)

Posted: Fri Aug 18, 2006 4:19 pm
by srod
If I understand what you've done, then it's a big no no! :)

A window's handle (used by window's and applications to identify different windows and controls etc.) is only valid for a particular session and so you cannot and must not attempt to hard code this.

For example, run windows explorer a first time and the window's handle allocated to it's main window could be, say, 100100.
Stop the program and run it again and the handle could have changed to, say, 200050 etc.

The thing to remember is that handles are dynamically allocated and are always subject to change between instances of running your program.


Right, now that's out of the way (assuming I understand what you did?) what exactly are you trying to do? :lol:

netmaestro posted some good code there. I don't see much scope for altering the code in anyway.

If you're after a detailed explanation of how it works, then fair enough; just ask.

btw, I wouldn't concern yourself with global atoms, I don't think many people use them anyhow.

Posted: Fri Aug 18, 2006 4:51 pm
by acidburn
whew... thnx for the info. dont know what to say

i better read more, but am hoping someone will post more examples here.

Posted: Fri Aug 18, 2006 4:54 pm
by srod
If you want loads of example snippets then try the invaluable code archive at:

http://www.purearea.net/pb/english/index.htm

Most (if not all) of these snippets are for Purebasic 3.94 and so will not run directly under PB 4. Each only requires a couple of alterations though, normally with the OpenWindow() command and a few constants that have changed.

Posted: Fri Aug 18, 2006 5:36 pm
by acidburn
ty for the information. i already did that, i've ready downloaded the samples and yes most of the files was created from the previous version of PB. but i managed to changed some syntax for PB4. actually i've started experimenting and conding since last august 3


and also thx to this site

http://www.xs4all.nl/~bluez/datatalk/pure3.htm#top

for the pure basic guide, it helps a lot..