윈도우 타이틀명을 인지 못하는것인지... 어찌해도 자꾸 확인불가만 뜨네요.. ㅜㅜ
인터넷에 윈도우타이틀명에 대해 찾는걸 검색해봐도, 제깐에 할 수 있는 방법은 다 해본 것 같은데. 기본적인것일지 모르겠으나 도움 한번 부탁드립니다 ㅠㅠ
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenCvSharp;
using System.Diagnostics;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
[System.Runtime.InteropServices.DllImport("User32", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string IpClassName, string IpWindowName);
[System.Runtime.InteropServices.DllImport("user32.dll")]
internal static extern bool PrintWindow(IntPtr hWnd, IntPtr hdcBlt, int nFlags);
//프로그램창 대상
string AppPlayerName = "notepad";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
IntPtr findwindow = FindWindow(null, AppPlayerName);
if(findwindow != IntPtr.Zero)
{
Debug.WriteLine("창 확인");
Graphics Graphicsdata = Graphics.FromHwnd(findwindow);
Rectangle rect = Rectangle.Round(Graphicsdata.VisibleClipBounds);
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
using (Graphics g = Graphics.FromImage(bmp))
{
IntPtr hdc = g.GetHdc();
PrintWindow(findwindow, hdc, 0x0);
g.ReleaseHdc(hdc);
}
pictureBox1.Image = bmp;
}
else
{
Debug.WriteLine("확인불가");
}
}
}
}
FindWindow로 notepad 불러오는 거 어떻게 하는지 검색해봐
감사합니다 ㅠㅠㅠㅠㅠ 열심히하겠습니다