我有个程序是用来记录键盘回车信息的,不关在什么地方录入回车,程序就会发出声音报警;
但现在有个问题,就是回车程序可以报警,但是回车不起作用;
我想程序报警,但对于我的操作没有影响。
例如:我在txt中录入回车,他会换行,同时也能报警。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; namespace EnterTip
{
public partial class Form1 : Form
{
[DllImport("user32")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, Keys vk);
[DllImport("user32")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
[DllImport("kernel32.dll")]
public static extern bool Beep(int freq,int duration);
public Form1()
{
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
RegisterHotKey(this.Handle, 888, 0, Keys.Enter);
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0312:
if (m.WParam.ToString().Equals("888"))
Beep(700, 400);
break;
}
base.WndProc(ref m);
} private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible = true;
}
} private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
} private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
Application.Exit();
} private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();
} private void label1_Click(object sender, EventArgs e)
{
}
}
}
但现在有个问题,就是回车程序可以报警,但是回车不起作用;
我想程序报警,但对于我的操作没有影响。
例如:我在txt中录入回车,他会换行,同时也能报警。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; namespace EnterTip
{
public partial class Form1 : Form
{
[DllImport("user32")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, Keys vk);
[DllImport("user32")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
[DllImport("kernel32.dll")]
public static extern bool Beep(int freq,int duration);
public Form1()
{
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
RegisterHotKey(this.Handle, 888, 0, Keys.Enter);
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0312:
if (m.WParam.ToString().Equals("888"))
Beep(700, 400);
break;
}
base.WndProc(ref m);
} private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible = true;
}
} private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
} private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
Application.Exit();
} private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();
} private void label1_Click(object sender, EventArgs e)
{
}
}
}
http://blog.csdn.net/bdmh/article/details/6124127