while( true ) { ReadTextFromWindow(Handle); if( qr/"Whatever triggers I need"/) { AddTextToWindow(Handle); } }