Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Controlling other opened windows.

Posted on 1998-12-23
10
Medium Priority
?
150 Views
Last Modified: 2010-04-04
How do I set focus on  another opened window, e.g. notepad and start sending tabs and keystrokes ? I'm trying to get around the Delphi/400 client installation when keying the QSECOFR's password. I have a few hundred installations ...
0
Comment
Question by:wengwah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 400 total points
ID: 1352737
Hi wengwah,

What about APi BringWindowToTop? You can use  FindWindow to look for other windows by class name, or use EnumWindows or GetWindow to look through the list of current windows.

The BringWindowToTop function brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.

BOOL BringWindowToTop(

    HWND  hWnd       // handle of window
   );      
Parameters

hWnd

Identifies the window to bring to the top of the Z order.

Return Value

If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

Regards, Zif.

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1352738
You have  Windows.SetFocus( HWND ), and you can find the handle of a window, by it's title for example, using FindWindow and GetWindow (look in win32.hlp).

Sending keystrokes is either sending WM_KEYDOWN, WM_CHAR messages using SendMessage, or you have the Keybd_event function, which is the best thing to use here (set the focus first).

BWT what's QSECOFR, or whatever you mean?
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1352739
Zif! You did it again! ;-)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Expert Comment

by:Matvey
ID: 1352740
You have  Windows.SetFocus( HWND ), and you can find the handle of a window, by it's title for example, using FindWindow and GetWindow (look in win32.hlp).

Sending keystrokes is either sending WM_KEYDOWN, WM_CHAR messages using SendMessage, or you have the Keybd_event function, which is the best thing to use here (set the focus first).

BWT what's QSECOFR, or whatever you mean?
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1352741
Have a look in the Extras\SendKeys directory on the Delphi CD. SendKeys.pas has an AppActivate routine where you supply a window name.
Also, there is SendKeys which takes a string, and a boolean wait value.
Might be just what you're looking for.

Cheers,
Phil.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1352742
I would prefer just sending WM_CHAR/WM_KEYDOWN/WM_KEYUP messages to the window without activating or focussing the it, because win98 sometimes makes problems with activating windows. Sometimes the program that you activated is in reality NOT activated, but only blinking in the taskbar.

Regards, Madshi.
0
 

Author Comment

by:wengwah
ID: 1352743
Forgot to mention that I'm really  new to Delphi 3/Win32 API programming.   I would appreciate some kind of roadmap on this.

Much appeciated the help and Merry Christmas!
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1352744
API is something that we aren't suppose to like much, but we have to learn to live with it.
API is based on handles and messages, which are simple constant numbers. Every object has it's handle (index), and you can access it with this handle, using API functions. These functions are simple DLL extracts, that are commonally used by all windows programming tools.
The best thing to do is register (free) in the MSDN, or use the SDK, which is mostly just Win32.HLP. You can find almost all documentation in there, though on MS site it's more organized and updated. (http://premium.microsoft.com/msdn/library/).

--Matvey
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1352745
Marry Christmass!
0
 
LVL 1

Expert Comment

by:adeng
ID: 1352746
In Windows 98, if your program that you activated is in reality NOT activated, but only blinking in  the taskbar try :

SetWindowPos(Handle, HWND_TOPMOST,
                         0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
SetWindowPos(Handle, HWND_NOTOPMOST,
                         0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);

it works for me.

0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question