473,399 Members | 2,146 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,399 software developers and data experts.

how to activate an application?

in Visual Basic ,I use
Appactivate(AcadApp.caption);
Nov 16 '05 #1
10 16437
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);

Nov 16 '05 #2
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);

Nov 16 '05 #3
This approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);



Nov 16 '05 #4
This is approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);


Nov 16 '05 #5
This approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);



Nov 16 '05 #6
This approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);



Nov 16 '05 #7
This is approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);


Nov 16 '05 #8
This approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);



Nov 16 '05 #9
Manish,

Multiple instances of same application will have same titiles. To over come
this, we have to get process ids, to identify which one we want to activate.

for example

Process [] apps = Process.GetProcessesByName("TestAppName")

Now if we decide which one we want from this process list to be activated,
pass the handle to SetForegroundWindow() function to activate it.

example:

SetForegroundWindow(app[0].Handle.ToInt32 ()); //assuming that 1st process
id is the one we want to activate.

Shak.


"Manish Agarwal" <ma************@mphasis.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
This is approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);



Nov 16 '05 #10
Manish,

Multiple instances of same application will have same titiles. To over come
this, we have to get process ids, to identify which one we want to activate.

for example

Process [] apps = Process.GetProcessesByName("TestAppName")

Now if we decide which one we want from this process list to be activated,
pass the handle to SetForegroundWindow() function to activate it.

example:

SetForegroundWindow(app[0].Handle.ToInt32 ()); //assuming that 1st process
id is the one we want to activate.

Shak.


"Manish Agarwal" <ma************@mphasis.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
This is approach will not work when at user desktop there is an explorer
window open with same title as your application title.

--------------------------------------------
Manish Agarwal <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
This can be achieved by windows api's

Add the definitions inside your class

[DllImportAttribute( "User32.dll" )]
private static extern int FindWindow( String ClassName, String
WindowName );
[DllImportAttribute( "User32.dll" )]
private static extern int SetForegroundWindow( int hWnd );
//to activate an application
int hWnd = FindWindow( null, "This is my Application Title" );
if( hWnd > 0 )
{
SetForegroundWindow( hWnd );
}

Shak.
"zhou" <zy****@sohu.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
in Visual Basic ,I use
Appactivate(AcadApp.caption);



Nov 16 '05 #11

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

Similar topics

4
by: Milon | last post by:
Hi all, I am new to Python, and I just wrote a simple script to launch an application from the windows's start menu's run command. (see code as follow) There is an "OK" button on the new...
1
by: LarsJ | last post by:
Hi, can please MS answer this question: Is there any way for an desktop application to make it the active application (= the application window is highlighted and in front)? Or is there any way...
4
by: bughunter | last post by:
In version 7.x connect to db activate db db SQL1494W Activate database is successful, however, there is already a connection to the database. works fine - db activated. In 8.x - No!...
1
by: Bsiang Tan | last post by:
Is there any way to activate or bring the process to front ? For example, my application will run the windows calculator. After certain process, I will need to activate the calculator... I know...
5
by: juststarter | last post by:
hi there here is my problem : there is a main form (frmMain) which calls a searchForm (frmSearch). Then i select an item (from the returned ones) and open a third form (frmData). Taking from...
0
by: venkat | last post by:
Hi, I have migrated application code to c#2.0 and when I build the solution I am getting the following warning. My application interacts with Excel. So I need to invoke different methods on...
2
by: Dave Booker | last post by:
I have a Windows form application that I generally run minimized. When a critical event occurs it instantiates another "Alert" form which I want to grab the user focus. In the Alert constructor...
0
by: LostInMD | last post by:
Hi, I am loading word with vb2005 customized commandbars. During the load of the Word exe, the exe automatically opens a new document. I am having difficulty "activating" the open document...
0
by: =?Utf-8?B?Um9nw6lyaW8gRmVycmVpcmE=?= | last post by:
First of all, I'd like to say that it's not easy to figure out the behavior of ToolStripMenuItem Visible property. I have replaced my Windows Forms 1.1 MainMenus with the new MainMenuStrip when...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...

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.