#include "stdafx.h"
#include "Keybd.h"
#include "sipapi.h"
#include "aygshell.h"
#include "imm.h"
#pragma comment (lib,"aygshell.lib")
//-------------------------------------------
// Global Variables and Function Declaration
//-------------------------------------------
HWND m_hWnd;
void IME_Test();
int SipEnumIMProc(IMENUMINFO* pIMInfo);
//add yxchen
CLSID g_SipClsid[20];
int g_index=0;
int g_nIMs = 0;
void IME_Chs2Eng(HWND hwnd);
int SipEnumIMProc(IMENUMINFO* pIMInfo)
{
if (g_index < g_nIMs)
{
g_SipClsid[g_index] = pIMInfo->clsid;
g_index++;
return g_index;
}
g_index = 0;
return 0;
}
// GET input method
void IME_Test()
{
int index=0;
TCHAR szBuffer[10];
HWND hWnd;
g_nIMs = SipEnumIM(NULL);
IMENUMPROC pEnumIMProc = SipEnumIMProc;
index=SipEnumIM(pEnumIMProc);
// wsprintf(szBuffer,L"%d",index);
// MessageBox(NULL,szBuffer,_T(""),MB_OK);
for(int i=0 ;i< 3;i++)
{
SipShowIM(SIPF_ON);
SipSetCurrentIM(&g_SipClsid[2]);
Sleep(2000);
SipShowIM(SIPF_OFF);
Sleep(1000);
}
}
void IME_Chs2Eng(HWND hwnd)
{
HKL hkl = GetKeyboardLayout(0);
if (ImmIsIME(hkl))
ImmSimulateHotKey(hwnd, IME_CHOTKEY_SYMBOL_TOGGLE);
}
void IME_Eng2Chs(HWND hwnd)
{
HKL hkl = GetKeyboardLayout(0);
if (!ImmIsIME(hkl))
ImmSimulateHotKey(hwnd, IME_CHOTKEY_IME_NONIME_TOGGLE);
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HWND hWnd = GetForegroundWindow(); ;
if(hWnd == NULL)
{
return 0;
}
HWND hwndChild = ::GetWindow(hWnd, GW_CHILD);
while(hwndChild)
{
SendMessage(hWnd, 0x287, 0x30, 0x0);
hwndChild = ::GetWindow( hwndChild, GW_HWNDNEXT);
}
return 0;
}