수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

가상키보드 후킹문제...한글입력이 ㄱ ㅏ ㄹ 이런식..

마디

2023.04.01



dotum

#pragma data_seg(shardata)
static hwnd hwndmain = null;
static hwnd hwndmainfrm = null;
static hinstance hinstance;
static hwnd hwndprevfocused = null;
static hwnd hwndprevforeground = null;
static hwnd hwndprevfocusedmainfrm = null;
#pragma data_seg()
hhook myhhookmouse, myhhookkeyboard, myhhookcbt, myhhookcallwndproc;
hwnd hwndtempforeground, hwndtempfocused;
char str[100];
static bool iseng = true;
#define wm_keyboardclicked wm_user + 10
#define wm_ime_state_eng wm_user + 11
#define wm_ime_state_han wm_user + 12
int far pascal initkeyboarddll(hwnd hmain, hwnd hwndmainfrm);
int far pascal installhook();
int far pascal showkeyboard();
int far pascal uninstallhook();
int far pascal hidekeyboard();
lresult callback mymousehookingproc(int ncode, wparam wparam, lparam lparam);
lresult callback mykeyboardhookingproc(int ncode, wparam wparam, lparam lparam);
lresult callback mycallwndproc(int ncode, wparam wparam, lparam lparam);int far pascal initkeyboarddll(hwnd hmain, hwnd hwndmainfrm)
{
cstring strmyclass;
hinstance = theapp.m_hinstance;
rect keyboardrect = {100, 100, 700, 400};
strmyclass = afxregisterwndclass(
cs_vredraw | cs_hredraw,
loadcursor(null, idc_arrow),
(hbrush) getstockobject(white_brush),
0);
myckeywnd.createex(0, strmyclass, mywnd,
ws_popup|ws_visible|ws_ex_topmost, crect(12,473,809,681), cwnd::fromhandle(hmain), null);
setwindowpos(myckeywnd.m_hwnd, hwnd_topmost, 12, 473, 797, 208, swp_noactivate | swp_hidewindow);
myckeywnd.m_fiseng = iseng;
hwndmain = myckeywnd.m_hwnd;
hwndmainfrm = myckeywnd.m_hwnd;
return 1;
}

int far pascal installhook()
{
myhhookcallwndproc = setwindowshookex(wh_callwndproc, (hookproc)mycallwndproc, hinstance, 0);
myhhookmouse = setwindowshookex(wh_mouse, (hookproc)mymousehookingproc, hinstance, 0);
myhhookkeyboard = setwindowshookex(wh_keyboard, (hookproc)mykeyboardhookingproc, hinstance, 0);
return 1;
}

