For Programmers: Free Programming Magazines  


Home > Archive > C# > June 2006 > how can I switch tasks thru code in C#









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how can I switch tasks thru code in C#
KeyboardSurfer

2006-06-17, 7:02 pm

I am still having problems with switching thru tasks in such a way that it
will work properly for me ... here is the basic information and a code
snippet follows below , a bitmap is included to make the situation more
clear.



My program is running and I need to switch to another (directx based)
program already running as a task. The code I have so far works when only my
program and the ProgramToSwitchTo are running , if I have something else
running like notepad it first A) goes into the ProgramToSwitchTo and
then B) jumps right out again and goes right into notepad or whatever else
I might have running... Note if I come out of my program to the desktop and
then click on the ProgramToSwitchTo BUTTON , it will go in and work just
like any normal button click from the desktop with do . I would be happy
coding something that does it that way , or ANY other way ...

Since I can't , as per usual get any information from MSDN or anywhere on
the net , so far , I appeal to all you brainiacs to see if there is a
workable solution out there !!!









________________________________________
_________________________________





if (proc.ProcessName == "ProgramToSwitchTo")


{


/*if (SetForegroundWindow(proc.MainWindowHandle)==false)

{

MessageBox.Show("cant switch to ProgramToSwitchTo") ;

return;

}*/

ShowWindow(proc.MainWindowHandle,1);

Form1_Resize(this,e);

break;

}




----------------------------------------------------------------------------
----





KeyboardSurfer

2006-06-17, 7:02 pm

I am still having problems with switching thru tasks in such a way that it
will work properly for me ... here is the basic information and a code
snippet follows below ..


My program is running and I need to switch to another (directx based)
program already running as a task. The code I have so far works when only my
program and the ProgramToSwitchTo are running , if I have something else
running like notepad it first A) goes into the ProgramToSwitchTo and
then B) jumps right out again and goes right into notepad or whatever else
I might have running... Note if I come out of my program to the desktop and
then click on the ProgramToSwitchTo BUTTON , it will go in and work just
like any normal button click from the desktop with do . I would be happy
coding something that does it that way , or ANY other way ...

Since I can't , as per usual get any information from MSDN or anywhere on
the net , so far , I appeal to all you brainiacs to see if there is a
workable solution out there !!!









________________________________________
_________________________________





if (proc.ProcessName == "ProgramToSwitchTo")


{


/*if (SetForegroundWindow(proc.MainWindowHandle)==false)

{

MessageBox.Show("cant switch to ProgramToSwitchTo") ;

return;

}*/

ShowWindow(proc.MainWindowHandle,1);

Form1_Resize(this,e);

break;

}






KeyboardSurfer

2006-06-17, 7:02 pm

anyone know how to "fake" a taskbar click from windows ?? I am getting
desperate here !!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com