Getting text from winExplorer add?

Just starting out? Need help? Post your questions and find answers here.
acidburn
User
User
Posts: 23
Joined: Mon Aug 07, 2006 1:37 pm

Getting text from winExplorer add?

Post by acidburn »

just want to know how to get the text from window explorer address using PB? anyone?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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
BERESHEIT
acidburn
User
User
Posts: 23
Joined: Mon Aug 07, 2006 1:37 pm

Post by acidburn »

@netmaestro

I'll try it now.. thank you very much..
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Nice code. :)
I may look like a mule, but I'm not a complete ass.
acidburn
User
User
Posts: 23
Joined: Mon Aug 07, 2006 1:37 pm

Post 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..
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
acidburn
User
User
Posts: 23
Joined: Mon Aug 07, 2006 1:37 pm

Post 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)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
acidburn
User
User
Posts: 23
Joined: Mon Aug 07, 2006 1:37 pm

Post 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.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
acidburn
User
User
Posts: 23
Joined: Mon Aug 07, 2006 1:37 pm

Post 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..
Post Reply