int far pascal uninstallhook()
{
//if(myhhookcallwndproc) unhookwindowshookex(myhhookcallwndproc);
if(myhhookmouse) unhookwindowshookex(myhhookmouse);
if(myhhookkeyboard) unhookwindowshookex(myhhookkeyboard);
if(myhhookcbt) unhookwindowshookex(myhhookcbt);
if(myhhookcallwndproc) unhookwindowshookex(myhhookcallwndproc);
return 1;
}
lresult callback mycallwndproc(int ncode, wparam wparam, lparam lparam)
{
lppoint lpcurpos = new point;
rect wndrect;
pcwpstruct pparamstruct;
pparamstruct = (pcwpstruct)lparam;
if(ncode 0)
{
if(pparamstruct-message == wm_activate)
{
if(getcursorpos(lpcurpos)) //현재 커서의 위치를 구해서
{
if(getwindowrect(hwndmain, &wndrect)) // 현재 키보드의 영역안에 커서가 있으면
{
if(ptinrect(&wndrect, *lpcurpos))
{
// sleep(1);
setforegroundwindow((hwnd)pparamstruct-wparam);
return true;
}
}
}
}
}
return callnexthookex(myhhookcallwndproc, ncode, wparam, lparam);
}lresult callback mymousehookingproc(int ncode, wparam wparam, lparam lparam)
{
if(ncode=0)
{
if(wparam == wm_lbuttondown)//왼쪽 클릭된 위치가 키보드의 화면이면 사용자 메세지를 키보드프로그램으로 보내고 아니면 그냥 통과
{
if(((lpmousehookstruct)lparam)-hwnd == hwndmain) // 키보드윈도우의 핸들과 같으면
{
if(getforegroundwindow() != hwndprevforeground && hwndprevfocused)
{
setforegroundwindow(hwndprevforeground);
if(getfocus() != hwndprevfocused && hwndprevfocused)
setfocus(hwndprevfocused);
}
postmessage(hwndmain, wm_keydown, (wparam)lparam, (lparam)hwndprevforeground);
sleep(300);
return true;
}
else if(((lpmousehookstruct)lparam)-hwnd)
{
}
}
else if(wparam == wm_lbuttonup)
p;{
if(((lpmousehookstruct)lparam)-hwnd != hwndmain && ((lpmousehookstruct)lparam)-hwnd)
{
hwndtempforeground = getforegroundwindow();
hwndtempfocused = getfocus();
if(!hwndtempforeground || hwndtempforeground == hwndprevforeground)
hwndtempforeground = getforegroundwindow();
if(!hwndtempfocused || hwndtempfocused == hwndprevfocused)
hwndtempfocused = getfocus();

hwndprevfocused = hwndtempfocused;
hwndprevforeground = hwndtempforeground;
}
}
}
return callnexthookex(myhhookmouse, ncode, wparam, lparam);
}
lresult callback mykeyboardhookingproc(int ncode, wparam wparam, lparam lparam)
{
lppoint lpcurpos = new point;
//rect wndrect;
if(ncode == hc_action)
{
if((wparam == 229 && lparam == -2147483647)||(wparam == 229 && lparam == -2147483648.0))
{

return true;
}

}
return callnexthookex(myhhookkeyboard, ncode, wparam, lparam);
}

이런식으로 후킹하는 걸 인터넷 소스 참고했는데...
한글입력시 ㄱ ㅏ ㄴ 이런식으로 조합이 안됩니다. 포커스 문제라는거같은데...어떻게 해야할까요?

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2694921 보더 레이아웃 안에 플로우 레이아웃 넣는방법? 초롱 2025-05-15
2694894 웹 프로그래밍 관련해서 질문합니다. 창의적 2025-05-15
2694868 컨택트 폼 7에서 textarea 높이 조정 영글 2025-05-15
2694818 line-height값이 적용이 안되는데 왜 그런 거예요?. letter-spacing,line-height의 기준?? (2) 풍란 2025-05-14
2694795 이것 어떻게 좀 해결좀;; (3) 개럭시 2025-05-14
2694724 코딩시 폰트 문제; ㅠ 후력 2025-05-13
2694696 텍스트박스 입력에 관한 문제입니다. 딥공감 2025-05-13
2694668 [질문] 페이퍼비전 PointLight 관련 질문 드려요.. 두바다찬솔 2025-05-13
2694611 Flash Lite 2.1에서 BitmapData와 Matrix 지원안하나요? (3) 이플 2025-05-12
2694582 IE & 파이어폭스 (2) 흙이랑 2025-05-12
2694553 무비클립안의 duplicate 발동이 안돼네요; 딥보라 2025-05-12
2694523 자바 애플릿 질문좀 ^^ (6) 동이 2025-05-12
2694494 [질문] JAVA 또는 C++ 로 프로그램 개발시.. 레지스터리 등록 관련 의문점? (3) 우람늘 2025-05-11
2694469 익스6에서 css버그 나오는것 해결방법좀요 !!!! (6) 원술 2025-05-11
2694442 로컬에선 잘 나오는데 운영에 반영하면 이상하게 나와요. (8) 목화 2025-05-11
2694412 [질문] 이미지 로딩후 사이즈 조절할때 (1) 아담 2025-05-11
2694391 설치형 블로그 쓰시는 분들 어떤거 쓰세요?? (7) AngelsTears 2025-05-10
2694362 Microsoft SQL Server에서 서버만드는법 어둠 2025-05-10
2694333 for문으로 돌린 이름의 제어 (4) 레이 2025-05-10
2694308 이미지 css 도와주세요 ㅠㅠ (2) 애기 2025-05-10
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com