c++ - look for keypress only if window is in focus -


i writing program interfaces testing equipment. want user able press button stop test, if program in focus. because can using pc other work @ same time. have now.

if ((getasynckeystate(vk_escape) & 0x8000)&&(getfocus() == findwindow(null,text("window name")))){

 break; 

}

the problem is, keypress still determined when user working on other programs. want happen without waiting user input program can continue running(i realize use threading think seems little overkill in case). if knows statement can use in second half of if statement great, or different method altogether.

thank you.

wild guess one. maybe use getforegroundwindow function , check handle against test window handle. possibly better method test window handle wm_keydown message. understanding message posted if window has focus.


Comments

Popular posts from this blog

asp.net mvc 3 - Using mvc3, I need to add a username/password to the sql connection string at runtime -

kineticjs - draw multiple lines and delete individual line -

thumbnails - jQuery image rotate on hover -