コード例 #1
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void ClickRepeat(Interactor intr, int xCoord, int yCoord, int repeats)
 {
     for (int c = 0; c < repeats; c++) {
         Click(intr, xCoord, yCoord);
         intr.Wait(25);
     }
 }
コード例 #2
0
ファイル: Wake.cs プロジェクト: c0gent/NeverClicker
 public static void Wake(Interactor intr)
 {
     //intr.ExecuteStatement("PostMessage, 0x0112, 0xF170, -1,, A");
     // PostMessage, 0x0112, 0xF170, 2,, A 			; Turn off Display (-1 on, 1 low-pow, 2 off) -- unreliable
     //intr.ExecuteStatement("PostMessage, 0x0112, 0x0F060, 0,, A"); // ; 0x0112 is WM_SYSCOMMAND, 0x0F060 is SC_CLOSE -- turns off screensaver
     SendMessage(FindWindow(null, null), WM_SYSCOMMAND, SC_CLOSE, 0);
 }
コード例 #3
0
ファイル: MoveAround.cs プロジェクト: c0gent/NeverClicker
        public static void MoveAround(Interactor intr)
        {
            string moveLeftKey = intr.AccountSettings.GetSettingValOr("moveLeft", "gameHotkeys", Global.Default.MoveLeftKey);
            string moveRightKey = intr.AccountSettings.GetSettingValOr("moveRight", "gameHotkeys", Global.Default.MoveRightKey);
            string moveForeKey = intr.AccountSettings.GetSettingValOr("moveForward", "gameHotkeys", Global.Default.MoveForwardKey);
            string moveBackKey = intr.AccountSettings.GetSettingValOr("moveBackward", "gameHotkeys", Global.Default.MoveBackwardKey);

            intr.WaitRand(40, 120);

            int dirRand = intr.Rand(0, 6);

            int keyDelay = 20;

            if (dirRand == 0 || dirRand == 1) {
                Keyboard.KeyPress(intr, moveLeftKey, keyDelay);
            } else if (dirRand == 2 || dirRand == 3) {
                Keyboard.KeyPress(intr, moveRightKey, keyDelay);
            } else if (dirRand == 4) {
                Keyboard.KeyPress(intr, moveForeKey, keyDelay);
            } else if (dirRand == 5) {
                Keyboard.KeyPress(intr, moveBackKey, keyDelay);
            }

            intr.WaitRand(120, 220);
        }
コード例 #4
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void DoubleClick(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Double-clicking at ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 0 }");
     intr.Wait(10);
     intr.ExecuteStatement("SendEvent { Click 2 }");
 }
コード例 #5
0
ファイル: Window.cs プロジェクト: c0gent/NeverClicker
 // Need to figure these two out and simplify...
 public static void WindowKill(Interactor intr, string windowExe)
 {
     string param = string.Format("ahk_exe {0}", windowExe);
     intr.ExecuteStatement("WinClose, " + param);
     intr.ExecuteStatement("WinClose, " + windowExe);
     intr.ExecuteStatement("WinKill, " + param);
     intr.ExecuteStatement("WinKill, " + windowExe);
 }
コード例 #6
0
ファイル: Window.cs プロジェクト: c0gent/NeverClicker
 public static void WindowKillClass(Interactor intr, string windowClass)
 {
     string param = string.Format("ahk_class {0}", windowClass);
     intr.ExecuteStatement("WinClose, " + param);
     intr.ExecuteStatement("WinClose, " + windowClass);
     intr.ExecuteStatement("WinKill, " + param);
     intr.ExecuteStatement("WinKill, " + windowClass);
 }
コード例 #7
0
ファイル: Window.cs プロジェクト: c0gent/NeverClicker
 public static void WindowKillTitle(Interactor intr, string windowTitle)
 {
     string param = windowTitle;
     intr.ExecuteStatement("WinClose, " + param);
     intr.ExecuteStatement("WinClose, " + windowTitle);
     intr.ExecuteStatement("WinKill, " + param);
     intr.ExecuteStatement("WinKill, " + windowTitle);
 }
コード例 #8
0
ファイル: ActivateClient.cs プロジェクト: c0gent/NeverClicker
        public static bool ActivateClient(Interactor intr)
        {
            //intr.ExecuteStatement("ActivateNeverwinter()");

            Screen.WindowActivate(intr, States.GAMECLIENTEXE);

            intr.Wait(1500);

            return true;
        }
コード例 #9
0
ファイル: ClickImage.cs プロジェクト: c0gent/NeverClicker
 public static bool ClickImage(Interactor intr, string imgCode, int xOfs, int yOfs)
 {
     var result = Screen.ImageSearch(intr, imgCode);
     if (result.Found) {
         Click(intr, result.Point.X + 5, result.Point.Y + 5);
         return true;
     } else {
         return false;
     }
 }
コード例 #10
0
ファイル: ClickImage.cs プロジェクト: c0gent/NeverClicker
 public static bool ClickImage(Interactor intr, List<string> imgCodes, int xOfs, int yOfs, Point topLeft, Point botRight)
 {
     var result = Screen.ImageSearch(intr, imgCodes, topLeft, botRight);
     if (result.Found) {
         Click(intr, result.Point.X + topLeft.X + 5, result.Point.Y + topLeft.Y + 5);
         return true;
     } else {
         return false;
     }
 }
コード例 #11
0
ファイル: Window.cs プロジェクト: c0gent/NeverClicker
        public static bool WindowDetect(Interactor intr, string windowExe, string flavor)
        {
            string detectionParam = string.Format("ahk_exe {0}", windowExe);
            var result = intr.EvaluateFunction("Win" + flavor, detectionParam);
            intr.Log(LogEntryType.Trace, "Interactions::Screen::WindowDetect{0}(): Win{0}({1}): '{2}'",
                flavor, detectionParam, result);

            if ((result.Trim() == "0x0") || (string.IsNullOrWhiteSpace(result))) {
                return false;
            } else {
                return true;
            }
        }
コード例 #12
0
ファイル: Keyboard.cs プロジェクト: c0gent/NeverClicker
        public static void KeyPress(Interactor intr, string key, int duration)
        {
            //intr.ExecuteStatement("SendInput { " + key + " down }");
            //intr.Wait((int)duration + 180);
            //intr.ExecuteStatement("SendInput { " + key + " up }");
            //intr.Wait(20);

            string cmd = @"Send {" + key + @" down}
            Sleep " + duration.ToString() + @"
            Send {" + key + @" up}
            Sleep " + duration.ToString() + @"
            ";

            intr.ExecuteStatement(cmd);
            intr.Wait(duration * 3);
        }
コード例 #13
0
ファイル: ClearDialogues.cs プロジェクト: c0gent/NeverClicker
        public static void ClearDialogues(Interactor intr)
        {
            intr.Log(LogEntryType.Debug, "Attempting to clear dialogues...");

            Point topLeft = new Point(680, 400);
            Point botRight = new Point(1240, 680);

            Keyboard.SendKey(intr, Keyboard.KeyMod.Ctrl, "2");

            // These probably don't work:
            Mouse.ClickImage(intr, "CharSelectOkayButton", 0, 0, topLeft, botRight);
            Mouse.ClickImage(intr, "CharSelectOkButton", 0, 0, topLeft, botRight);
            Mouse.ClickImage(intr, "CharSelectOkButton_3", 0, 0, topLeft, botRight);
            //Mouse.ClickImage(intr, "DeclineButton", 0, 0, topLeft, botRight);
            //Mouse.ClickImage(intr, "DeclineButton_2", 0, 0, topLeft, botRight);
        }
コード例 #14
0
ファイル: Inventory.cs プロジェクト: c0gent/NeverClicker
        //// Checks to ensure that the inventory was successfully opened.
        //public static bool InventoryIsOpen(Interactor intr) {
        //    var invState = States.DetermineInventoryState(intr);
        //    if (invState == InventoryState.None) {
        //        return false;
        //    } else {
        //        return true;
        //    }
        //}
        // Opens inventory.
        public static bool OpenInventory(Interactor intr)
        {
            intr.Log(LogEntryType.Debug, "Opening inventory...");
            string openInventoryKey = intr.AccountSettings.GetSettingValOr("inventory", "gameHotkeys", Global.Default.InventoryKey);
            MoveAround(intr);
            Keyboard.SendKey(intr, openInventoryKey);
            intr.Wait(300);

            if (intr.WaitUntil(8, WorldWindowState.Inventory, States.IsWorldWindowState, null, 1)) {
                intr.Log(LogEntryType.Debug, "Inventory is open.");
                return true;
            } else {
                intr.Log(LogEntryType.Info, "Unable to open inventory. Could be a random glitch.");
                return false;
            }
        }
