Skip to content

Instantly share code, notes, and snippets.

@ropo
Created April 16, 2012 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ropo/2398910 to your computer and use it in GitHub Desktop.
Save ropo/2398910 to your computer and use it in GitHub Desktop.
(」・ω・)」うー! (/・ω・)/にゃー!
// archive http://arc.ropo.jp/git/unyaHack.zip
#include <Windows.h>
#include <tchar.h>
#include <map>
#include <string>
#include <signal.h>
using namespace std;
typedef map<HWND,wstring> WNDMAP;
typedef pair<HWND,wstring> WNDPAIR;
volatile bool escape = false;
BOOL CALLBACK enumWinProc( HWND hWnd, LPARAM lParam )
{
WNDMAP *pMap = (WNDMAP*)lParam;
RECT rect;
wchar_t str[256];
GetWindowRect( hWnd, &rect );
if( rect.left >= rect.right || rect.top >= rect.bottom )
return TRUE;
GetWindowText( hWnd, str, sizeof(str) );
pMap->insert( WNDPAIR( hWnd, str ) );
return TRUE;
}
void sigcatch( int sig )
{
escape = true;
}
int _tmain(int argc, _TCHAR* argv[])
{
WNDMAP maps;
EnumWindows( enumWinProc, (LPARAM)&maps );
if (SIG_ERR == signal(SIGINT, sigcatch))
return 1;
puts("Ctrl+Cで終了");
wchar_t *strs[2]={L"(」・ω・)」うー!",L"(/・ω・)/にゃー!"};
int i=0;
while(!escape)
{
for( WNDMAP::iterator itr=maps.begin(); itr!=maps.end(); ++itr )
SetWindowText( itr->first, strs[i&1] );
Sleep( 1000 );
i++;
}
for( WNDMAP::iterator itr=maps.begin(); itr!=maps.end(); ++itr )
SetWindowText( itr->first, itr->second.c_str() );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment