안녕하세요 저는 C#을 사용하여 (심지어 최소화 된 경우) 실행중인 다른 프로그램으로 창을 전환하려고합니다.C#을 사용하여 Windows를 전환하십시오.
왜 이것이 작동하지 않는지 궁금합니다.
오류 메시지 : 인수 1 :에 'System.Diagnostics.Process가'에서 변환 할 수 없습니다 'System.IntPtr 이름'
그것은 내가 PROC 변수가 적절한 참조 것이라고 생각 루프 안타 시간으로 윈도우 핸들러. 이것은 사실이 아닌가? 정말 도움을 주셔서 감사합니다. 미래의 독자
//declarations
using system.IO;
using System.Runtime.InteropServices;
//more
//namespace here
//class here
//initialize method
//related .dll import
[DllImport("user32.dll")]
public static extern void SwitchToThisWindow(IntPtr hWnd);
String ProcWindow = "itunes";
//function which calls switchWindow() is here but not important
//now we have switch window.
private void switchWindow()
{
Process[] procs = Process.GetProcessesByName(ProcWindow);
foreach (Process proc in procs)
{
//switch to process by name
SwitchToThisWindow(proc);
}
}
: 나는 또 다른 질문에서 내 코드에서이 지점에 도착. Correct way (in .NET) to switch the focus to another application
프로세스 개체가 프로세스 핸들 (intptr)이 아닙니다. 여기를보십시오 : http://stackoverflow.com/questions/1276629/c-sharp-get-running-process-given-process-handle – jwrush