NightmareXIV / AntiAfkKick

An application, Dalamud and ACT plugin for preventing being auto-kicked from FFXIV due to inactivity.
GNU Affero General Public License v3.0
111 stars 24 forks source link

Standalone and ACT versions: game changes #4

Closed Limiana closed 2 years ago

Limiana commented 3 years ago

Standalone version and ACT plugin are expected to be working immediately, but due to internal game changes a changes to the program/plugin might be required. Please report here if you encounter any problems, feel free to report that program works fine as well if it does for you.

Additional information: to test it without risk of being kicked - enter any duty undersized and go afk for 7-10 minutes. Should you come back and see no messages that you are being inactive - the program/plugin is working fine. Should you see a warning about auto-kick from duty, it means anti-kick does not works.

finc2020 commented 3 years ago

Tested out Standalone, working so far at 40 minutes in with three clients. HUD and talking to NPC no longer works

Rubylium commented 3 years ago

Tested on my side, not working. The standalone version was running but i was still sent back to the main screen

Limiana commented 3 years ago

Tested on my side, not working. The standalone version was running but i was still sent back to the main screen

can you tell me more of the circumstances? Did you have game in background or active? And were you just kicked to main screen or did the error appeared?

Squall-Leonhart commented 3 years ago

the game is ignoring repeated keystrokes in the idle detection, even a rubber band on a controller doesn't prevent the kick if the the direction never changes.

might be as simple as sending additional buttons and randomizing them.

Limiana commented 3 years ago

It would seem that there is some different behavior related to controller being used. I would suggest waiting for Dalamud version for further diagnostics, it will be updated soon.

DuckieFried commented 2 years ago

I tried the standalone version and was kicked to title screen. I had the game selected and not tabbed out of it so maybe that is the problem?

Limiana commented 2 years ago

I had the game selected and not tabbed out of it so maybe that is the problem?

Are you using controller by any chance?

Please proceed to https://github.com/xaviergmail/DiscordNotificationDebug - download InputDebugger.exe as stated in the article and launch it and see if your system is able to correctly registed idle time. This is crucial for the program to work.

DuckieFried commented 2 years ago

I had the game selected and not tabbed out of it so maybe that is the problem?

Are you using controller by any chance?

Please proceed to https://github.com/xaviergmail/DiscordNotificationDebug - download InputDebugger.exe as stated in the article and launch it and see if your system is able to correctly registed idle time. This is crucial for the program to work.

Nope, no controller. Just mouse and keyboard

Limiana commented 2 years ago

and what are the results of InputDebugger?

DuckieFried commented 2 years ago

Seems to be working correctly, if i dont touch anything it shows the system is idle message its supposed to. Do i just leave that running like that or close it out? Also, if i do need to afk do i alt tab from the game or does it matter?

Limiana commented 2 years ago

No need to leave that program open, it was just for diagnostics. And you shouldn't need to alt-tab from the game if the program indicates that idle timer works fine... but if you have problems, then do alt-tab. Tomorrow I will be releasing Dalamud version which should be free of all these potential problems of standalone.

DuckieFried commented 2 years ago

OK sweet, tyvm. Ill keep a look out for it tomorrow.

GoldenChrysus commented 2 years ago

Been logged in for over 24 hours with standalone, Windows 10 19043, MKB input, windowed mode FFXIV.

dstevenson12 commented 2 years ago

Also, can confirm that standalone DID NOT keep me logged in. MKB input, Windows 11, full screen FFXIV

MarcTheDev commented 2 years ago

Been logged in for over 24 hours with standalone, Windows 10 19043, MKB input, windowed mode FFXIV.

Did you alt tab too? I put in windowed mode, not sure if I can do other things while keeping game minimized.

DuckieFried commented 2 years ago

Seems windowed mode is the key here

patrat46 commented 2 years ago

Been logged in for over 24 hours with standalone, Windows 10 19043, MKB input, windowed mode FFXIV.

