473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Focus issue

Tom
Another question relating to focus: Is it possible to set the focus to
another program's window and send it keystrokes, YET still keep my VB
program in the foreground (i.e. showing on the screen)? For instance, I want
to monitor another program's window and send keytstrokes to it, yet I want
my VB.NET program to remain in the foreground, where I will show progress
indicators.

Is this even possible in .NET? I believe it was in VB6 (cause I have a
program that did that) yet I can't get it to work in .NET

Tom
Nov 21 '05 #1
4 6414
Tom
Crouchie: Yes, this is an external application that I am calling. I want to
set focus to it (the external application) and send it keystrokes; however,
I would like to keep this external application in the background - i.e. keep
my application in the front.

So exactly which APIs must I call to do this? Thanks.

Tom

"Crouchie1998" <Cr**********@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Yes, it it possible.

Is the window you want to set focus to part of your application or external?
Does the window title change?

Obviously, to keep your window on top you can use:

Me.TopMost = True

However, there are a few ways to set the focus to the other application:

FindWindow API (Window text or class name)
GetProcessByName & Activate it are just a few ways
"Tom" wrote:
Another question relating to focus: Is it possible to set the focus to
another program's window and send it keystrokes, YET still keep my VB
program in the foreground (i.e. showing on the screen)? For instance, I want to monitor another program's window and send keytstrokes to it, yet I want my VB.NET program to remain in the foreground, where I will show progress indicators.

Is this even possible in .NET? I believe it was in VB6 (cause I have a
program that did that) yet I can't get it to work in .NET

Tom

Nov 21 '05 #2
Set your application to topmost:

Me.TopMost = True ' You application is now the TopMost windows.

Is the 'window caption' a constant value in your external application? If
so, you can use FindWindow to get its Handle etc.

Awaiting your reply to the Window Caption question
Nov 21 '05 #3
Tom
Crouchie: OK, I've set my TopMost to True (and set it to False when the form
is closing).

And yes, I believe that my window caption is a constant value. Actually, I
am using FindWindow, and FindWindowLike to get the handle of the
application; that I am not having a problem with. I just need to set the
focus to that external application (so I can send it keystrokes) yet keep
the other window in the front to display statistics (via a timer).

I've played around with SetFocusAPI, BringProcessToFront, SetToForeground,
etc; however, I am unsure as to exactly which one (if only one) I need to
use to accomplish this task.

One more thing: I find that if I have used one of these APIs to set focus to
the external application, it seems to have a hard time setting focus BACK to
my main VB.NET application once it gets done. I tried a simple Me.Focus but
the external application still stays up. Any ideas on that?

Tom

"Crouchie1998" <Cr**********@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
Set your application to topmost:

Me.TopMost = True ' You application is now the TopMost windows.

Is the 'window caption' a constant value in your external application? If
so, you can use FindWindow to get its Handle etc.

Awaiting your reply to the Window Caption question

Nov 21 '05 #4
Tom
Crouchie: Yep, TopMost worked great... now I can use the API calls to set
focus but the main VB.NET window stays in the forefront.

Now if I can just figure out why I can't reset focus back to the .NET form
when my sendkeys are done....

"Crouchie1998" <Cr**********@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
Set your application to topmost:

Me.TopMost = True ' You application is now the TopMost windows.

Is the 'window caption' a constant value in your external application? If
so, you can use FindWindow to get its Handle etc.

Awaiting your reply to the Window Caption question

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing...
5
by: tshad | last post by:
I have a date validation function that I want to stay at the object I am validating if there is a Validation error, but it always goes to the next object. The Javascript: function...
0
by: Steve Bezner | last post by:
I have an issue in which a link label on a windows form does not draw the focus rectangle if you programmatically force it to have focus via the Control.Focus() method. To duplicate, create...
0
by: Vinod. | last post by:
Hi all, I have added browser control to a windows form. I am loading pages having multiple frames. I have noticed that the focus in a text is not maintained when the application is deactivated....
1
by: avnrao | last post by:
Hi, I am facing a problem with control.focus (javascript). Here is the description of the issue. 1. I have 2 aspx files. on Aspx1 I have button named NewRow. Clicking on this, will redirect...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
9
by: Zytan | last post by:
http://msdn2.microsoft.com/en-us/system.windows.forms.control.focus(VS.80).aspx this page says: "Focus is a low-level method intended primarily for custom control authors. Instead, application...
22
by: alejandro | last post by:
Hey everyone, I'm currently working on a php project that started about 3 years ago (meaning, it's already quite large.). It uses quite a lot of pupups that seem to work great in all browsers......
2
by: pra__ | last post by:
Hi, i am designing a WYSIWYG editor. I want that when the user presses a 'TAB', a count of four spaces should be put. I used this code, <html> <head> <script> function chk(e){ if...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.