PC 프로그램에서 카카오 PC 대화방에 특정 메세지를 전달하는 코드다.
1
2 |
[System.Runtime.InteropServices.DllImport("User32", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); |
cs |
FindWindow 를 통해서 대화창 프로세스 정보를 가져온다.
1
2
3
4
5
6
7
8
9
10 |
IntPtr hd01 = FindWindow(null, "카카오톡 대화방 제목");
if (hd01 != IntPtr.Zero)
{
IntPtr hd03 = FindWindowEx(hd01, IntPtr.Zero, "RichEdit20W", "");
if (hd03 != IntPtr.Zero)
{
SendMessage(hd03, 0x000c, 0, "전달할 말");
PostMessage(hd03, 0x0100, 0xD, 0x1C001);
}
} |
cs |
위 코드를 실행하면 PC 카카오톡 대화방 창을 찾은 후 메세지를 전달할 수 있다.