Did you alt tab too? I put in windowed mode, not sure if I can do other things while keeping game minimized.

Shouldn't be an issue in standalone. I don't know act.

The stand alone sends the left control click for .2 seconds to all final fantasy game processes that have been in active since the last run. You can do other things in other games or windows and they should not be interrupted.

Game can be minimized, in the background, maximized, full screen or boarderless window mode without issue.

Do you have left default key binding or a customer key binding for left control?

alkado commented 2 years ago

Tested the standalone today (6-Dec-21) for the first time in hopes of finally getting some early access playtime. Also had a water bottle sitting on movement keys to double-up my efforts but when I made it home I was disconnected. Unknown how much time passed.

edit) Windowed, maximized, primary window. I don't play with controller, but to be sure, it was unplugged at the time.

patrat46 commented 2 years ago

Tested the standalone today (6-Dec-21) for the first time in hopes of finally getting some early access playtime. Also had a water bottle sitting on movement keys to double-up my efforts but when I made it home I was disconnected. Unknown how much time passed.

edit) Windowed, maximized, primary window. I don't play with controller, but to be sure, it was unplugged at the time.

I think that may be the issue. (Bold is not very bold this: water bottle sitting on movement keys)

Part of the standalone programming checks that the last actions was not within a certain period of time. If there was activity then it waits. This is so you can still play the game without getting odd results or key combination.

By running or moving in the game the anti afk kicker program will not take action, while the game will not recognize running in place as an action.

The combination of Anti-AFK kicker detecting action... And the game not detecting that same action as valid is why you got kicked.

Edit- Looking at the latest code it seems it is watching the active window for inactivity over 1 minute and sending left control. Likely still the same cause. Either you need to be actually active or you need to be inactive for it to work correctly.

VoidVi commented 2 years ago

I have tried both the ACT plugin and the standalone and neither version is working. Both tests were done on borderless windowed mode with the game in focus. I went into a dungeon and eventually was booted for 10 minutes of inactivity on both tests.

Limiana commented 2 years ago

@alkado no please don't put the water bottle on your keyboard, as mentioned above program will read that as your activity in the game and simply cease to work, since there is no feasible way to detect if it's you pressing keys or water bottle

@Vivelric could you download InputDebugger from here https://github.com/xaviergmail/DiscordNotificationDebug and test if your system is being able to register inactivity?

@dstevenson12 unfortunately true fullscreen application may behave differently when inactive, for example refusing to accept any inputs. And unfortunately it may vary from system to system, as I've learned.

Either way, Dalamud version was updated and I'd suggest that if you have problems with standalone, try switching to Dalamud. If there is still a problem with Dalamud's version, then further diagnostics is easier to be done from within there rather than standalone application. Dalamud version reads afk timers directly from the game and does not relies on any external methods that might be inaccurate or flawed.

VoidVi commented 2 years ago

@Vivelric could you download InputDebugger from here https://github.com/xaviergmail/DiscordNotificationDebug and test if your system is being able to register inactivity?

Either way, Dalamud version was updated and I'd suggest that if you have problems with standalone, try switching to Dalamud. If there is still a problem with Dalamud's version, then further diagnostics is easier to be done from within there rather than standalone application. Dalamud version reads afk timers directly from the game and does not relies on any external methods that might be inaccurate or flawed.

@Eternita-S Very big wall of text, I am sorry but I hope this is of some help. I did some further testing between 2 of the 3 options in various game states. For further clarity, all tests were done inside tam tara. No movement of the mouse or any button clicks from either the mouse or keyboard were done during the test (I don't use controller so can't test that, sorry!). Basically just set it up and then didn't touch the system until 10 minutes was up (or I heard the music change back to Thavnair music).

Standalone version: Windowed with game in focus: Did not work Borderless with game in focus: Did not work Full screen with game in focus: Did not work.

