Click here to Skip to main content
15,892,674 members

Comments by jon-80 (Top 49 by date)

jon-80 18-Jun-14 6:34am View    
Well this is helpful however, I was actually reading XML not writing :)
jon-80 19-Feb-12 3:12am View    
Well, it does not quite work well, somehow, since only the number key 1 seems to work, any idea why?

<pre>

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

//initialize keyboard shortcuts (1 to 9, the decimal point, and, multiplication operators (+,-,*,/)
this.btn1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn1_KeyPress);
this.btn2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn2_KeyPress);
this.btn3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn3_KeyPress);
this.btn4.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn4_KeyPress);
this.btn5.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn5_KeyPress);
this.btn6.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn6_KeyPress);
this.btn7.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn7_KeyPress);
this.btn8.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn8_KeyPress);
this.btn9.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn9_KeyPress);
this.btn0.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn0_KeyPress);
this.btnDecimal.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnDecimalPoint_KeyPress);
this.btnAdd.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnAdd_KeyPress);
this.btnSubtract.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnSubtract_KeyPress);
this.btnMultiply.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnMultiply_KeyPress);
this.btnDivide.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btnDivide_KeyPress);
}

private void btn1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 49)
{
btn1.PerformClick();
}
}

private void btn2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 50)
{
btn2.PerformClick();
}
}

private void btn3_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 51)
{
btn3.PerformClick();
}
}

private void btn4_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 52)
{
btn4.PerformClick();
}
}

private void btn5_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 53)
{
btn5.PerformClick();
}
}

private void btn6_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 54)
{
btn6.PerformClick();
}
}

private void btn7_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 55)
{
btn6.PerformClick();
}
}

private void btn8_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 56)
{
btn1.PerformClick();
}
}
private void btn9_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 57)
{
btn1.PerformClick();
}
}
private void btn0_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 48)
{
btn1.PerformClick();
}
}
private void btnDecimalPoint_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 46)
{
btnDecimal.PerformClick();
}
}
private void btnAdd_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 43)
{
btnDecimal.PerformClick();
}
}
private void btnSubtract_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 45)
{
btnDecimal.PerformClick();
}
}
private void btnMultiply_KeyPress(object sender, KeyPressEventArgs e)
{
i
jon-80 19-Feb-12 2:34am View    
The code needs to exclude the (), otherwise VS will complain that ..KeyChar(), cannot be used like a method.

<pre>
this.btn1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.btn1_KeyPress);

private void btn1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar=='1')
{
//ur code
}
}
<pre>
jon-80 2-Aug-11 13:33pm View    
That's fine, however I would like to be able to do it programmatically, by passing parameters that represent applications held in memory, and, interface directly with the Windows API, for example using the Clipboard API (http://msdn.microsoft.com/en-us/library/ms649012%28v=VS.85%29.aspx).
jon-80 27-Mar-11 2:04am View    
Thanks