Hello,
im currently using this kind of Hotkey :

if(GetAsyncKeyState(VK_F1))
     {
          if (this->checkBox1->Checked == false)
		  {
               this->checkBox1->Checked = true;
		  }
          else
		  {
               this->checkBox1->Checked = false;
		  }
	  }

But its not very good.
I couldn't find a better way to do this :/
(im using Visual Studio 2008)

Anybody knows a better method for hotkeys ?

Recommended Answers

All 3 Replies

I can tell you GetAsyncKeyState will return true a million or so times per key press. You can check the return value for information about the keypress, it should return different values for key-down and key-up. Try this:

if(GetAsyncKeyState(VK_F1) == -32767)
{
  this->checkBox1->Checked = ! this->checkBox1->Checked;//Toggle
}

Thanks pseudorandom21.

But is there any way to use RegisterHotkey in windows form applications ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.