Windowed tabbed out of the game: Did work Borderless tabbed out of the game: Did work Full screen tabbed out of the game: Did work.

ACT Plugin: Windowed with game in focus: Did not work Borderless with game in focus: Did not work Full screen with game in focus: Did not work.

Windowed tabbed out of the game: Did work Borderless tabbed out of the game: Did work. Full screen tabbed out of the game: Did work.

As for the dalamud version, I did not test this as they disabled the plugin when EW dropped (idk if they've updated it yet at all, nor do I know how to manually install plugins for it).

Both of the versions I tested did not seem to work while the game window was active. I'm not a coder or anything so I can only make assumptions that both programs think the game is active even if no inputs are being done by the user. Not sure if that's intentional or not. They both only seemed to work if I tabbed out of the game onto something else (I tried discord, Brave, Windows Explorer, and Windows 10 Mail program, it all worked so long as I did not have the game window in front). It is 2am for me and my eyes hurt looking at my phone to pass the time.. lmao

Limiana commented 2 years ago

@Vivelric thank you for your contribution, but could you please also download InputDebugger https://github.com/xaviergmail/DiscordNotificationDebug/releases/tag/v1.1 and run it while your game is active to see if windows can recognize absence of activity?

Also, standalone and ACT versions completely share code while ACT is being merely host for it instead of being separate program, so their results always will be identical

aiwaverse commented 2 years ago

I think I have some interesting contribution to share, using the ACT version (Dalamud is still disabled on XIV Launcher as far as I know, there's no news on the server about being enabled again for now).

Entering a dungeon, with a controller connected, if the game is on focus, it goes idle and gives me a warning/kicks me out of it, InputDebugger showed nothing but "System is not idle!". When the game was out of focus, the message was still "System is not idle!", but this time I got no warnings and it worked. However, after a while my controller (DS4) disconnected, and then the InputDebugger message changed, to "System has been idle for N seconds", until I moved/pressed something, if I turn the controller on again, behavior changes to the previously mentioned. I have not tested if this kicks me out or not (my bad really), given the next test, I assume it does not, but unsure.

I restarted the game without the controller and the behavior is the same as when the controller disconnected, InputDebugger starts to say the system has been idle, both focused and unfocused. However, it doesn't seem to kick me out, so despite what InputDebugger was saying, the game wasn't detecting me as idle, again, both with focused and unfocused.

Limiana commented 2 years ago

@aiwaverse so what you have faced is controller driver/windows bug. Windows idle timer and FFXIV idle timer are different things independent from each other. I do use windows idle timer to reset ffxiv's one when ffxiv is active since having some extra key pressed without your request while you're playing is last thing you want to happen. Keypress sent to ffxiv does resets it's idle timer but does not resets windows's timer. Unfortunately, controller driver somehow keeps resetting windows idle timer. It's a known bug and there is no good solution to it. I could rewrite inactivity detection myself, but not only it will take quite a lot of time which I don't have right now, but also I don't have controller and won't be able to account for it while doing such a thing. I could read ffxiv's inactivity timer, but this would make standalone program break with updates, just like Dalamud does and that's what I do not want to happen. Program actually was made to take place of Dalamud's plugin while Dalamud is unavailable.

So the best I can suggest, if you run into that bug, just alt-tab out of the game when you go afk.

VoidVi commented 2 years ago

@Vivelric thank you for your contribution, but could you please also download InputDebugger https://github.com/xaviergmail/DiscordNotificationDebug/releases/tag/v1.1 and run it while your game is active to see if windows can recognize absence of activity?

Also, standalone and ACT versions completely share code while ACT is being merely host for it instead of being separate program, so their results always will be identical

@Eternita-S I could not get the "System was inactive for X seconds" to appear at all. Both alt tabbing from the game and having the game window in focus. Both times the console just kept spitting out "System is not idle".

Also some extra testing, I just woke up and my character is still logged in :D so for me at least, as long as I alt tab off the game the program works.

Limiana commented 2 years ago

@VoidVi seems like in your system some device preventing windows from going idle as well. It would seem that I can't really rely on windows and have to come up with some other means of input detection then.

Also try not to leave your char online for literally days, for sleep you should log out. The chance of such thing is negligible tiny, but in the event if some GM decides to look when and for how long you stayed online and finds out you've been on for a week straight, there could be questions.

patrat46 commented 2 years ago

Sorry for butting in again~ For the issue @VoidVi is having maybe adding in a menu item that is check/not checks and adding an additional OR statement to the if statement to check the bool value would work

Im still nub at coding so forgive my mess: I'm sure the code could be 1/4th as long.

                bool SendClickAlways = false;
                SendClickAlways = bool.Parse(ConfigurationManager.AppSettings.Get("SendClickAlways"));
                Console.WriteLine(": The value of SendClickAlways is " + SendClickAlways);

                MenuItem[] ControlInactive = new MenuItem[2];
                MenuItem Inactive = new MenuItem("Inactive Only");
                MenuItem AlwaysRun = new MenuItem("Alway Run");
                ControlInactive[0] = Inactive;
                ControlInactive[1] = AlwaysRun;

                Inactive.Checked = true;

                if (SendClickAlways)
                {
                    AlwaysRun.Checked = true;
                    Inactive.Checked = false;
                };

                Inactive.Click += new EventHandler(MyMenuClickInactive);
                AlwaysRun.Click += new EventHandler(MyMenuClickInactive);

                void MyMenuClickInactive(Object sender, EventArgs e)
                {
                    if (sender == Inactive)
                    {
                        Inactive.Checked = true;
                        AlwaysRun.Checked = false;

                        SendClickAlways = false;
                    }

                    if (sender == AlwaysRun)
                    {

                        AlwaysRun.Checked = true;
                        Inactive.Checked = false;

                        SendClickAlways = true;
                    }
                };

and notifcation icon

                n = new NotifyIcon
                {
                    Icon = icon,
                    Visible = true,
                    Text = "Anti AFK Kick next key stroke in: " + 1 + (NextKeyPress - Environment.TickCount / 1000 / 60)  + " minutes.",
                    ContextMenu = new ContextMenu(new MenuItem[]
                    {
                        new MenuItem("Anti AFK Kick") { Enabled = false },
                        new MenuItem("-"),
                        new MenuItem("Report issue", delegate { Process.Start(new ProcessStartInfo() { UseShellExecute = true, FileName = "https://github.com/Eternita-S/AntiAfkKick/issues" }); }),
                        new MenuItem("Run While",ControlInactive),
                        new MenuItem("-"),
                        new MenuItem("Exit", delegate { n.Dispose(); Environment.Exit(0); }),
                    })
                };

And in the if statement

if (Native.GetForegroundWindow() != handle || Native.IdleTimeFinder.GetIdleTime() > 60 * 1000 | SendClickAlways)

My thoughts are the checked item in the menu switch true/false for the SendClickAlways bool variable. Adding it to the statement as an or so that it is checked only if the window did not meet the previous conditions... Then if it's true the key will be sent. The user can flip it to only while in active when playing and back when they need to step back for a bit...

I don't understand the notification icon menu so I made a sub menu as I'm having a hard time figuring out how access specific items in the notifications. Do you know of a tut that covers it or document I should have a look at to better understand the menu?

Limiana commented 2 years ago

@patrat46 always clicking is hardly good idea since last thing you want is a program interfering with your input when you're in combat or managing inventory for example.

Just alt-tab out of the game when going afk, or better, use Dalamud plugin which relies on game's own afk timer rather than windows idle one. Dalamud is already updated in stable btw.

At some later time I'll come up with custom idle detection.

Limiana commented 2 years ago

closing this as it seems that everything works correctly aside from this one windows/drivers bug