Rumor as prophecy in Win32

by Michael S. Kaplan, published on 2007/10/11 10:31 -04:00, original URI:

Have you ever caused (or at least inspired) an event to happen by starting a rumor that it was happening?

It can make for an interesting technique to solve the problem pointed out at the beginning of the year in The 'in' process for out of process keyboard work where the goal was to change the keyboard layout within a process other than the one in which your code is running.

The trick? As Haali pointed out in a comment:

Actually you can (ab)use WM_INPUTLANGCHANGEREQUEST. The documentation for that message says that DefWindowProc will do the needed changes, and indeed it works fine most of the time (I know it doesn't work for some input fields in Outlook).

Obviously the intent of the notification is to allow an application to accept or deny a keyboard change attempted by a user.

But if, instead of waiting for a user to try and change the keyboard, you "start a rumor" that the user tried to make this change, then you can in many cases get the application to pass the message on and see the application pass the message on and cause the very change you are looking for to happen!

Now it is important to note that even though the Text Services Framework caused the WM_INPUTLANGCHANGEREQUEST message to not be passed to the application (ref: What broke the input language messages?), that you can still take advantage of the notification to have another process switch.

The application still gets the final word in this case (as it should), but even so this is a technique to be used only sparingly, as it is in most cases incredibly obnoxious to change people's keyboard layouts out from under them.

It also won't always work since some people have switch to use the Text Services Framework methodology here and know to not pass on the notification.

But as tricks go it will work some of the time....


This post brought to you by "" (U+a056, a.k.a. YI SYLLABLE BBIT)

no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2008/06/02 One keyboard to rule them all?

go to newer or older post, or back to index or month or day