Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

SendKeys to a differnt application from System tray App

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Manoj Nair - 09 Aug 2005 07:02 GMT
Hi,

The problem :
Have a system tray application.This has a menu item 'Exit'.
On click of this a differnt application with a UI which runs in the
background should close.
The other application requires a Keyboard combination of Ctrl + Shift + Alt
+ X to close it properly.
After closing the other application the tray app should exit. (Process.Kill
cannot be used)
The following code doesnt work all the times.
Any Ideas.
Thanks in advance
------
//
//[DllImport("user32.dll")] public static extern int FindWindow(string
lpClassName,string lpWindowName);

int handle = Win32.FindWindow(null,"Basic Service");

//[DllImport("user32.dll")]public static extern bool SetForegroundWindow(int
hWnd);

Win32.SetForegroundWindow(handle);

handle = Win32.FindWindow(null,"Basic Service");

//[DllImport("user32.dll")]public static extern bool SetActiveWindow(int
hWnd);

Win32.SetActiveWindow(handle);

SendKeys.SendWait("+^%(x)");

processor.EndTasks();

noiIcon.Visible = false;

this.Close();

------------------------------
Jakob Christensen - 09 Aug 2005 07:33 GMT
It is probably not a good idea to rely on using SendKeys.  
Process.CloseMainWindow is the correct way to close another process.  This
will cause the message WM_QUIT to be send to the window of the other process
which is similar to having the user closing the application manually.

HTH, Jakob.
Signature

http://www.dotninjas.dk
http://www.powerbytes.dk

> Hi,
>
[quoted text clipped - 37 lines]
>
> ------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.