0

I'm trying to close windows on-screen keyboard (osk.exe) in c++ code, but without any success.

HWND kbIsOpen = FindWindow(TEXT("OSKMainClass"),NULL);
CloseWindow(kbIsOpen);  

CloseWindow or SendMessage didn't to anything. Note that the problem is not in kbIsOpen, and also getLastError returns 5 (ERROR_ACCESS_DENIED).

What I can do to deal with this problem?

vivekagr
  • 1,786
  • 15
  • 23
DuduE
  • 21
  • 4

1 Answers1

2

Assuming FindWindow returns a valid window handle, SendMessage(kbIsOpen, WM_DESTROY, NULL, NULL); should close it. (Although it's kind of a dangerous way to do it. Try sending WM_CLOSE and WM_QUIT first.)

However, it's possible that the keyboard window throws away destroy messages, and just keeps on going no matter what you throw at it. I'm running Windows 7, so I can't tell you myself.

< unimportant opinion > bkIsOpen sounds like the name of a boolean variable telling you if the window is open, not a handle to the window if it exists. < /unimportant opinion >

Proxy
  • 1,824
  • 1
  • 16
  • 27