I need to do a button which has same functionality as PTT (Press to Talk).
So, you press and keep the button pressed - it does some function.
On release of the button, do something else.
while (button.pressed)
do something
on release
do something
ps. I found this code in a Forum, but it is not working. Nothing happens on pressing the button.
isLooping = false;
//on mouse down
private void myControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) {
isLooping = true;
runLoop();
}
//on mouse up event
private void myControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) {
isLooping = false;
}
//This is the main loop you care about. Put this in your application
//This should go in its own thread
void runLoop() {
while (isLooping) {
//do stuff
}
}
VulpesPosted Aug 30, 2011, 4:23 AM
Ganeshan RPosted Aug 4, 2017, 8:11 AM
Asterix ObelixPosted Aug 30, 2011, 5:40 AM
Sam HobbsPosted Aug 29, 2011, 9:01 PM
One of the many reasons for making a new thread is that the question about a hotkey is very unclear to me. I am very confused about what that actually means, but I won't even try to get clarification in this thread.
Asterix ObelixPosted Aug 29, 2011, 7:49 PM
I tried what you suggested for the Hotkey, but it is not working.
Maybe I need also to link the methods (events) that you suggested as in the previous case?
I thought of putting the following link on form_load, but a detail is missing since it is not working:
this.button2.KeyDown += new KeyEventHandler(Form1_KeyDown);
this.button2.KeyUp += new KeyEventHandler(Form1_KeyUp);
VulpesPosted Aug 29, 2011, 11:55 AM
Asterix ObelixPosted Aug 29, 2011, 10:55 AM
I would like to ask another think.
How can I link a Hotkey to do this functionality of pressing the Button?
Thank you again!
VulpesPosted Aug 29, 2011, 10:45 AM
Asterix ObelixPosted Aug 29, 2011, 9:57 AM
But still, what should I add on the button itself (button click)?
Here is the code:
private void button1_Click_1(object sender, EventArgs e)
{
}
private void OnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Skype.Attach(6, true);
SKYPE4COMLib.Command command1 = new SKYPE4COMLib.Command();
command1.Command = "SET MUTE OFF";
command1.Blocking = false;
command1.Id = 1000;
Skype.SendCommand(command1);
}
//on mouse up event
private void OnMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Skype.Attach(6, true);
SKYPE4COMLib.Command command1 = new SKYPE4COMLib.Command();
command1.Command = "SET MUTE ON";
command1.Blocking = false;
command1.Id = 1000;
Skype.SendCommand(command1);
}
Jaganathan BantheswaranPosted Aug 29, 2011, 9:52 AM
Asterix ObelixPosted Aug 29, 2011, 9:34 AM
__________________________________
void runLoop2() {
Skype.Attach(6, true);
SKYPE4COMLib.Command command1 = new SKYPE4COMLib.Command();
command1.Command = "SET MUTE ON";
command1.Blocking = false; command1.Id = 1000;
Skype.SendCommand(command1);
}
_______________________________
So, my idea is to mute the microphone on Pressed and on released unmute.
Jaganathan BantheswaranPosted Aug 29, 2011, 9:23 AM
Put break point on both events and the loop. check whether the isLooing is getting changed while press and release.
Asterix ObelixPosted Aug 29, 2011, 9:20 AM
Jaganathan BantheswaranPosted Aug 29, 2011, 9:18 AM
I cant find out any MouseDown event handler in that code.... Change the first _MouseUp event handler to _MouseDown.