RE: Get FULL Title Bar string of Active window. by SBans
SBans
Tue Nov 29 07:59:08 CST 2005
Michel,
I removed the extra 'ENDDEFINE', however the following errors still remain:
Program E:\TEST\check.prg has the following errors:
Unknown GETDESKTOPWINDOW - Undefined
Unknown GETWINDOW - Undefined
Unknown GETCLASSNAME - Undefined
Unknown GETWINDOWTEXT - Undefined
Regards
S Bans
"Michel Roy" wrote:
> yep, that's an extra line of code that should not be there. sometimes, when
> you cut/paste from another program you forget to remove/fix little bits.
>
> "S Bans" wrote:
>
> > Thanks, Michel,
> >
> > Your suggestion is working fine, if I run it as a stand alone PRG, However
> > if I compile it with my project with the top 5 lines changed, I get some
> > errors:
> >
> > My changed code is:
> > -------------------------
> >
> > loCaption = GetFullCaption("My Application")
> > mFLAG = 0
> > FOR I = 1 to loCaption.Count && number of matching windows
> > IF LEN(ALLTRIM(loCaption.Item(I))) > len("My Application")
> > mFLAG = 1
> > EXIT
> > ELSE
> > mFLAG = 0
> > ENDIF
> > NEXT
> >
> >
> > The Errors I get are :
> > --------------------------
> >
> > Compiling E:\TEST\check.prg
> > ENDDEFINE
> > Error in line 80: Statement is only valid within a class definition.
> >
> > Program E:\TEST\check.prg has the following errors:
> > Unknown GETDESKTOPWINDOW - Undefined
> > Unknown GETWINDOW - Undefined
> > Unknown GETCLASSNAME - Undefined
> > Unknown GETWINDOWTEXT - Undefined
> >
> > -------------------------------
> >
> > Incidentally, my knowledge of Programming is very basic. I am engaged in
> > some other vocation, and the small appliocations I develop or get developed
> > are mostly for my own use. So I might be commiting some very basic mistake
> > and getting these errors. I hope you will understand and guide me how to
> > solve it.
> >
> > Regards
> >
> > S Bans
> >
> >
> >
> >
> >
> > "Michel Roy" wrote:
> >
> > > this will iterate thrue open windows and return a collection of all windows
> > > matching the beginning caption text
> > >
> > > ex: loCaption = GetFullCaption("My Application")
> > > FOR I = 1 to loCaption.Count && number of matching windows
> > > ? loCaption.Item(I)
> > > NEXT
> > >
> > > #DEFINE WM_CLOSE 0x10
> > > #DEFINE GW_CHILD 5
> > > #DEFINE GW_HWNDNEXT 2
> > >
> > > PROCEDURE GetFullCaption(lcTxt AS STRING)
> > > LOCAL lcPrc AS STRING, lnHwnd AS INTEGER, lnDesktopHWND
> > > LOCAL lcTemp AS STRING, lcDir AS STRING
> > > LOCAL loWindows AS Collection
> > > loWindows = CREATEOBJECT("Collection")
> > >
> > > DECLARE LONG "GetWindow" IN WIN32API LONG HWND, LONG wCmd
> > >
> > > DECLARE LONG "FindWindow" IN WIN32API ;
> > > STRING lpClassName, STRING lpWindowName
> > >
> > > DECLARE LONG "PostMessage" IN WIN32API ;
> > > LONG HWND, LONG wMsg, LONG wParam, LONG LPARAM
> > >
> > > DECLARE LONG "IsWindowVisible" IN WIN32API LONG HWND
> > >
> > > DECLARE LONG "GetClassName" IN WIN32API ;
> > > LONG HWND, STRING lpClassName, LONG nMaxCount
> > >
> > > DECLARE LONG "GetWindowText" IN WIN32API ;
> > > LONG HWND, STRING lpClassName, LONG nMaxCount
> > >
> > > DECLARE LONG "GetDesktopWindow" IN WIN32API
> > >
> > > lcPrc = ""
> > >
> > > TRY
> > > lnDesktopHWND = GetDesktopWindow()
> > > lnHwnd = GetWindow(lnDesktopHWND, GW_CHILD)
> > >
> > > DO WHILE lnHwnd <> 0
> > > lnHwnd = GetWindow(lnHwnd, GW_HWNDNEXT)
> > > ccc = GWT(lnHwnd)
> > > IF UPPER(ccc) = UPPER(lcTxt)
> > > loWindows.Add(ccc)
> > > ENDIF
> > > ENDDO
> > >
> > > CATCH
> > > ENDTRY
> > > RETURN loWindows
> > > ENDPROC
> > >
> > > PROCEDURE GCN(HWND AS LONG)
> > > lcClass = SPACE(256)
> > > lnLen = GetClassName(HWND, @lcClass, LEN(lcClass))
> > > RETURN LEFT(lcClass, lnLen)
> > > ENDPROC
> > >
> > > PROCEDURE GWT(HWND AS LONG)
> > > lcText = SPACE(256)
> > > lnLen = GetWindowText(HWND, @lcText, LEN(lcText))
> > > RETURN LEFT(lcText, lnLen)
> > > ENDPROC
> > >
> > > ENDDEFINE
> > >
> > >
> > > "S Bans" wrote:
> > >
> > > > Friends,
> > > >
> > > > Recently I posted a question with the SUBJECT heading of "Sending KeyStrokes
> > > > to another Windows Application". The replies have been very helpful and did
> > > > what I wanted. I further need to know the FULL title bar caption of the
> > > > window activated by the the command:
> > > >
> > > > WshShell.AppActivate("My application")
> > > >
> > > > Actually the title bar can be more than just "My application" - In this case
> > > > it can be 'My application + some more strings'
> > > >
> > > > I will look forward to guidance of member for doing it in my VFP8 application
> > > >
> > > > Regards
> > > >
> > > > S Bans
> > > >