728x90
반응형
728x170
using System;
using System.Runtime.InteropServices;
using System.Text;
#region 작업 보기 모드 여부 구하기 - IsTaskViewMode()
/// <summary>
/// 작업 보기 모드 여부 구하기
/// </summary>
/// <returns>작업 보기 모드 여부</returns>
public bool IsTaskViewMode()
{
IntPtr foregroundWindowHandle = GetForegroundWindow();
if(foregroundWindowHandle == IntPtr.Zero)
{
return false;
}
StringBuilder windowTextStringBuilder = new StringBuilder(100);
GetWindowText(foregroundWindowHandle, windowTextStringBuilder, 100);
string windowText = windowTextStringBuilder.ToString();
return windowText == "작업 보기" || windowText == "Task View";
}
#endregion
#region 전경 윈도우 구하기 - GetForegroundWindow()
/// <summary>
/// 전경 윈도우 구하기
/// </summary>
/// <returns>윈도우 핸들</returns>
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
#endregion
#region 윈도우 텍스트 구하기 - GetWindowText(windowHandle, stringBuilder, maximumCount)
/// <summary>
/// 윈도우 텍스트 구하기
/// </summary>
/// <param name="windowHandle">윈도우 핸들</param>
/// <param name="stringBuilder">문자열 빌더</param>
/// <param name="maximumCount">최대 카운트</param>
/// <returns>윈도우 텍스트</returns>
[DllImport("user32.dll")]
private static extern int GetWindowText(IntPtr windowHandle, StringBuilder stringBuilder, int maximumCount);
#endregion
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] ManagementObjectSearcher 클래스 : 프로세스 정보 구하기 (0) | 2021.04.10 |
---|---|
[C#/COMMON] Process 클래스 : Modules 속성을 사용해 프로세스 모듈 정보 구하기 (0) | 2021.04.10 |
[C#/COMMON] Process 클래스 : Threads 속성을 사용해 프로세스 스레드 정보 구하기 (0) | 2021.04.10 |
[C#/COMMON] Process 클래스 : GetProcessById 정적 메소드를 사용해 전경 프로세스 구하기 (0) | 2021.04.07 |
[C#/COMMON] 너비가 0인 공백 문자 제거하기 (0) | 2021.04.05 |
[C#/COMMON] 모든 UWP 애플리케이션의 윈도우 최소화하기 (0) | 2021.04.03 |
[C#/COMMON] 오픈 윈도우 핸들 딕셔너리 구하기 (0) | 2021.04.03 |
[C#/COMMON] 한글 윈도우즈 10에서 계산기 UWP 앱 윈도우 최소화하기 (0) | 2021.04.02 |
[C#/COMMON] 프로세스 ID를 사용해 윈도우 핸들 리스트 구하기 (0) | 2021.04.02 |
[C#/COMMON] 누겟 설치 : InputSimulator (0) | 2021.03.27 |
댓글을 달아 주세요