コード例 #15
0
ファイル: Inventory.cs プロジェクト: c0gent/NeverClicker
        // Maintains inventory.
        //
        // [TODO]: Need error handling channels if detected states don't align with expected.
        //
        public static CompletionStatus MaintainInventory(Interactor intr, uint charIdx)
        {
            if (intr.CancelSource.IsCancellationRequested) { return CompletionStatus.Cancelled; }

            bool InventoryOpened = OpenInventory(intr);

            var enchKeyAvailable = DetectEnchantedKeyAwaitingCollection(intr);

            // Collect Enchanted Key:
            if (IsEnchantedKeyTimerExpired(intr)) {
                intr.Log(LogEntryType.Debug, "Enchanted key timer has expired. Attempting to collect...");
                ClaimEnchantedKey(intr, charIdx, InventoryOpened);
            } else if (enchKeyAvailable) {
                intr.Log(LogEntryType.Debug, "Enchanted key detected as awaiting collection. Attempting to collect...");
                ClaimEnchantedKey(intr, charIdx, InventoryOpened);
            }

            // Transfer any overflow items:
            TransferOverflow(intr, true, true);

            // Open Celestial Bags of Refinement:
            var ocbStatus = OpenRewardBags(intr, "InventoryCelestialBagOfRefinement", true);

            if (ocbStatus != CompletionStatus.Complete) {
                intr.Log(LogEntryType.Error, "Unable to open celestial bags of refinement.");
                return ocbStatus;
            }

            // Open VIP Account Reward bags:
            var varStatus = OpenRewardBags(intr, "InventoryVipAccountRewardBag", true);

            if (varStatus != CompletionStatus.Complete) {
                intr.Log(LogEntryType.Error, "Unable to open vip account reward bags.");
                return varStatus;
            }

            // Attempt to transfer any overflow items again just in case:
            TransferOverflow(intr, true, true);

            // Finish up:
            MoveAround(intr);
            if (intr.CancelSource.IsCancellationRequested) { return CompletionStatus.Cancelled; } // necessary?
            return CompletionStatus.Complete;
        }
コード例 #16
0
ファイル: MouseMoveTest.cs プロジェクト: c0gent/NeverClicker
        public static void MouseMoveTest(Interactor intr)
        {
            int sleepDuration = 3000;
            int loopIterations = 3;

            var coordinateList = new List<Point>();
            coordinateList.Add(new Point(1, 1));
            coordinateList.Add(new Point(800, 20));
            coordinateList.Add(new Point(20, 800));

            for (uint i = 0; i < loopIterations; i++) {
                foreach (var p in coordinateList) {
                    if (intr.CancelSource.Token.IsCancellationRequested) {
                        intr.Log("Attempting to cancel mouse movement test.");
                        break;
                    }
                    //WriteTextBox("Moving to (1, 1).");
                    intr.Log(String.Format("Moving to ({0}, {1}).", p.X, p.Y));

                    intr.MoveMouseCursor(p, false);
                    //alibEng.Exec("SendEvent {Click 1, 1, 0}");
                    //alibEng.Exec("Sleep 3000");
                    //Thread.Sleep(2000);
                    //log.Report("Moving to (800, 800).");
                    Task.Delay(sleepDuration).Wait();
                    //cancelToken.ThrowIfCancellationRequested();
                    //if (cancelToken.IsCancellationRequested) { break; }
                }

                ////WriteTextBox("Moving to (800, 800).");
                //log.Report("Moving to (800, 800).");
                //alibEng.Exec("SendEvent {Click 800, 800, 0}");
                ////alibEng.Exec("Sleep 3000");
                ////Thread.Sleep(2000);
                //await Task.Delay(3000);
                ////cancelToken.ThrowIfCancellationRequested();
                //if (cancelToken.IsCancellationRequested) { break; }
            }

            intr.Log("Mouse movement complete.");
        }
コード例 #17
0
ファイル: LogOut.cs プロジェクト: c0gent/NeverClicker
        //public static bool ActivateClient(Interactor intr) {
        //    //intr.ExecuteStatement("ActivateNeverwinter()");
        //    Screen.WindowActivate(intr, Game.GAMECLIENTEXE);
        //    intr.Wait(1000);
        //    return true;
        //}
        public static bool LogOut(Interactor intr)
        {
            //intr.ExecuteStatement("Logout()");
            intr.Log(LogEntryType.Info, "Logging out...");

            ClearDialogues(intr);

            MoveAround(intr);

            Keyboard.SendKey(intr, "Enter");
            intr.Wait(50);

            Keyboard.Send(intr, "/gotocharacterselect");
            intr.Wait(100);

            Keyboard.SendKey(intr, "Enter");
            intr.Wait(100);

            //intr.Wait(3000);

            return true;
        }
コード例 #18
0
        public static bool CrashCheckRecovery(Interactor intr, int prev_tries_unimplemented)
        {
            intr.Log(LogEntryType.Info, "CrashCheckRecovery(): Initiating...");

            Screen.Wake(intr);

            Mouse.Move(intr, 1, 1);

            intr.Wait(5000);

            ClearDialogues(intr);

            intr.Wait(2000);

            Screen.WindowKillTitle(intr, "Verify?");

            KillAll(intr);

            return true;

            //switch (Game.DetermineGameState(intr)) {
            //	case GameState.Closed:
            //		intr.Log("CrashCheckRecovery(): GameState == Closed. Calling ProduceClientState().", LogEntryType.Info);
            //		return ProduceClientState(intr, ClientState.CharSelect);
            //	case GameState.Patcher:
            //		intr.Log("CrashCheckRecovery(): GameState == Closed. Calling ProduceClientState().", LogEntryType.Info);
            //		return ProduceClientState(intr, ClientState.CharSelect);
            //	case GameState.ClientActive:
            //		intr.Log("CrashCheckRecovery(): GameState == Closed. Killing all then calling ProduceClientState().", LogEntryType.Info);
            //		KillAll(intr);
            //		return ProduceClientState(intr, ClientState.CharSelect);
            //	case GameState.Unknown:
            //	default:
            //		intr.Log("CrashCheckRecovery(): GameState unknown. Killing all.");
            //		KillAll(intr);
            //		return false;
            //}
        }
コード例 #19
0
ファイル: Keyboard.cs プロジェクト: c0gent/NeverClicker
 public static void KeyPress(Interactor intr, string key)
 {
     KeyPress(intr, key, 10);
 }
コード例 #20
0
ファイル: Keyboard.cs プロジェクト: c0gent/NeverClicker
 public static void SendEvent(Interactor intr, string keys)
 {
     intr.ExecuteStatement("SendEvent " + keys);
     intr.Wait(20);
 }
コード例 #21
0
ファイル: Keyboard.cs プロジェクト: c0gent/NeverClicker
 public static void Send(Interactor intr, string key)
 {
     SendInput(intr, key);
 }
コード例 #22
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Move(Interactor intr, Point point)
 {
     Move(intr, point.X, point.Y);
 }
コード例 #23
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
        //public static void SendInput(Interactor intr, string key) {
        //	//intr.Wait(200);
        //	intr.ExecuteStatement("SendInput " + key);
        //	intr.Wait(50);
        //}

        //public static void SendPlay(Interactor intr, string keys) {
        //	intr.ExecuteStatement("SendPlay " + keys);
        //	intr.Wait(50);
        //}

        //public static void SendEvent(Interactor intr, string keys) {
        //	intr.ExecuteStatement("SendEvent " + keys);
        //	intr.Wait(50);
        //}

        public static void SendTest(Interactor intr, string key)
        {
            intr.Wait(3000);
            intr.ExecuteStatement("SendEvent " + key);
            intr.Wait(50);
        }
コード例 #24
0
        public static void WindowRun(Interactor intr, string windowExePath)
        {
            string runFolder = Path.GetDirectoryName(windowExePath);

            intr.ExecuteStatement("Run, " + windowExePath + ", " + runFolder);
        }
コード例 #25
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Click(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Clicking at ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 1 }");
 }
