Simple way to get window handle?

Just starting out? Need help? Post your questions and find answers here.
marlo
User
User
Posts: 10
Joined: Fri Jul 30, 2004 8:39 pm

Simple way to get window handle?

Post by marlo »

I try to make something in PB to draw,change text,or move things in external window app made by another language,wich is the simple way to get the external window app?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Simple way to get window handle?

Post by PB »

If the other window's title never changes, then you can get its handle like so:

Code: Select all

handle=FindWindow_(0,"FullTitleGoesHere")
And if you need to find it by partial title (rather than full), use this:

Code: Select all

Procedure FindPartialWindow(part$)
  r=GetWindow_(GetDesktopWindow_(),#GW_CHILD)
  Repeat
    t$=space(999) : GetWindowText_(r,t$,999)
    If FindString(t$,part$,1)<>0
      w=r
    Else
      r=GetWindow_(r,#GW_HWNDNEXT)
    EndIf
  Until r=0 Or w<>0
  ProcedureReturn w
EndProcedure

handle=FindPartialWindow("PartialTitleGoesHere")
Fred: Would you perhaps be able to make a native "FindPartialWindow" command?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
marlo
User
User
Posts: 10
Joined: Fri Jul 30, 2004 8:39 pm

Post by marlo »

Thanks PB!

If the other program call my PB app by parameter as for example
the window handle number can i use the same API command FindWindow?

Another, and last>

How can i ,if is possible , move ,change the text ,of any object in the external window app, if this app send to my PB app the handle number of
that object ,is also possible to do this with PB?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Sorry, but I don't really understand your last 2 questions...?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
marlo
User
User
Posts: 10
Joined: Fri Jul 30, 2004 8:39 pm

Post by marlo »

Great PB, simply:

I have one app made by another programming language and call
my PB app, then i need that my PB app can use only the Window of
that application ,and the objects in it ,buttons,text,etc, in few word, my PB APP can control and even, if is possible, create or modify objects on external window. I try with APIs but i cant make it work until now.I search
on purearea, and nothing like i want.
Post Reply