I have been trying to design an application where I need to set the focus from my application to the last application eg word powerpoint excel etc and then to paste in some information to that application. I think that I should be using enumerate windows or get lastwindow functions but I just cant fathom how to use them.
Any help would be really appreciated as I have been working ion this (sporadically) for a very long time.
Thanks
daycartes

i believe getlastwindow isn't a delphi function. also i'm confused, why you must send focus to an application. why you don't search the application through winapi functions?

best regards,

Thanks for replying radu84. getlastwindow is an api and as such is usable within delphi. I'm sending the focus to the last application and then using a paste function to insert a character. I can focus onto MSWord and can paste into that app, but I want to automate the programme to look for and setfocus and paste into that application be it word, powerpoint excel etc. I can search through open windows, but I need to find the code to bring that window to the front of the z order. Thanks again, daycartes

i haven't worked until on something similar so i can only give some advices and talk with you. here is what i found on msdn about z-order

Z-Order

The z-order of a window indicates the window's position in a stack of overlapping windows. This window stack is oriented along an imaginary axis, the z-axis, extending outward from the screen. The window at the top of the z-order overlaps all other windows. The window at the bottom of the z-order is overlapped by all other windows.
The system maintains the z-order in a single list. It adds windows to the z-order based on whether they are topmost windows, top-level windows, or child windows. A topmost window overlaps all other non-topmost windows, regardless of whether it is the active or foreground window. A topmost window has the WS_EX_TOPMOST style. All topmost windows appear in the z-order before any non-topmost windows. A child window is grouped with its parent in z-order.
When an application creates a window, the system puts it at the top of the z-order for windows of the same type. You can use the BringWindowToTop function to bring a window to the top of the z-order for windows of the same type. You can rearrange the z-order by using the SetWindowPos and DeferWindowPos functions.
The user changes the z-order by activating a different window. The system positions the active window at the top of the z-order for windows of the same type. When a window comes to the top of z-order, so do its child windows. You can use the GetTopWindow function to search all child windows of a parent window and return a handle to the child window that is highest in z-order. The GetNextWindow function retrieves a handle to the next or previous window in z-order.

(http://msdn2.microsoft.com/en-us/library/ms632599.aspx)

i hope with this i gave you some more information on what you want to accomplish.

best regards and i wait for you to come back and tell what you've done

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.