コード例 #1
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)
            //	}
            //}
        }
コード例 #2
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));
        }