1
크롬 창을 포 그라운드로 설정하고 활성화하여 키보드 포커스를 얻으려고합니다. 내 코드는 메모장이나 IE에서 작동하지만 Chrome에서는 작동하지 않습니다.크롬 창을 활성화 설정 중 (C++)
//Getting the HWND of Chrome
HWND chromeWindow = FindWindow("Chrome_WidgetWin_1", NULL);
DWORD dwCurrentThread = GetCurrentThreadId();
DWORD dwFGThread = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
AttachThreadInput(dwCurrentThread, dwFGThread, TRUE);
//Actions
AllowSetForegroundWindow(ASFW_ANY);
bool fore =SetForegroundWindow(chromeWindow);
if(fore==false){cout << "fore failed"<<endl;}
bool capture = SetCapture(chromeWindow);
if(capture==false){cout << "capture failed" <<endl;}
bool focus = SetFocus(chromeWindow);
if(focus==false){cout << "focus failed"<<endl;}
bool active = SetActiveWindow(chromeWindow);
if(active==false){cout << "active failed"<<endl;}
//Finishing
AttachThreadInput(dwCurrentThread, dwFGThread, FALSE);
코드는 전경에 Google 크롬 창을 설정하지만 나에 키보드 초점을 활성화하지 않습니다. 나는 무엇이 잘못되었는지 모른다. 표시되는 결과는 다음과 같습니다.
capture failed.
focus failed.
active failed.
어떻게해야합니까?