コード例 #26
0
        public static bool Redeem(Interactor intr, uint charIdx)
        {
            VaultOfPietyItem item;

            try {
                item = (VaultOfPietyItem)Enum.Parse(typeof(VaultOfPietyItem),
                                                    intr.AccountSettings.GetCharSetting(charIdx, "vaultOfPietyItem"), true);
            } catch (Exception) {
                item = DEFAULT_REDEMPTION_ITEM;
            }

            intr.Log(LogEntryType.Debug, "VaultOfPietyItem: " + item.ToString());

            intr.Wait(500);
            string cursorModeKey = intr.AccountSettings.GetSettingValOr("toggleMouseCursor", "gameHotkeys",
                                                                        Global.Default.ToggleMouseCursor);

            if (Screen.ImageSearch(intr, "InvocationMaximumBlessings").Found)
            {
                intr.Wait(200);
                Mouse.ClickImage(intr, "InvocationMaximumBlessingsVaultOfPietyButton");
            }
            else
            {
                intr.Wait(1000);
                Keyboard.SendKey(intr, cursorModeKey);
                intr.Wait(500);
                bool clicked = false;
                clicked |= Mouse.ClickImage(intr, "InvocationNotReady");
                clicked |= Mouse.ClickImage(intr, "InvocationReady");

                if (!clicked)
                {
                    intr.Log(LogEntryType.FatalWithScreenshot, "Unable to click Vault of Piety button");
                }
            }

            intr.WaitRand(2100, 2500);

            if (!Screen.ImageSearch(intr, "VaultOfPietyWindowTitle").Found)
            {
                return(false);
            }

            Mouse.ClickImage(intr, "VaultOfPietyCelestialSynergyTabTitle");
            intr.Wait(2000);

            string panelImage;
            string purchaseConfirmImage;

            //if (item == VaultOfPietyItem.ElixirOfFate) {
            //	var panel = Screen.ImageSearch(intr, "VaultOfPietyCelestialSynergyElixirOfFate");

            //	if (panel.Found) {
            //		Mouse.DoubleClick(intr, panel.Point);
            //		intr.Wait(500);
            //		Mouse.ClickImage(intr, "VaultOfPietyElixirOfFateSelectAmountOkButton");
            //		intr.Log(LogEntryType.Info, "Vault of Piety: 'Elixir of Fate' purchased successfully.");
            //	} else {
            //		intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find 'Elixir of Fate' icon/tile.");
            //		return false;
            //	}
            //} else if (item == VaultOfPietyItem.CofferOfCelestialArtifactEquipment) {
            //	var panel = Screen.ImageSearch(intr, "VaultOfPietyCelestialSynergyCofferOfCelestialArtifactEquipment");

            //	if (panel.Found) {
            //		Mouse.DoubleClick(intr, panel.Point);
            //		intr.Wait(500);
            //		Mouse.ClickImage(intr, "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton");
            //		intr.Log(LogEntryType.Info, "Vault of Piety: 'Coffer of Celestial Artifact Equipment' purchased successfully.");
            //	} else {
            //		intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find 'Coffer of Celestial Artifact Equipment' icon/tile.");
            //		return false;
            //	}
            //}

            if (item == VaultOfPietyItem.ElixirOfFate)
            {
                panelImage           = "VaultOfPietyCelestialSynergyElixirOfFate";
                purchaseConfirmImage = "VaultOfPietyElixirOfFateSelectAmountOkButton";
            }
            else if (item == VaultOfPietyItem.BlessedProfessionsElementalPack)
            {
                panelImage           = "VaultOfPietyCelestialSynergyBlessedProfessionsElementalPack";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else if (item == VaultOfPietyItem.CofferOfCelestialEnchantments)
            {
                panelImage           = "VaultOfPietyCelestialSynergyCofferOfCelestialEnchantments";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else if (item == VaultOfPietyItem.CofferOfCelestialArtifacts)
            {
                panelImage           = "VaultOfPietyCelestialSynergyCofferOfCelestialArtifacts";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else if (item == VaultOfPietyItem.CofferOfCelestialArtifactEquipment)
            {
                panelImage           = "VaultOfPietyCelestialSynergyCofferOfCelestialArtifactEquipment";
                purchaseConfirmImage = "VaultOfPietyCofferOfCelestialArtifactEquipmentPurchaseConfirmOkButton";
            }
            else
            {
                intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Unknown item: '{0:G}'.", item);
                return(false);
            }

            var panel = Screen.ImageSearch(intr, panelImage);

            if (panel.Found)
            {
                Mouse.DoubleClick(intr, panel.Point);
                intr.Wait(500);
                Mouse.ClickImage(intr, purchaseConfirmImage);
                intr.Log(LogEntryType.Info, "Vault of Piety: '{0:G}' purchased successfully.", item);
            }
            else
            {
                intr.Log(LogEntryType.Fatal, "Vault of Piety Error: Could not find '{0:G}' icon/panel.", item);
                return(false);
            }

            // [FIXME]: Handle the fact that the VaultOfPietyItem is:  `5`
            // [FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME]
            // [FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME][FIX THE HELL OUT OF ME]

            return(true);
        }
コード例 #27
0
        public static bool ProduceClientState(Interactor intr, ClientState desiredState, int attemptCount)
        {
            if (intr.CancelSource.Token.IsCancellationRequested)
            {
                return(false);
            }

            attemptCount += 1;

            intr.Log(LogEntryType.Info, "Attempting to produce client state: " + desiredState.ToString());

            if (States.IsClientState(intr, desiredState))
            {
                intr.Log(LogEntryType.Info, "Client state is already: " + desiredState.ToString());
                return(true);
            }
            else if (desiredState == ClientState.Inactive)
            {
                if (States.IsGameState(intr, GameState.ClientActive))
                {
                    intr.Log("Minimizing client...");
                    Screen.WindowMinimize(intr, States.GAMECLIENTEXE);
                }
                return(true);
            }
            else if (desiredState == ClientState.None)
            {
                intr.Log("Attempting to close game client...");
                KillAll(intr);
                return(true);
            }
            else if (desiredState == ClientState.CharSelect)
            {
                var currentClientState = States.DetermineClientState(intr);
                intr.Log(LogEntryType.Debug, "Interactions::ProduceClientState(): Current client state is " +
                         currentClientState.ToString());
                switch (currentClientState)
                {
                case ClientState.None:
                    intr.Log("Launching patcher...");
                    return(PatcherLogin(intr, desiredState));

                case ClientState.Inactive:
                    intr.Log("Game client is currently in the background. Waiting 30 seconds " +
                             "or until client is brought to foreground before continuing...");

                    const int waitIncr = 5000;

                    for (int i = 0; i < 30000; i += waitIncr)
                    {
                        if (!States.IsClientState(intr, ClientState.Inactive))
                        {
                            break;
                        }
                        intr.Wait(waitIncr);
                    }

                    //intr.Wait(30000);
                    intr.Log("Activating Client...");
                    ActivateClient(intr);
                    return(intr.WaitUntil(10, ClientState.CharSelect, States.IsClientState, ProduceClientState, attemptCount));

                case ClientState.InWorld:
                    if (attemptCount >= 10)
                    {
                        intr.Log(LogEntryType.FatalWithScreenshot, "Stuck at in world. Killing all and restarting.");
                        KillAll(intr);
                        intr.Wait(5000);
                        return(ProduceClientState(intr, ClientState.CharSelect, 0));
                    }
                    else
                    {
                        intr.Log("Logging out...");
                        LogOut(intr);
                        return(intr.WaitUntil(45, ClientState.CharSelect, States.IsClientState, ProduceClientState, attemptCount));
                    }

                case ClientState.LogIn:
                    if (attemptCount >= 10)
                    {
                        intr.Log(LogEntryType.FatalWithScreenshot, "Stuck at client login screen. Killing all and restarting.");
                        KillAll(intr);
                        intr.Wait(5000);
                        return(ProduceClientState(intr, ClientState.CharSelect, 0));
                    }
                    else
                    {
                        intr.Log("Client open, at login screen.");
                        ClientSignIn(intr);
                        return(intr.WaitUntil(30, ClientState.CharSelect, States.IsClientState, ProduceClientState, attemptCount));
                    }

                case ClientState.Unknown:
                default:
                    ClearDialogues(intr);

                    if (!intr.WaitUntil(30, ClientState.CharSelect, States.IsClientState, null, attemptCount))
                    {
                        intr.Log(LogEntryType.Info, "Client state unknown. Attempting crash recovery...");

                        CrashCheckRecovery(intr, 0);
                        return(ProduceClientState(intr, desiredState, attemptCount));

                        //var curState = Game.DetermineClientState(intr);

                        //if (curState == ClientState.Unknown) {
                        //	//CrashCheckRecovery(intr);
                        //	return
                        //} else {
                        //	return
                        //}
                    }
                    else
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #28
0
ファイル: EnchantedKey.cs プロジェクト: c0gent/NeverClicker
        // Claims an Enchanted Key if at all possible.
        public static bool ClaimEnchantedKey(Interactor intr, uint charIdx, bool inventoryOpened)
        {
            // Offset between reward icon and claim button:
            int xOfs = 222;
            int yOfs = 12;

            string charLabel = intr.AccountSettings.CharNames[(int)charIdx];

            intr.Wait(1000);
            intr.Log(LogEntryType.Debug, "Attempting to claim Enchanted Key for {0} ...", charLabel);

            // Open inventory if it has not already been pronounced open:
            if (!inventoryOpened)
            {
                intr.Log(LogEntryType.Debug, "Opening inventory ...");
                if (!OpenInventory(intr))
                {
                    intr.Log(LogEntryType.Fatal, "Unable to open inventory while claiming Enchanted Key for {0}.", charLabel);
                }
                else
                {
                    intr.Log(LogEntryType.Debug, "Inventory has been opened ...");
                }
                // Sometimes takes a long time for icons to load...
                intr.Wait(3000);
            }

            // // If VIP tab is not active, click it's icon:
            //if (!States.IsInventoryState(intr, InventoryState.Vip)) {
            //	intr.Log(LogEntryType.Debug, "VIP tab is not active, activating now...");
            //	var tabIcon = Screen.ImageSearch(intr, "InventoryTabIconVip");

            //	if (tabIcon.Found) {
            //		Mouse.Click(intr, tabIcon.Point);
            //	} else {
            //		intr.Log(LogEntryType.FatalWithScreenshot, "Unable to find inventory VIP icon to click.");
            //		return false;
            //	}

            //	intr.Wait(1800);

            //	// Move mouse out of the way:
            //	Mouse.Move(intr, tabIcon.Point.X - 30, tabIcon.Point.Y);

            //	// Ensure that we're looking at the VIP tab:
            //	if (!States.IsInventoryState(intr, InventoryState.Vip)) {
            //		intr.Log(LogEntryType.FatalWithScreenshot, "Unable to select VIP Tab in Inventory window.");
            //		return false;
            //	}
            //} else {
            //	intr.Log(LogEntryType.Debug, "VIP Tab is active.");
            //}

            // Click VIP tab icon:
            var vipTabIcon = Screen.ImageSearch(intr, "InventoryTabIconVip");

            if (vipTabIcon.Found)
            {
                Mouse.Click(intr, vipTabIcon.Point);
            }
            else
            {
                intr.Log(LogEntryType.FatalWithScreenshot, "Unable to find inventory VIP icon to click.");
                return(false);
            }

            // Move mouse out of the way:
            Mouse.Move(intr, vipTabIcon.Point.X - 30, vipTabIcon.Point.Y);

            // Ensure that we're looking at the VIP tab:
            if (!States.IsInventoryState(intr, InventoryState.Vip))
            {
                intr.Log(LogEntryType.FatalWithScreenshot, "Unable to select VIP Tab in Inventory window.");
                return(false);
            }
            else
            {
                intr.Log(LogEntryType.Debug, "VIP Tab is active.");
            }

            // Wait to make sure VIP tab page is drawn:
            intr.Wait(1800);

            // Get reward icon location/result:
            var iconLoc = Screen.ImageSearch(intr, "InventoryVipAccountRewardsIcon");

            // If found, click on two locations:
            if (iconLoc.Found)
            {
                intr.Log(LogEntryType.Debug, "VIP Claim image found, moving mouse to: ({0},{1}) to claim...",
                         (iconLoc.Point.X + xOfs),
                         (iconLoc.Point.Y + yOfs));

                // Click to the right of that image:
                Mouse.Move(intr, iconLoc.Point.X + xOfs, iconLoc.Point.Y + yOfs);
                Mouse.Click(intr, iconLoc.Point.X + xOfs, iconLoc.Point.Y + yOfs);
                intr.Wait(900);

                // Click again just to the right of the previous spot:
                Mouse.Move(intr, iconLoc.Point.X + xOfs + 15, iconLoc.Point.Y + yOfs);
                Mouse.Click(intr, iconLoc.Point.X + xOfs + 15, iconLoc.Point.Y + yOfs);

                //intr.Wait(2500);
                //// Verify that the VIP reward icon is no longer visible:
                //if (Screen.ImageSearch(intr, "InventoryVipAccountRewardsIcon").Found) {
                //	intr.Log(LogEntryType.FatalWithScreenshot, "Error clicking on claim button.");
                //	return false;
                //} else {
                //	intr.Log(LogEntryType.Normal, "Enchanted key collected on {0}.", charLabel);
                //	intr.AccountStates.SaveSetting(DateTime.Now.ToString("o"), "EnchKeyLastReceived", "invocation");
                //	return true;
                //}

                intr.Wait(200);
                intr.Log(LogEntryType.Normal, "Enchanted key collected on {0}.", charLabel);
                intr.AccountStates.SaveSetting(DateTime.Now.ToString("o"), "EnchKeyLastReceived", "invocation");
                return(true);
            }
            else
            {
                // If things didn't work, just advance it anyway with an error message. //
                intr.Log(LogEntryType.Error, "Failure to claim enchanted key on {0}.", charLabel);
                intr.Log(LogEntryType.Error, "Assuming key was manually collected and continuing.");
                intr.AccountStates.SaveSetting(DateTime.Now.ToString("o"), "EnchKeyLastReceived", "invocation");

                return(false);
            }
        }
コード例 #29
0
ファイル: ClearDialogues.cs プロジェクト: c0gent/NeverClicker
 public static void ClearWindowsWithX(Interactor intr)
 {
     Mouse.ClickImage(intr, "WindowXButton");
 }
コード例 #30
0
        public static bool ProduceClientState(Interactor intr, ClientState desiredState, int attemptCount)
        {
            if (intr.CancelSource.Token.IsCancellationRequested) { return false; }

            attemptCount += 1;

            intr.Log(LogEntryType.Info, "Attempting to produce client state: " + desiredState.ToString());

            if (States.IsClientState(intr, desiredState)) {
                intr.Log(LogEntryType.Info, "Client state is already: " + desiredState.ToString());
                return true;
            } else if (desiredState == ClientState.Inactive) {
                if (States.IsGameState(intr, GameState.ClientActive)) {
                    intr.Log( "Minimizing client...");
                    Screen.WindowMinimize(intr, States.GAMECLIENTEXE);
                }
                return true;
            } else if (desiredState == ClientState.None) {
                intr.Log("Attempting to close game client...");
                KillAll(intr);
                return true;
            } else if (desiredState == ClientState.CharSelect) {
                var currentClientState = States.DetermineClientState(intr);
                intr.Log(LogEntryType.Debug, "Interactions::ProduceClientState(): Current client state is " +
                    currentClientState.ToString());
                switch (currentClientState) {
                    case ClientState.None:
                        intr.Log("Launching patcher...");
                        return PatcherLogin(intr, desiredState);
                    case ClientState.Inactive:
                        intr.Log("Game client is currently in the background. Waiting 30 seconds " +
                            "or until client is brought to foreground before continuing...");

                        const int waitIncr = 5000;

                        for (int i = 0; i < 30000; i += waitIncr) {
                            if (!States.IsClientState(intr, ClientState.Inactive)) { break; }
                            intr.Wait(waitIncr);
                        }

                        //intr.Wait(30000);
                        intr.Log("Activating Client...");
                        ActivateClient(intr);
                        return intr.WaitUntil(10, ClientState.CharSelect, States.IsClientState, ProduceClientState, attemptCount);
                    case ClientState.InWorld:
                        if (attemptCount >= 10) {
                            intr.Log(LogEntryType.FatalWithScreenshot, "Stuck at in world. Killing all and restarting.");
                            KillAll(intr);
                            intr.Wait(5000);
                            return ProduceClientState(intr, ClientState.CharSelect, 0);
                        } else {
                            intr.Log("Logging out...");
                            LogOut(intr);
                            return intr.WaitUntil(45, ClientState.CharSelect, States.IsClientState, ProduceClientState, attemptCount);
                        }
                    case ClientState.LogIn:
                        if (attemptCount >= 10) {
                            intr.Log(LogEntryType.FatalWithScreenshot, "Stuck at client login screen. Killing all and restarting.");
                            KillAll(intr);
                            intr.Wait(5000);
                            return ProduceClientState(intr, ClientState.CharSelect, 0);
                        } else {
                            intr.Log("Client open, at login screen.");
                            ClientSignIn(intr);
                            return intr.WaitUntil(30, ClientState.CharSelect, States.IsClientState, ProduceClientState, attemptCount);
                        }
                    case ClientState.Unknown:
                    default:
                        ClearDialogues(intr);

                        if (!intr.WaitUntil(30, ClientState.CharSelect, States.IsClientState, null, attemptCount)) {
                            intr.Log(LogEntryType.Info, "Client state unknown. Attempting crash recovery...");

                            CrashCheckRecovery(intr, 0);
                            return ProduceClientState(intr, desiredState, attemptCount);

                            //var curState = Game.DetermineClientState(intr);

                            //if (curState == ClientState.Unknown) {
                            //	//CrashCheckRecovery(intr);
                            //	return
                            //} else {
                            //	return
                            //}
                        } else {
                            return true;
                        }
                }
            }

            return false;
        }
コード例 #31
0
ファイル: ClickImage.cs プロジェクト: c0gent/NeverClicker
 // Clicks an image.
 //
 // [TODO]: Randomize click location within image area.
 //
 public static bool ClickImage(Interactor intr, string imgCode)
 {
     return(ClickImage(intr, imgCode, 0, 0));
 }
コード例 #32
0
        public static void AutoCycle(
            Interactor intr,
            int startDelaySec)
        {
            if (intr.CancelSource.IsCancellationRequested)
            {
                return;
            }

            var queue      = new TaskQueue();
            int charsTotal = intr.AccountSettings.GetSettingValOr("characterCount", "general", 0);

            if (queue.IsEmpty)
            {
                intr.Log("Populating task queue: (0 -> " + (charsTotal).ToString() + ")");
                queue.Populate(intr, charsTotal, RESET_DAY);
                intr.UpdateQueueList(queue.ListClone(intr));
            }

            intr.Log("Starting AutoCycle in " + startDelaySec.ToString() + " seconds...");
            intr.Wait(startDelaySec * 1000);
            if (intr.CancelSource.IsCancellationRequested)
            {
                return;
            }
            intr.Log("Beginning AutoCycle.");


            // ##### BEGIN AUTOCYCLE LOOP #####
            while (!queue.IsEmpty && !intr.CancelSource.IsCancellationRequested)
            {
                if (IsCurfew())
                {
                    int sleepTime = intr.WaitRand(300000, 1800000);
                    intr.Log("Curfew time. Sleeping for " + (sleepTime / 60000).ToString() + " minutes.");
                }

                intr.Log(LogEntryType.Debug, "AutoCycle(): Loop iteration starting.");

                TimeSpan nextTaskMatureDelay = queue.NextTaskMatureDelay();
                intr.Log(LogEntryType.Debug, "AutoCycle(): Next task mature delay: " + nextTaskMatureDelay);

                if (nextTaskMatureDelay.Ticks <= 0)
                {
                    // TASK TIMER HAS MATURED -> CONTINUE
                    // ##### ENTRY POINT -- INVOKING & PROCESSING CHARACTER #####
                    ProcessCharacter(intr, queue);
                }
                else
                {
                    // TASK TIMER NOT MATURE YET -> WAIT
                    intr.Wait(1000);
                    intr.Log("Next task matures in " + nextTaskMatureDelay.TotalMinutes.ToString("F0") + " minutes.");

                    TimeSpan waitDelay = nextTaskMatureDelay;

                    if (nextTaskMatureDelay.TotalMinutes > 8)
                    {
                        if (queue.NextTask.Kind == TaskKind.Profession)
                        {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 25);
                        }
                        else
                        {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 15);
                        }

                        ProduceClientState(intr, ClientState.None, 0);
                    }
                    else if (nextTaskMatureDelay.TotalSeconds > 1)
                    {
                        // Delay more than 1 sec, let the train catch up...
                        ProduceClientState(intr, ClientState.Inactive, 0);
                        waitDelay = nextTaskMatureDelay + intr.RandomDelay(5, 11);
                        intr.Log("Minimizing client and waiting " + waitDelay.TotalMinutes.ToString("F0") + " minutes.");
                    }

                    if (waitDelay.TotalSeconds > 1)
                    {
                        intr.Log("Sleeping for " + waitDelay.TotalMinutes.ToString("F0") + " minutes before continuing...");
                        intr.Wait(waitDelay);
                        Screen.Wake(intr);
                    }
                }

                intr.Wait(100);
            }

            intr.Log(LogEntryType.Info, "Autocycle complete.");
        }
コード例 #33
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Click(Interactor intr, Point point, int xOfs, int yOfs)
 {
     Click(intr, point.X + xOfs, point.Y + yOfs);
 }
コード例 #34
0
ファイル: ClearDialogues.cs プロジェクト: c0gent/NeverClicker
 public static void ClearWindowsWithX(Interactor intr)
 {
     Mouse.ClickImage(intr, "WindowXButton");
 }
コード例 #35
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Click(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Clicking at ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 1 }");
 }
コード例 #36
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Move(Interactor intr, Point point)
 {
     Move(intr, point.X, point.Y);
 }
コード例 #37
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Click(Interactor intr, int xCoord, int yCoord, int xOfs, int yOfs)
 {
     Click(intr, xCoord + xOfs, yCoord + yOfs);
 }
コード例 #38
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 //public static void SendInput(Interactor intr, string key) {
 //    //intr.Wait(200);
 //    intr.ExecuteStatement("SendInput " + key);
 //    intr.Wait(50);
 //}
 //public static void SendPlay(Interactor intr, string keys) {
 //    intr.ExecuteStatement("SendPlay " + keys);
 //    intr.Wait(50);
 //}
 //public static void SendEvent(Interactor intr, string keys) {
 //    intr.ExecuteStatement("SendEvent " + keys);
 //    intr.Wait(50);
 //}
 public static void SendTest(Interactor intr, string key)
 {
     intr.Wait(3000);
     intr.ExecuteStatement("SendEvent " + key);
     intr.Wait(50);
 }
コード例 #39
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void DoubleClick(Interactor intr, Point point)
 {
     DoubleClick(intr, point.X, point.Y);
 }
コード例 #40
0
        public static void ProcessCharacter(
            Interactor intr,
            TaskQueue queue
            )
        {
            var  currentTask = queue.NextTask;
            uint charIdx     = currentTask.CharIdx;
            //string charLabel = intr.AccountSettings.CharNode(charIdx).GetAttribute("name");
            string charLabel = intr.AccountSettings.CharNames[(int)charIdx];
            //string charLabel = queue.NextTask.CharIdxLabel;
            int  invokesToday    = intr.AccountStates.GetCharStateOr(charIdx, "invokesToday", 0);
            bool skipInvocation  = false;
            bool skipMaintInven  = false;
            bool skipProfessions = false;

            DateTime invokesCompletedForDay = intr.AccountStates.GetCharStateOr(charIdx,
                                                                                "invokesCompleteFor", Global.Default.SomeOldDate);

            if (invokesCompletedForDay == TaskQueue.TodaysGameDate)
            {
                // Skip invocation if it's already done.
                skipInvocation = true;
            }
            else if (invokesCompletedForDay < TaskQueue.TodaysGameDate && invokesToday < 2 &&
                     currentTask.Kind == TaskKind.Invocation)
            {
                // Skip professions for the first few invokes of the day.
                intr.Log(LogEntryType.Info, "Skipping profession processing this round.");
                skipProfessions = true;
            }

            // Skip inventory processing for the first two invokes [0, 1] and every non invoke task:
            if (invokesToday < 2 || currentTask.Kind != TaskKind.Invocation)
            {
                intr.Log(LogEntryType.Info, "Skipping inventory processing this round.");
                skipMaintInven = true;
            }


            CompletionStatus invocationStatus     = CompletionStatus.None;
            CompletionStatus professionsStatus    = CompletionStatus.None;
            CompletionStatus maintStatus          = CompletionStatus.None;
            bool             processingIncomplete = false;

            intr.Log("Starting processing for " + charLabel + " ...");

            // Reset `invokesToday` if `invokesCompletedOn` is
            if (invokesToday >= 6)
            {
                if (currentTask.Kind == TaskKind.Invocation)
                {
                    if (invokesCompletedForDay == TaskQueue.TodaysGameDate)
                    {
                        intr.Log(LogEntryType.Info, charLabel +
                                 " has already invoked 6 times today. Queuing invocation for tomorrow");
                        queue.AdvanceInvocationTask(intr, charIdx, invokesToday, false);
                        skipInvocation = true;
                        skipMaintInven = true;
                        //queue.QueueSubsequentInvocationTask(intr, charIdx, invokesToday);
                        return;
                    }
                    else if (invokesCompletedForDay < TaskQueue.TodaysGameDate)
                    {
                        intr.Log(LogEntryType.Info, charLabel + ": Resetting InvokesToday to 0.");
                        invokesToday = 0;
                        intr.AccountStates.SaveCharState(invokesToday, charIdx, "invokesToday");
                    }
                    else
                    {
                        var errMsg = charLabel + ": Internal error. `invokesCompletedOn` is in the future.";
                        intr.Log(LogEntryType.Fatal, errMsg);
                        throw new Exception(errMsg);
                    }
                }
            }

            // CHECK TO SEE IF THERE ARE ANY UPCOMING TASKS FOR CHARACTER IN THE NEXT 29:59 MINUTES
            // IF SO -> CHECK TO SEE IF THERE ARE ANY TASKS IN THE 29:59 (TOTAL 59:59) MINUTES AFTER THAT
            //	IF NOT -> MERGE TASKS
            //	IF SO -> CONTINUE

            if (!ProduceClientState(intr, ClientState.CharSelect, 0))
            {
                return;
            }

            intr.Log(LogEntryType.Info, "ProcessCharacter(): Selecting " + charLabel + " ...");

            if (!SelectCharacter(intr, charIdx, ENTER_WORLD))
            {
                return;
            }

            // [DO NOT REMOVE]:
            //
            //int selectAttemptCount = 0;

            //while (!SelectCharacter(intr, charIdx, ENTER_WORLD)) {
            //	// Determine if login has been a success:
            //	if (!intr.WaitUntil(90, ClientState.InWorld, Game.IsClientState, CharSelectFailure, 0)) {
            //		ProduceClientState(intr, ClientState.CharSelect, attemptCount);
            //		SelectCharacter(intr, charIdx, enterWorld, attemptCount);
            //		//return false;
            //	}
            //	ClearDialogues(intr);

            //	selectAttemptCount += 1;

            //	if (selectAttemptCount >= SELECT_ATTEMPTS_MAX) {
            //		intr.Log("ProcessCharacter(): Fatal error selecting " + charLabel + ".", LogEntryType.Fatal);
            //		return;
            //	}
            //}

            // NEW PLAN:
            // SelectCharacter()
            // Determine if client state is still ClientState.CharSelect
            //    If so, FatalWithScreenShot
            //    If not, start the 'Verification' loop which will look for signs of the 'World'
            //
            //
            // END [DO NOT REMOVE]

            if (!ENTER_WORLD)
            {
                                #pragma warning disable CS0162 // Unreachable code detected
                queue.AdvanceInvocationTask(intr, charIdx, invokesToday, false);
                                #pragma warning restore CS0162 // Unreachable code detected
                return;
            }

            // ################################## CLEAR AND MOVE ##################################
            intr.Wait(1500);
            ClearDialogues(intr);
            MoveAround(intr);

            // ############################### INVENTORY MAINTENANCE ##############################
            if (!skipMaintInven)
            {
                intr.Log(LogEntryType.Info, "ProcessCharacter(): Maintaining inventory for " + charLabel + " ...");
                maintStatus = MaintainInventory(intr, charIdx);
                intr.Log(LogEntryType.Info, "ProcessCharacter(): Inventory maintenance status: " + maintStatus.ToString());
            }

            // #################################### INVOCATION ####################################
            if (!skipInvocation)
            {
                intr.Log(LogEntryType.Info, "ProcessCharacter(): Invoking for " + charLabel + " ...");
                invocationStatus = Invoke(intr, charIdx);
                intr.Log(LogEntryType.Info, "ProcessCharacter(): Invocation status: " + invocationStatus.ToString());
            }

            // ################################### PROFESSIONS ####################################
            var professionTasksProcessed = new List <ProfessionTaskResult>(9);

            if (!skipProfessions)
            {
                intr.Log(LogEntryType.Info, "ProcessCharacter(): Maintaining profession tasks for " + charLabel + " ...");
                professionsStatus = MaintainProfs(intr, charIdx, professionTasksProcessed);
                intr.Log(LogEntryType.Info, "ProcessCharacter(): Professions status: " + professionsStatus.ToString());
            }


            // ##################################### LOG OUT ######################################
            LogOut(intr);

            // ########################### INVOCATION QUEUE AND SETTINGS ##########################
            if (invocationStatus == CompletionStatus.Complete)
            {
                intr.Log(LogEntryType.Normal, "Invocation task for " + charLabel + ": Complete.");
                queue.AdvanceInvocationTask(intr, charIdx, invokesToday, true);
            }
            else if (invocationStatus == CompletionStatus.DayComplete)
            {
                intr.Log(LogEntryType.Normal, "Daily invocations for " + charLabel + ": Complete for day.");
                queue.AdvanceInvocationTask(intr, charIdx, 6, true);
            }
            else if (invocationStatus == CompletionStatus.Immature && currentTask.Kind == TaskKind.Invocation)
            {
                intr.Log(LogEntryType.Normal, "Invocation task for " + charLabel + ": Immature.");
                intr.Log(LogEntryType.Info, "Re-queuing task for " + charLabel + ".");
                queue.AdvanceInvocationTask(intr, charIdx, invokesToday, false);
            }
            else if (invocationStatus == CompletionStatus.Failed && currentTask.Kind == TaskKind.Invocation)
            {
                intr.Log(LogEntryType.Normal, "Invocation task for " + charLabel + ": Failed.");
                queue.AdvanceInvocationTask(intr, charIdx, invokesToday, false);
                //processingIncomplete = true;
            }
            else if (invocationStatus == CompletionStatus.Cancelled && currentTask.Kind == TaskKind.Invocation)
            {
                intr.Log(LogEntryType.Normal, "Invocation task for " + charLabel + ": Cancelled.");
                //processingIncomplete = true;
            }

            // ######################### PROFESSIONS QUEUE AND SETTINGS ###########################
            intr.Log(LogEntryType.Normal, "Profession task for " + charLabel + ": " + professionsStatus.ToString()
                     + ", items complete: " + professionTasksProcessed.Count);
            if (professionsStatus == CompletionStatus.Complete)
            {
                foreach (ProfessionTaskResult taskResult in professionTasksProcessed)
                {
                    queue.AdvanceProfessionsTask(intr, charIdx, taskResult.TaskId, taskResult.BonusFactor);
                }
            }
            else if (professionsStatus == CompletionStatus.Stuck && currentTask.Kind == TaskKind.Profession)
            {
                // I guess we have to do this to progress a task which is stuck:
                queue.AdvanceProfessionsTask(intr, currentTask.CharIdx, currentTask.TaskId, currentTask.BonusFactor);
            }
            else if (professionsStatus == CompletionStatus.Immature && currentTask.Kind == TaskKind.Profession)
            {
                // Pretty sure we still need this:
                queue.AdvanceProfessionsTask(intr, currentTask.CharIdx, currentTask.TaskId, currentTask.BonusFactor);
            }
            else if (currentTask.Kind == TaskKind.Profession)
            {
                // IF the status was NOT `CompletionStatus.Complete` AND the next task is a profession task for this character:
                processingIncomplete = true;
                // CANCELLED OR FAILED
                //queue.AdvanceTask(intr, currentTask.CharIdx, TaskKind.Profession, currentTask.TaskId);		// SAME
            }

            //// EVALUATE WHETHER OR NOT TO BRING THIS BACK:
            //if (!processingIncomplete && !skipProfessions && !skipInvocation) {
            //	intr.Log(LogEntryType.Normal, "Advancing all matured tasks for character {0}.", charIdx.ToString());
            //	queue.AdvanceMatured(intr, charIdx);
            //}

            if (processingIncomplete)
            {
                intr.Log(LogEntryType.Normal, "Processing incomplete for " + charLabel + ".");
            }
            else
            {
                intr.Log(LogEntryType.Normal, "Processing complete for " + charLabel + ".");
            }
        }
コード例 #41
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Move(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Moving mouse cursor to ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 0 }");
 }
コード例 #42
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void DoubleClick(Interactor intr, Point point)
 {
     DoubleClick(intr, point.X, point.Y);
 }
コード例 #43
0
ファイル: Keyboard.cs プロジェクト: c0gent/NeverClicker
 public static void SendInput(Interactor intr, string key)
 {
     //intr.Wait(200);
     intr.ExecuteStatement("SendInput " + key);
     intr.Wait(20);
 }
コード例 #44
0
ファイル: World.cs プロジェクト: c0gent/NeverClicker
        public static ImageSearchResult GetUiWindowPosition(Interactor intr, string titleImgCode)
        {
            var titleSearchRes = Screen.ImageSearch(intr, titleImgCode);

            return(titleSearchRes);
        }
コード例 #45
0
ファイル: Keyboard.cs プロジェクト: c0gent/NeverClicker
 public static void SendTest(Interactor intr, string key)
 {
     intr.Wait(3000);
     SendInput(intr, key);
 }
コード例 #46
0
ファイル: Invoke.cs プロジェクト: c0gent/NeverClicker
        public static CompletionStatus Invoke(Interactor intr, uint charIdx)
        {
            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }

            string charLabel = intr.AccountSettings.CharNames[(int)charIdx];
            string invokeKey = intr.AccountSettings.GetSettingValOr("invoke", "gameHotkeys", Global.Default.InvokeKey);

            // Invocation Attempt (first):
            Keyboard.SendKey(intr, invokeKey);
            intr.Wait(300);

            if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionWindowTitle").Found)
            {
                intr.Wait(200);

                if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionInvokeReady").Found)
                {
                    intr.Wait(2000);
                    // Invocation Attempt:
                    Keyboard.SendKey(intr, invokeKey);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionDoneForDay").Found)
                {
                    intr.Log("Unable to invoke: Invocation already finished for the day on " + charLabel + ".");
                    return(CompletionStatus.DayComplete);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionPatience").Found)
                {
                    intr.Log("Unable to invoke: Still waiting to invoke on " + charLabel + ".");
                    return(CompletionStatus.Immature);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionNotInRestZone").Found)
                {
                    intr.Log(LogEntryType.Error, "Unable to invoke: " + charLabel + " not in rest zone.");
                    return(CompletionStatus.Complete);
                }
                else if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionItemsInOverflow").Found)
                {
                    intr.Log(LogEntryType.Error, "Unable to invoke: Items in overflow bag are preventing invocation for "
                             + charLabel + ". Attempting to move to regular inventory...");

                    // Attempt to transfer overflow items to regular inventory:
                    //
                    // [NOTE]: Possibly Redundant.
                    // - Determine if it is possible for new items to be added to inventory
                    //   between inventory management and here.
                    //
                    TransferOverflow(intr, false, false);
                    MoveAround(intr);

                    // Invocation Attempt:
                    Keyboard.SendKey(intr, invokeKey);
                }
                else
                {
                    intr.Log(LogEntryType.FatalWithScreenshot, "Unable to invoke for " + charLabel +
                             "." + "[IN0]");
                    intr.Wait(30000);
                    return(CompletionStatus.Failed);
                }
            }
            else if (Screen.ImageSearch(intr, "InvocationMaximumBlessings").Found || DEBUG_ALWAYS_REDEEM)
            {
                // Vault of Piety //
                intr.Log(LogEntryType.Info, "Maximum blessings reached for " + charLabel
                         + ". Redeeming through Vault of Piety...");

                if (DEBUG_ALWAYS_REDEEM)
                {
                                        #pragma warning disable CS0162 // Unreachable code detected
                    MoveAround(intr);
                                        #pragma warning restore CS0162 // Unreachable code detected
                }

                if (Redeem(intr, charIdx))
                {
                    MoveAround(intr);
                    intr.Log(LogEntryType.Debug, "Redeeming Vault of Piety...");
                    // Invocation Attempt:
                    Keyboard.SendKey(intr, invokeKey);
                }
                else
                {
                    intr.Log(LogEntryType.Error, "Unable to invoke: Error collecting Vault of Piety rewards for " + charLabel + ".");
                    return(CompletionStatus.Failed);
                }
            }

            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }
            intr.Wait(2800);

            if (!intr.WaitUntil(5, DialogueBoxState.InvocationSuccess, States.IsDialogueBoxState, null, 0))
            {
                // Invocation Attempt:
                Keyboard.SendKey(intr, invokeKey);
                intr.Wait(1500);
                MoveAround(intr);
            }

            //// [FIXME]: Not sure why this is here still or why it was needed:
            //if (Screen.ImageSearch(intr, "InvocationRewardsOfDevotionWindowTitle").Found) {
            //	intr.Log("Closing Rewards of Devotion window and reassessing invocation success...", LogEntryType.Debug);
            //	//Mouse.ClickImage(intr, "InvocationRewardsOfDevotionCloseButton");
            //}

            if (!intr.WaitUntil(9, DialogueBoxState.InvocationSuccess, States.IsDialogueBoxState, null, 0))
            {
                // Invocation Attempt Failure -- Display invocation screen for the screenshot:
                Keyboard.SendKey(intr, invokeKey);
                intr.Wait(1500);

                intr.Log(LogEntryType.FatalWithScreenshot, "Unable to invoke for character " + charLabel +
                         "." + "[FN1]");

                intr.Wait(30000);
                MoveAround(intr);
                return(CompletionStatus.Failed);
            }

            intr.Log(LogEntryType.Info, "Invocation successful. Continuing...");

            if (intr.CancelSource.IsCancellationRequested)
            {
                return(CompletionStatus.Cancelled);
            }

            return(CompletionStatus.Complete);
        }
コード例 #47
0
ファイル: Keyboard.cs プロジェクト: c0gent/NeverClicker
 public static void SendKey(Interactor intr, string keyMod, string key)
 {
     SendKeyWithMod(intr, keyMod, key, SendMode.Event);
 }
コード例 #48
0
ファイル: ClearSafeLogin.cs プロジェクト: c0gent/NeverClicker
 public static void ClearSafeLogin(Interactor intr)
 {
     Mouse.ClickImage(intr, "CharSelectSafeLoginButton");
 }
コード例 #49
0
ファイル: Client.cs プロジェクト: c0gent/NeverClicker
        //public static bool ActivateClient(Interactor intr) {
        //	//intr.ExecuteStatement("ActivateNeverwinter()");

        //	Screen.WindowActivate(intr, Game.GAMECLIENTEXE);

        //	intr.Wait(1000);

        //	return true;
        //}

        //public static bool LogOut(Interactor intr) {
        //	//intr.ExecuteStatement("Logout()");
        //	intr.Log("Logging out...", LogEntryType.Info);

        //	MoveAround(intr);

        //	Keyboard.SendKey(intr, "Enter");
        //	intr.Wait(50);

        //	Keyboard.Send(intr, "/gotocharacterselect");
        //	intr.Wait(100);

        //	Keyboard.SendKey(intr, "Enter");
        //	intr.Wait(100);

        //	intr.Wait(3000);

        //	return true;
        //}


        public static bool ClientSignIn(Interactor intr)
        {
            intr.Log(LogEntryType.Info, "Signing in Client...");

            //intr.ExecuteStatement("ClientLogin()");

            intr.Wait(5000);

            ClearDialogues(intr);

            //if (!intr.WaitUntil(15, ClientState.LogIn, Game.IsClientState, null, 0)) { return false; }

            string gameUserName = intr.AccountSettings.GetSettingValOr("accountName", "general", "");
            string gamePassword = intr.AccountSettings.GetSettingValOr("password", "general", "");

            intr.Wait(1000);

            //var shiftHome = @"Send {Shift down}
            //	Sleep 20
            //	Send { Home down}
            //	Sleep 20
            //	Send { Shift up}
            //	Sleep 20
            //	Send { Home up}
            //	Sleep 20
            //";

            //intr.ExecuteStatement(shiftHome);
            Keyboard.SendKeyWithMod(intr, "Shift", "Tab", Keyboard.SendMode.Input);
            intr.Wait(200);

            Keyboard.SendKeyWithMod(intr, "Shift", "Home", Keyboard.SendMode.Input);

            Keyboard.Send(intr, gameUserName);

            Keyboard.SendKey(intr, "Tab");
            intr.Wait(200);

            Keyboard.Send(intr, gamePassword);
            intr.Wait(200);

            Keyboard.SendKey(intr, "Enter");

            intr.Wait(3000);

            // [TODO]: THIS NEEDS TO CLEAR VERIFY? DIALOGUE
            //ClearDialogues(intr);

            return(true);

            //ClientLogin() {
            //	global

            //	While ((ToggleInv && !FindClientLoginButton()) && (A_Index < 10))  {
            //		LogAppend("[Attempting to find ClientLoginButton.]")
            //		sleep 1500
            //	}

            //	if (ToggleInv && !FindClientLoginButton()) {
            //			LogAppend("[Not sure if we found ClientLoginButton but continuing...]")
            //			; msgbox ClientLogin() Waited too long for Login Screen to appear. If you are at login screen please check or remake %Lb_ImageFile%.
            //	}

            //	if (ToggleInv) {
            //		Sleep 2000 + Ran(500)
            //		Send {Shift down}
            //		Sleep 20
            //		Send {Home down}
            //		Sleep 20
            //		Send {Shift up}
            //		Sleep 20
            //		Send {Home up}
            //		Sleep 20
            //		Send %NwUserName%
            //		Sleep 50
            //		Send {Tab}
            //		Sleep 200 + Ran(100)
            //		Send %NwActPwd%
            //		Sleep 200 + Ran(100)
            //		Send {Enter}
            //		Sleep AfterLoginDelay + Ran(120)
            //	}
            //}
        }
コード例 #50
0
ファイル: AutoCycle.cs プロジェクト: c0gent/NeverClicker
        public static void AutoCycle(
					Interactor intr,
					int startDelaySec)
        {
            if (intr.CancelSource.IsCancellationRequested) { return; }

            var queue = new TaskQueue();
            int charsTotal = intr.AccountSettings.GetSettingValOr("characterCount", "general", 0);

            if (queue.IsEmpty) {
                intr.Log("Populating task queue: (0 -> " + (charsTotal).ToString() + ")");
                queue.Populate(intr, charsTotal, RESET_DAY);
                intr.UpdateQueueList(queue.ListClone(intr));
            }

            intr.Log("Starting AutoCycle in " + startDelaySec.ToString() + " seconds...");
            intr.Wait(startDelaySec * 1000);
            if (intr.CancelSource.IsCancellationRequested) { return; }
            intr.Log("Beginning AutoCycle.");

            // ##### BEGIN AUTOCYCLE LOOP #####
            while (!queue.IsEmpty && !intr.CancelSource.IsCancellationRequested) {
                if (IsCurfew()) {
                    int sleepTime = intr.WaitRand(300000, 1800000);
                    intr.Log("Curfew time. Sleeping for " + (sleepTime / 60000).ToString() + " minutes.");
                }

                intr.Log(LogEntryType.Debug, "AutoCycle(): Loop iteration starting.");

                TimeSpan nextTaskMatureDelay = queue.NextTaskMatureDelay();
                intr.Log(LogEntryType.Debug, "AutoCycle(): Next task mature delay: " + nextTaskMatureDelay);

                if (nextTaskMatureDelay.Ticks <= 0) {
                    // TASK TIMER HAS MATURED -> CONTINUE
                    // ##### ENTRY POINT -- INVOKING & PROCESSING CHARACTER #####
                    ProcessCharacter(intr, queue);
                } else {
                    // TASK TIMER NOT MATURE YET -> WAIT
                    intr.Wait(1000);
                    intr.Log("Next task matures in " + nextTaskMatureDelay.TotalMinutes.ToString("F0") + " minutes.");

                    TimeSpan waitDelay = nextTaskMatureDelay;

                    if (nextTaskMatureDelay.TotalMinutes > 8) {
                        if (queue.NextTask.Kind == TaskKind.Profession) {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 25);
                        } else {
                            waitDelay = nextTaskMatureDelay + intr.RandomDelay(9, 15);
                        }

                        ProduceClientState(intr, ClientState.None, 0);
                    } else if (nextTaskMatureDelay.TotalSeconds > 1) {
                        // Delay more than 1 sec, let the train catch up...
                        ProduceClientState(intr, ClientState.Inactive, 0);
                        waitDelay = nextTaskMatureDelay + intr.RandomDelay(5, 11);
                        intr.Log("Minimizing client and waiting " + waitDelay.TotalMinutes.ToString("F0") + " minutes.");
                    }

                    if (waitDelay.TotalSeconds > 1) {
                        intr.Log("Sleeping for " + waitDelay.TotalMinutes.ToString("F0") + " minutes before continuing...");
                        intr.Wait(waitDelay);
                        Screen.Wake(intr);
                    }
                }

                intr.Wait(100);
            }

            intr.Log(LogEntryType.Info, "Autocycle complete.");
        }
コード例 #51
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Click(Interactor intr, int xCoord, int yCoord, int xOfs, int yOfs)
 {
     Click(intr, xCoord + xOfs, yCoord + yOfs);
 }
コード例 #52
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Click(Interactor intr, Point point, int xOfs, int yOfs)
 {
     Click(intr, point.X + xOfs, point.Y + yOfs);
 }
コード例 #53
0
ファイル: Patcher.cs プロジェクト: c0gent/NeverClicker
        //Potentially split into ProducePatcherState & Sub-functions
        public static bool PatcherLogin <TState>(Interactor intr, TState state)
        {
            //intr.ExecuteStatement("ActivateNeverwinter()");

            string gameUserName = intr.AccountSettings.GetSettingValOr("accountName", "general", "");
            string gamePassword = intr.AccountSettings.GetSettingValOr("password", "general", "");

            if (gameUserName == "enter_user_name" || gameUserName == "" ||
                gamePassword == "enter_password" || gamePassword == "")
            {
                intr.Log(LogEntryType.Fatal, "Username and/or Password not configured properly. Please edit " +
                         "NeverClicker_GameAccount.ini and enter them there.");
                intr.CancelSource.Cancel();
                return(false);
            }

            Mouse.Move(intr, 0, 0);

            // If patcher is already open, close it:
            if (States.DeterminePatcherState(intr) != PatcherState.None)
            {
                Screen.WindowKill(intr, States.GAMEPATCHEREXE);
                if (!intr.WaitUntil(15, PatcherState.None, States.IsPatcherState, PatcherKillFailure, 0))
                {
                    return(false);
                }
            }

            // Open patcher:
            Screen.WindowRun(intr, Properties.Settings.Default.NeverwinterExePath);
            if (!intr.WaitUntil(90, GameState.Patcher, States.IsGameState, PatcherRunFailure, 0))
            {
                return(false);
            }

            // Set focus on patcher:
            intr.Wait(4000);
            Screen.WindowActivate(intr, States.GAMEPATCHEREXE);
            intr.Wait(1000);

            // Make sure server is up:
            if (States.IsServerState(intr, ServerState.Down))
            {
                intr.Log("Server is down. Waiting until it comes up...");
                //intr.Wait(1200000);
                //return false;

                // Check every 1min for 20min and return false (relaunching patcher) if unsuccessful.
                if (!intr.WaitUntil(1200, 60, ServerState.Up, States.IsServerState, PatcherServerFailure, 0))
                {
                    return(false);
                }
            }

            // Wait for login button to appear:
            if (!intr.WaitUntil(90, PatcherState.LogIn, States.IsPatcherState, PatcherRunFailure, 0))
            {
                return(false);
            }

            // Set focus on patcher:
            Screen.WindowActivate(intr, States.GAMEPATCHEREXE);

            //while (intr.WaitUntil(10, PatcherState.LogIn, Game.IsPatcherState, null, 0)) {
            //	//Keyboard.SendEvent(intr, "{Shift down}{Tab}{Shift up}");
            //	Keyboard.SendKeyWithMod(intr, "Shift", "Tab", Keyboard.SendMode.Event);
            //	Keyboard.SendInput(intr, gameUserName);
            //	intr.Wait(500);
            //	Keyboard.SendInput(intr, "{Tab}");
            //	Keyboard.SendInput(intr, gamePassword);
            //	intr.Wait(500);
            //	Keyboard.SendInput(intr, "{Enter}");
            //	intr.Wait(10000);
            //}

            intr.Wait(500);
            Keyboard.SendKeyWithMod(intr, "Shift", "Tab", Keyboard.SendMode.Event);
            Keyboard.SendInput(intr, gameUserName);
            intr.Wait(500);
            Keyboard.SendInput(intr, "{Tab}");
            Keyboard.SendInput(intr, gamePassword);
            intr.Wait(500);
            Keyboard.SendInput(intr, "{Enter}");
            intr.Wait(10000);

            Screen.WindowKillTitle(intr, "Verify?");

            // // Set focus on patcher:
            //Screen.WindowActivate(intr, Game.GAMEPATCHEREXE);

            if (!intr.WaitUntil(1800, PatcherState.PlayButton, States.IsPatcherState, PatcherLogInFailure, 0))
            {
                return(false);
            }

            //intr.Wait(1000);
            //Keyboard.SendKeyWithMod(intr, "Shift", "Tab", Keyboard.SendMode.Event);
            //intr.Wait(300);
            //Keyboard.SendKeyWithMod(intr, "Shift", "Tab", Keyboard.SendMode.Event);
            //Keyboard.SendInput(intr, "{Enter}");

            // Click play button image (may not be as reliable as above):
            Mouse.ClickImage(intr, "PatcherPlayButton");

            return(intr.WaitUntil(60, ClientState.CharSelect, States.IsClientState, ProduceClientState, 0));
        }
コード例 #54
0
        public static void WindowActivate(Interactor intr, string windowExe)
        {
            string param = string.Format("ahk_exe {0}", windowExe);

            intr.ExecuteStatement("WinActivate, " + param);
        }
コード例 #55
0
ファイル: Patcher.cs プロジェクト: c0gent/NeverClicker
 public static bool PatcherKillFailure <TState>(Interactor intr, TState state, int attemptCount)
 {
     intr.Log(LogEntryType.Error, "Failed to launch Patcher, unable to close existing process. Patcher state: " + state.ToString());
     return(false);
 }
コード例 #56
0
 public static bool WindowDetectExist(Interactor intr, string windowExe)
 {
     return(WindowDetect(intr, windowExe, "Exist"));
 }
コード例 #57
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void Move(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Moving mouse cursor to ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 0 }");
 }
コード例 #58
0
ファイル: Patcher.cs プロジェクト: c0gent/NeverClicker
 public static bool PatcherLogInFailure <TState>(Interactor intr, TState state, int attemptCount)
 {
     intr.Log(LogEntryType.Error, "Failed to log in using patcher, play button not found. Patcher state: " + state.ToString());
     return(false);
 }
コード例 #59
0
ファイル: Mouse.cs プロジェクト: c0gent/NeverClicker
 public static void WheelUp(Interactor intr, int repeats)
 {
     for (int c = 0; c < repeats; c++) {
         intr.ExecuteStatement("SendEvent { Click WheelUp }");
         intr.Wait(5);
     }
 }
コード例 #60
0
ファイル: Patcher.cs プロジェクト: c0gent/NeverClicker
 public static bool PatcherServerFailure <TState>(Interactor intr, TState state, int attemptCount)
 {
     intr.Log(LogEntryType.Error, "Failed to log in using patcher, server status down. Patcher state: " + state.ToString());
     return(false);
 }