Hi Gal,
you could maybe create a thread that runs in the background and listens for key presses, I know I did something similar but for mouse events, it might be that the principle is similar, let me know if you'd be interested in what I have.
Yacine Benahmed
Hi Gal, I veryfied my code, however I dont know how you could modify it to listen to keypress events. private void Listen_To_The_Mouse()
private: void Create_MouseListener()
{
th_MouseListener = new Thread(new ThreadStart(this, &Form1::Listen_To_The_Mouse));
th_MouseListener->set_Priority(ThreadPriority::Lowest);
th_MouseListener->Start();
}
{
String *position;
String *str_xy[] = {S"",S""}; //needed for the string containing the coordinates
String *sep = " , "; //separates x y
while(1) //infinite loop
{
th_MouseListener->Sleep(1); //Process sleeps 10ms or else takes to much cpu time
str_xy[0] = System::Convert::ToString(Control::MousePosition.get_X());
str_xy[1] = System::Convert::ToString(Control::MousePosition.get_Y());
position = String::Join(sep, str_xy);
txt_Valeur->Text = position;
txt_Valeur->AppendText(System::Convert::ToString0(Control::get_MouseButtons()));
System::GC::Collect(); //garbage collection
}
}
Yacine Benahmed