📄 form2.cs
字号:
//if (e == Keys.LWin)
//{
// if (!button78.BackColor.Equals(Color.Yellow))
// {
// this.button78.BackColor = Color.Yellow;
// ++i;
// }
//}
//if (e == Keys.Space)
//{
// if (!button80.BackColor.Equals(Color.Yellow))
// {
// this.button80.BackColor = Color.Yellow;
// ++i;
// }
//}
//if (e == Keys.Apps)
//{
// if (!button82.BackColor.Equals(Color.Yellow))
// {
// this.button82.BackColor = Color.Yellow;
// ++i;
// }
//}
}
return true;
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Button2");
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
}
public void pd()
{
while(true)
{
KeyStateInfo RctrlKey = KeyboardInfo.GetKeyState(Keys.RControlKey);
KeyStateInfo LctrlKey = KeyboardInfo.GetKeyState(Keys.LControlKey);
KeyStateInfo RaltKey = KeyboardInfo.GetKeyState(Keys.RMenu);
KeyStateInfo LaltKey = KeyboardInfo.GetKeyState(Keys.LMenu);
KeyStateInfo RshiftKey = KeyboardInfo.GetKeyState(Keys.RShiftKey);
KeyStateInfo LshiftKey = KeyboardInfo.GetKeyState(Keys.LShiftKey);
KeyStateInfo end = KeyboardInfo.GetKeyState(Keys.End);
KeyStateInfo qsx = KeyboardInfo.GetKeyState(Keys.OemQuestion);
KeyStateInfo fire = KeyboardInfo.GetKeyState(Keys.Apps);
KeyStateInfo lwin = KeyboardInfo.GetKeyState(Keys.LWin);
KeyStateInfo KG= KeyboardInfo.GetKeyState(Keys.Space);
KeyStateInfo zj = KeyboardInfo.GetKeyState(Keys.LButton);
KeyStateInfo yj = KeyboardInfo.GetKeyState(Keys.RButton);
//KeyStateInfo gl = KeyboardInfo.GetKeyState(Keys);
if (LctrlKey.IsPressed)
{
if (!button77.BackColor.Equals(Color.Yellow))
{
button77.BackColor = Color.Yellow;
++i;
}
}
if (zj.IsPressed)
{
if (!button87.BackColor.Equals(Color.Yellow))
{
button87.BackColor = Color.Yellow;
++i;
}
}
if (yj.IsPressed)
{
if (!button88.BackColor.Equals(Color.Yellow))
{
button88.BackColor = Color.Yellow;
++i;
}
}
if (KG.IsPressed)
{
if (!button80.BackColor.Equals(Color.Yellow))
{
button80.BackColor = Color.Yellow;
++i;
}
}
if (end.IsPressed)
{
if (!button75.BackColor.Equals(Color.Yellow))
{
button75.BackColor = Color.Yellow;
++i;
}
}
if (qsx.IsPressed)
{
if (!button72.BackColor.Equals(Color.Yellow))
{
button72.BackColor = Color.Yellow;
++i;
}
}
if (fire.IsPressed)
{
if (!button82.BackColor.Equals(Color.Yellow))
{
button82.BackColor = Color.Yellow;
++i;
}
}
if (lwin.IsPressed)
{
if (!button78.BackColor.Equals(Color.Yellow))
{
button78.BackColor = Color.Yellow;
++i;
}
}
if (RctrlKey.IsPressed)
{
if (!button83.BackColor.Equals(Color.Yellow))
{
button83.BackColor = Color.Yellow;
++i;
}
}
if(RaltKey.IsPressed)
{
if (!button81.BackColor.Equals(Color.Yellow))
{
button81.BackColor = Color.Yellow;
++i;
}
}
if (LaltKey.IsPressed)
{
if (!button79.BackColor.Equals(Color.Yellow))
{
button79.BackColor = Color.Yellow;
++i;
}
}
if (RshiftKey.IsPressed)
{
if (!button73.BackColor.Equals(Color.Yellow))
{
button73.BackColor = Color.Yellow;
++i;
}
}
if (LshiftKey.IsPressed)
{
if (!button62.BackColor.Equals(Color.Yellow))
{
button62.BackColor = Color.Yellow;
++i;
}
}
if (i >= 87)
{
this.Hide();
Form3 f3 = new Form3();
f3.ShowDialog();
ph.Abort();
break;
}
}
}
UserActivityHook actHook;
private void Form2_Load(object sender, EventArgs e)
{
actHook = new UserActivityHook(); // crate an instance with global hooks
actHook.OnMouseActivity += new MouseEventHandler(MouseMoved);
ph = new Thread(new ThreadStart(pd));
ph.Start();
}
public void MouseMoved(object sender, MouseEventArgs e)
{
if(e.Delta>100)
{
this.button89.BackColor = Color.Yellow;
}
if (e.Delta <-100)
{
this.button90.BackColor = Color.Yellow;
}
}
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
foreach (System.Diagnostics.Process thisproc in System.Diagnostics.Process.GetProcesses())
{
if (thisproc.ProcessName.Equals("WindowsApplication1"))
{
thisproc.Kill();
}
}
}
private void Form2_MouseMove(object sender, MouseEventArgs e)
{
//if (e.Delta > 100)
//{
// this.button89.BackColor = Color.Yellow;
//}
//if(e.Delta<-100)
//{
// this.button90.BackColor = Color.Yellow;
//}
}
private void button91_Click(object sender, EventArgs e)
{
this.Hide();
Form3 f3 = new Form3();
f3.ShowDialog();
}
}
public class KeyboardInfo
{
private KeyboardInfo() { }
[DllImport("user32")]
private static extern short GetKeyState(int vKey);
public static KeyStateInfo GetKeyState(Keys key)
{
int vkey = (int)key;
if (key == Keys.Alt)
{
vkey = 0x12; // VK_ALT
}
short keyState = GetKeyState(vkey);
int low = Low(keyState);
int high = High(keyState);
bool toggled = (low == 1);
bool pressed = (high == 1);
return new KeyStateInfo(key, pressed, toggled);
}
private static int High(int keyState)
{
if (keyState > 0)
{
return keyState >> 0x10;
}
else
{
return (keyState >> 0x10) & 0x1;
}
}
private static int Low(int keyState)
{
return keyState & 0xffff;
}
}
public struct KeyStateInfo
{
Keys m_Key;
bool m_IsPressed;
bool m_IsToggled;
public KeyStateInfo(Keys key, bool ispressed, bool istoggled)
{
m_Key = key;
m_IsPressed = ispressed;
m_IsToggled = istoggled;
}
public static KeyStateInfo Default
{
get
{
return new KeyStateInfo(Keys.None, false, false);
}
}
public Keys Key
{
get { return m_Key; }
}
public bool IsPressed
{
get { return m_IsPressed; }
}
public bool IsToggled
{
get { return m_IsToggled; }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -