Ejemplo n.º 1
0
 public static void Click(int milliseconds)
 {
     Thread.Sleep(milliseconds);
     KeyRegister.mouse_event(KeyRegister.MOUSE_BUTTONDOWN, 0, 0, 0, IntPtr.Zero);
     Thread.Sleep(50);
     KeyRegister.mouse_event(KeyRegister.MOUSE_BUTTONUP, 0, 0, 0, IntPtr.Zero);
 }
Ejemplo n.º 2
0
        private async void StartAlarm(object sender, RoutedEventArgs e)
        {
            if (viewModel.CountThreadStarted == false)
            {
                if (viewModel.Alarm.Started == false)
                {
                    if (viewModel.Alarm.Target == null || viewModel.Alarm.AttackList == null || viewModel.Alarm.AttackList.Count < 2)
                    {
                        return;
                    }
                    if (sender is MainWindow)
                    {
                        KeyRegister.mouse_event(KeyRegister.MOUSE_BUTTONDOWN, 0, 0, 0, IntPtr.Zero);
                        Thread.Sleep(50);
                        KeyRegister.mouse_event(KeyRegister.MOUSE_BUTTONUP, 0, 0, 0, IntPtr.Zero);
                    }
                    viewModel.Alarm.Started         = true;
                    viewModel.Alarm.Player.Position = viewModel.Alarm.Player.NaturalDuration.TimeSpan;
                    Progress <bool> progress = new Progress <bool>((x) =>
                    {
                        viewModel.Alarm.PlaySound();
                    }
                                                                   );
                    await Task.Factory.StartNew(() => { viewModel.Alarm.Start(progress); }, TaskCreationOptions.LongRunning);

                    viewModel.Alarm.Player.Stop();
                }
                else
                {
                    viewModel.Alarm.Started = false;
                }
            }
        }
Ejemplo n.º 3
0
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            var result = MessageBox.Show(Timinger.Language.ExitMessage, Timinger.Language.Exit, MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                e.Cancel = true;
            }
            else
            {
                count_thread?.Abort();
                count_thread?.Join();
                viewModel.Alarm.ClosePlayer();
                KeyRegister.UnregisterKey(Hwnd);
                viewModel.Config.SaveToFile();
            }
        }
Ejemplo n.º 4
0
 public static void Click()
 {
     KeyRegister.mouse_event(KeyRegister.MOUSE_BUTTONDOWN, 0, 0, 0, IntPtr.Zero);
     Thread.Sleep(50);
     KeyRegister.mouse_event(KeyRegister.MOUSE_BUTTONUP, 0, 0, 0, IntPtr.Zero);
 }
Ejemplo n.º 5
0
        public bool Start(IProgress <bool> progress)
        {
            if (attack_list == null || attack_list.Count < 2)
            {
                return(false);
            }
            attack_list.Sort();
            attack_list.Reverse();
            Iterator = 1;
            bool alarm        = false;
            bool NotFairClick = false;

            CurrentAttack  = attack_list[iterator - 1];
            NextAttack     = attack_list[iterator];
            UnsafeNextTime = DateTime.Now.AddSeconds(CurrentAttack.Time - NextAttack.Time);
            while (Started == true && iterator < attack_list.Count)
            {
                var time = UnsafeNextTime.Subtract(DateTime.Now);
                CurrentTime = time.TotalSeconds;
                //
                if (NotFairOption == true && NotFairClick == false)
                {
                    if (CurrentTime <= NotFairTime && NotFairTime >= 0)
                    {
                        KeyRegister.Click();
                        NotFairClick = true;
                    }
                    else if (NotFairTime < 0 && CurrentTime <= 0)
                    {
                        new Thread(() => KeyRegister.Click((int)Math.Abs(NotFairTime * 1000))).Start();
                    }
                }
                //
                if (CurrentTime <= AlarmTime && alarm == false)
                {
                    alarm = true;
                    progress.Report(true);
                }
                if (CurrentTime <= 0)
                {
                    Iterator++;
                    if (iterator >= attack_list.Count)
                    {
                        Started     = false;
                        CurrentTime = 0;
                        Iterator    = 0;
                        return(true);
                    }
                    else
                    {
                        NotFairClick   = false;
                        CurrentAttack  = attack_list[iterator - 1];
                        NextAttack     = attack_list[iterator];
                        UnsafeNextTime = DateTime.Now.AddSeconds(CurrentAttack.Time - NextAttack.Time);
                        CurrentTime    = UnsafeNextTime.Subtract(DateTime.Now).TotalSeconds;
                        alarm          = false;
                    }
                }
            }
            CurrentTime = 0;
            Iterator    = 0;
            return(true);
        }