Taking time out from AoE2 to implement it. Current progress.
Apparently just finished reading the Vocola 2 titlebar string that
looks something like this...
"^Destination Window Title^"
The carrot symbols are ignored, the titlebar text is between them.
Below... First is the updated but preliminary window switching
code. It's going in the DLL because it is systemwide (window
switching is usable in all programs). An exact window titlebar
match will have priority, after that it will search for partial
matches, and maybe then for a case insensitive match. I have no
plans to start applications with it, the window must be open or
minimized to the taskbar. Following that is the just finished
input reading code. EnumWinHandle() is before the keyboard hook in
the DLL file.
BOOL CALLBACK EnumWinHandle(HWND hWnd,LPARAM lparam)
{//look for matching window titlebar
if(IsWindowVisible(hWnd))
{//FND, normal window titles
GetWindowText(hWnd,TitleBar1,256);
if(strstr(TitleBar1,TitleText))
{//FND-NRM, activate the destination window
//FND-NRM-ACT, press alt key
ZeroMemory(SI,sizeof(INPUT));
SI[0].type=INPUT_KEYBOARD;
SI[0].ki.wVk=VK_MENU;
SI[0].ki.dwFlags=0;//press
SendInput(1,SI,sizeof(INPUT));
if(IsIconic(hWnd))
{//FND-NRM-ACT, restore destination window if minimized
OpenIcon((hWnd));
}//FND-NRM-ACT, restore destination window if minimized
else
{//FND-NRM-ACT, switch to destination window
SetForegroundWindow(hWnd);
}//FND-NRM-ACT, switch to destination window
//FND-NRM-ACT, release alt key
SI[0].ki.dwFlags=KEYEVENTF_KEYUP;
SendInput(1,SI,sizeof(INPUT));
return FALSE;//stop enumerating
}//FND-NRM, activate the destination window
}//FND, normal window titles
return TRUE;//continue enumerating
}//look for matching window titlebar
char TitleText[280]={};
BYTE KeyboardState[256]={};
char KeyInput[32]={};
if(GetTitle)
{//K, reading input for window switching
if((wParam==VK_6)&&(GetKeyState(VK_SHIFT)&0x8000))
{//K-IN, switch windows
if(KeyUp)
{//K-IN-SWITCH, upstroke
//EnumWindows(EnumWinHandle,NULL);
OutputDebugString(TitleText);
GetTitle=false;
*TitleText='\0';
}//K-IN-SWITCH, upstroke
return 1;
}//K-IN, switch windows
else
{//K-IN, add characters to titlebar search string
if(wParam!=VK_SHIFT)
{//K-IN-ADD, reject shift key
if(KeyUp)
{//K-IN-ADD-NIFT, upstroke
GetKeyboardState(KeyboardState);
ToAscii(wParam,MapVirtualKey(wParam,0),KeyboardState,(LPWORD)KeyInput,0);
strcat(TitleText,KeyInput);
}//K-IN-ADD-NIFT, upstroke
}//K-IN-ADD, reject shift key
return 1;
}//K-IN, add characters to titlebar search string
}//K, reading input for window switching
else
{//K
if((wParam==VK_6)&&(GetKeyState(VK_SHIFT)&0x8000))
{//K, begin reading titlebar text for window switching
if(KeyUp)
{//K-IN, upstroke
OutputDebugString("First ^, Start recording\n");
GetTitle=true;
}//K-IN, upstroke
return 1;
}//K, begin reading titlebar text for window switching
}//K