c++ - Virtual Key combination -
this question has answer here:
- using getkeystate() 3 answers
i'm looking c++ virtual key combination, i'm looking simple key combination action. i'm trying shift+g work. i've tried know , it's given me different results nothing i'm trying do.
if (vk_shift & 0x47) // shift+g test { if(::getkeystate(0x47)<0); { cbaseitem* piteminfo = g_pitemtablehash->getdata( g_pmainplayer->m_pinv_guardian[0].getid()); if (guardian_item_type_adult == piteminfo->baseitem_guardian.btype) { if(cuserinterface::getinstance()->m_bguardian==false) { // on // ctds_dungeon_callgardian callguardinan; callguardinan.bzipcode = 0; g_pnet->sendmsg( (char*)&callguardinan, callguardinan.getpacketsize(), server_index_zone); } } } }
all matters first line, 1 know how can fix key combination shift+g works?
the biggest problem in code ;
@ end of
if(::getkeystate(0x47)<0); // !!!!!
the ;
causes following indented inner if-block executed in case !
here similar simplified code works well:
while(true) { if(::getkeystate(vk_shift) & 0x8000) // shift pressed ? { if(::getkeystate(0x47) & 0x8000) // if g pressed ? { std::cout << "shift g pressed" << std::endl; break; } else std::cout << "shift..." << std::endl; } } }
additional infos:
the expression (vk_shift & 0x47)
constant independent of input. vk_shift
0x10
, 0x10 & 0x47
yields 0. outer if-block gets never executed.
Comments
Post a Comment