[PHP]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Clock
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[System.Runtime.InteropServices.DllImport("user32.d ll")]
static extern bool SetCursorPos(int x, int y);
[System.Runtime.InteropServices.DllImport("user32.d ll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public static void LeftMouseClick(int xpos, int ypos)
{
SetCursorPos(xpos, ypos);
mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
}
Timer timer_10 = new Timer();
Timer timer_100 = new Timer();
Timer timer_1000 = new Timer();
Timer timer_reset = new Timer();
bool active = true;
private void Form1_Load(object sender, EventArgs e)
{
timer_10.Interval = 100;
timer_10.Tick += timer_10_Tick;
timer_10.Start();
timer_100.Interval = 10;
timer_100.Tick += timer_100_Tick;
timer_100.Start();
timer_1000.Interval = 1;
timer_1000.Tick += timer_1000_Tick;
timer_1000.Start();
timer_reset.Interval = 2013;
timer_reset.Tick += timer_reset_Tick;
timer_reset.Start();
}
void timer_reset_Tick(object sender, EventArgs e)
{
if (checkBox2.Checked == true)
active = true;
}
void timer_1000_Tick(object sender, EventArgs e)
{
label6.Text = DateTime.Now.Millisecond.ToString();
if (checkBox1.Checked == true)
{
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
{
int hour = Convert.ToInt16(textBox1.Text);
int minute = Convert.ToInt16(textBox2.Text);
int second = Convert.ToInt16(textBox3.Text);
int millisecond = Convert.ToInt16(textBox4.Text);
if (DateTime.Now.Millisecond == millisecond && DateTime.Now.Second == second && DateTime.Now.Minute == minute && DateTime.Now.Hour == hour)
if (active == true)
{
LeftMouseClick(MousePosition.X, MousePosition.Y);
active = false;
}
}
}
}
void timer_100_Tick(object sender, EventArgs e)
{
if (Convert.ToInt16(label5.Text) < 99)
label5.Text = (DateTime.Now.Millisecond / 10).ToString();
else
label5.Text = "0";
}
void timer_10_Tick(object sender, EventArgs e)
{
if (Convert.ToInt16(label4.Text) < 9)
label4.Text = (DateTime.Now.Millisecond / 100).ToString();
else
label4.Text = "0";
label3.Text = DateTime.Now.Second.ToString();
label2.Text = DateTime.Now.Minute.ToString();
label1.Text = DateTime.Now.Hour.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
timer_10.Stop();
timer_100.Stop();
timer_1000.Stop();
}
private void button1_Click(object sender, EventArgs e)
{
timer_10.Start();
timer_100.Start();
timer_1000.Start();
}
private void button3_Click(object sender, EventArgs e)
{
active = true;
}
private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
e.Handled = true;
if (e.KeyChar == '.')
{
e.Handled = true;
}
}
}
}
[/PHP]