Ejemplo n.º 1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            //Enable the awake mode
            PowerHelper.ForceSystemAwake();


            btnStart.Enabled = false;
        }
Ejemplo n.º 2
0
        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();
            }
        }