Skip to content

Instantly share code, notes, and snippets.

@rchl
Created February 13, 2013 20:43
Show Gist options
  • Save rchl/4948061 to your computer and use it in GitHub Desktop.
Save rchl/4948061 to your computer and use it in GitHub Desktop.
// Activate window with specified title.
//
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char* argv[])
{
if (argc < 2)
{
cout << "Usage: showwindow.exe <window_title>" << endl;
return -1;
}
HWND target_hwnd = FindWindowA(NULL, argv[1]);
if (!target_hwnd)
{
cout << "No window with specified title was found!" << endl;
return -1;
}
if (GetForegroundWindow() != target_hwnd)
SetForegroundWindow(target_hwnd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment