private void btnEnd_Click(object sender, EventArgs e) { PowerHelper.ResetSystemDefault(); btnStart.Enabled = true; btnStartWithClick.Enabled = true; myTimer.Stop(); exitFlag = true; // Displays a message box asking whether to continue running the timer. //if (MessageBox.Show("Continue running?", "Count is: " + alarmCounter, // MessageBoxButtons.YesNo) == DialogResult.Yes) //{ // // Restarts the timer and increments the counter. // alarmCounter += 1; // myTimer.Enabled = true; //} //else //{ // // Stops the timer. // exitFlag = true; //} }
private void btnStart_Click(object sender, EventArgs e) { //Enable the awake mode PowerHelper.ForceSystemAwake(); btnStart.Enabled = false; }
private void btnStartWithClick_Click(object sender, EventArgs e) { //Enable the awake mode PowerHelper.ForceSystemAwake(); btnStartWithClick.Enabled = false; // Convert the target to absolute screen coordinates. Point pt = this.PointToScreen(m_Target); // mouse_event moves in a coordinate system where // (0, 0) is in the upper left corner and // (65535,65535) is in the lower right corner. // Convert the coordinates. Rectangle screen_bounds = Screen.GetBounds(pt); uint x = (uint)(pt.X * 65535 / screen_bounds.Width); uint y = (uint)(pt.Y * 65535 / screen_bounds.Height); // Move the mouse. mouse_event( (uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.MOVE), x, y, 0, 0); // Click there. mouse_event( (uint)(MouseEventFlags.ABSOLUTE | MouseEventFlags.MOVE | MouseEventFlags.LEFTDOWN | MouseEventFlags.LEFTUP), x, y, 0, 0); /* Adds the event and the event handler for the method that will * process the timer event to the timer. */ myTimer.Tick += new EventHandler(TimerEventProcessor); // Sets the timer interval to 5 seconds. myTimer.Interval = 5000; myTimer.Start(); // Runs the timer, and raises the event. while (exitFlag == false) { // Processes all the events in the queue. Application.DoEvents(); } }
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { PowerHelper.ResetSystemDefault(); }
private void frmMain_Load(object sender, EventArgs e) { PowerHelper.ResetSystemDefault(); btnStart.Enabled = true; }