473,507 Members | 9,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I set focus to an external application?

HaLo2FrEeEk
404 Contributor
I've tried

[DllImport("User32.dll")]
private static extern IntPtr SetFocus(HandleRef hWnd);

And it's not wanting to work. I've tried passing both the process handle and the main window handle to the method with this code

SetFocus(new HandleRef(null, Process.MainWindowHandle));

And it just won't do it. I know I have the right handle because I'm using GetWindowRect() to get the size and location of the window, so why can't I set it's focus?
Nov 16 '10 #1
2 4093
Curtis Rutland
3,256 Recognized Expert Specialist
Use SetForegroundWindow.
Nov 16 '10 #2
HaLo2FrEeEk
404 Contributor
Ok that works, but only if the window in question is not minimized. Is there a way to detect the windowstate of an external application? I'm looking at GetWindowInfo(), but it returns a WINDOWINFO object and I don't know how to get at that.
Nov 17 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3558
by: Juan Manuel Alegría B. | last post by:
Hi group I have been making a windows service to execute an external application. I use a timer control, I can execute the application but does't appear as a normal windows, just I see it in the...
4
4943
by: Sivakumar Shanmugam | last post by:
Group.. We are running on db2 UDF V8 on Sun solaris platform. I created an UDF which calles a C-routine(SQL_API_FN). This C-routine in turn calls an external C-function. The C-function is provided...
2
3592
by: Tiago Costa | last post by:
I there!!! How can i call an external application?? For example SKYPE? thanks in advance. Tiago Costa
1
1211
by: VB User | last post by:
I have to start an external imaging application in the splash screen of my application. But this external application appears in the foreground when the main screen is displayed until I manually...
0
843
by: Paul Bromley | last post by:
Can anyone tell me if it is possible to use a contextmenu from my application as a contextmenu for an external application - i.e. suppress the centextmenu of the external application. Altrenativley...
2
2118
by: Lonifasiko | last post by:
Hi group, I must launch from my Winforms application another application (.exe developed by the client) which response time sometimes can be more or less 30 seconds. I'm using ProcessManager...
4
4858
by: Rico | last post by:
Hello, I have an Access application and I would like to not only run an external application, but at the point in the code where it is run, I'd like to wait for the external applicaiton to...
1
2990
by: cvairetti | last post by:
Hi, I just write an application in C# that show an interface with five button, each button starts an external application that it comes in front of the main C# application with focus on. When the...
0
1116
by: Martin2007 | last post by:
HI, I'm fairly new to VB.net and am trying to write an application that controls another. Basically at the moment I'm using the SendKeys function to control it as the external application has no...
1
1598
by: JasonT | last post by:
Hi. I have created a dll in VC++ 08 that exports a CLR windows form class. I call into this dll from an external (closed source, third-party) application to instantiate the form and embed it into...
1
7030
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...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.