Prevent Star Citizen from disconnecting while idle Topic is solved

Ask gaming related questions (AHK v1.1 and older)
off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Prevent Star Citizen from disconnecting while idle

Post by off » 28 Mar 2023, 20:50

@DuckingQuack
Sorry, since you two always use V2 earlier, i think i need to use V2 to test and help instead of V1
So the thread will be consistent
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

User avatar
xvz
Posts: 33
Joined: 20 Feb 2023, 15:15

Re: Prevent Star Citizen from disconnecting while idle

Post by xvz » 03 Apr 2023, 20:26

Interesting, okay this worked, it created a window with information about width, height, and position.

Code: Select all

#Requires AutoHotkey v2.0
Shift & q:: ;try to use this hotkey if +q not working at all
{
WinActivate "Star Citizen"
WinMove A_ScreenWidth, A_ScreenHeight,,, "Star Citizen"
WinGetPos &X, &Y,,, "Star Citizen"
MsgBox "Screen Width" A_ScreenWidth "Screen Height" A_ScreenHeight "`n Star Citizen Pos X" X "Star Citizen Pos Y" Y
Return
}
The output:
Screen Width 3440
Screen Height 1440
Star Citizen Pos X 3440
Star Citizen Pos Y 1440

I went back to the other script and replaced +q with Shift & q, and it appears to be working.

Edit- I spoke too soon, one time it pressed F1 in Star Citizen, another time it pressed F1 in my web browser. It also moved my web browser off screen and resized it. The screen also flickers but it's very quick, it's not too distracting. The only thing at this point is making it so only the Star Citizen window if affected and not any others.

Here's the current draft of the script:

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance Force
;SetKeyDelay( ,250)
DetectHiddenWindows 1
if not A_IsAdmin
	Run '*RunAs "' A_ScriptFullPath '"'

; Stay Online

Shift & q:: {
    Static on := false
    if on := !on {
        SetTimer(Fn1, 15000) ; 15 seconds for testing, set to 900000 (15 minutes) when script is ready
        WinRestore "Star Citizen"
        WinMove A_ScreenWidth, A_ScreenHeight, , , "Star Citizen"
        WinMinimize "Star Citizen"
    } Else {
        SetTimer(Fn1, 0)
        WinMaximize "Star Citizen"
    }
}
Fn1() {
    ;ComObject("SAPI.SpVoice").Speak("Sending")
    SoundBeep(250,1000)
    WinActivate "Star Citizen"
    ;SendEvent "{F4}"
    SendInput "{F4}"
    WinMinimize "Star Citizen"
    SoundBeep(500,100)
}

; Auto-Walk

#HotIf WinActive("Star Citizen")
+w:: {
    Loop {
        Send("{w down}")
        Sleep 100
        KeyWait "w" 
        Break
        
    }
} ;

; Auto-Hold Interact

+f:: {
    Loop {
        Send("{f down}")
        Sleep 100
        KeyWait "f"
        Break
    }
}
I also have some difficulty getting Star Citizen to return to display on the screen again. I have to alt tab to it, then press alt enter to force it to display. Actually, testing it again right away, I may not need to press alt enter. The behavior of the window is odd, it may take getting used to it.

Otherwise, I don't know why it occasionally presses F1 on a different window or how to make it only do that with Star Citizen. I just tested that again, it appears to happen if I start to alt tab among multiple windows with the timing of my alt tabs occurring in the middle of the Stay Online lines from the script.

As a side note, I am going to change the F1 key to F4. The F4 key changes perspectives in Star Citizen from 1st person to 3rd person, it should still count as activity to prevent disconnects. I'm updating the draft above with that.

I may need a key combination to make it stop using the Stay Online lines from the script, but without it also stopping the auto-walk and auto-hold interact lines. I would still like to be able to use any of the 3 sections of the script at any time.

This is definitely getting closer, it's progress. :)

Edit 2 - it looks like I actually may have to press alt enter while in the Star Citizen window to make it display again. I've also selected the "Pause Script" pop-up menu option from the task tray for AHK to make it stop cycling the Stay Online section of the script, and it appears the auto-walk and auto-hold interact sections of the script still work.
Last edited by xvz on 03 Apr 2023, 20:52, edited 1 time in total.

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Prevent Star Citizen from disconnecting while idle

Post by off » 03 Apr 2023, 20:48

one time it pressed F1 in Star Citizen, another time it pressed F1 in my web browser.
Seems like your web browser somehow trying to get focused..

It also can be happened if you click on the window too,
maybe use BlockInput in F1 process would help
It also moved my web browser off screen and resized it.
Im not sure why this happen, since

Code: Select all

WinMove A_ScreenWidth, A_ScreenHeight, , , "Star Citizen"
will only executed to a window named Star Citizen.

Edit :
You might also want to add ahk_id and/or ahk_class to define the window instead only window title
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

User avatar
xvz
Posts: 33
Joined: 20 Feb 2023, 15:15

Re: Prevent Star Citizen from disconnecting while idle

Post by xvz » 03 Apr 2023, 20:54

I don't know. :/ It is strange. I could probably explain better but this is all very new to me. I know that when the web browser has been affected by the script it appears to happen while I am pressing alt tab between different windows.

Another quick edit- I do have to press alt enter, two times, once to force Star Citizen to display again, then again to make it change back to the windowed-type of mode (it works with Borderless mode and Windowed mode, so I'm just using Borderless). After I alt tab back into Star Citizen then press alt enter a couple times, I can then keep using the script if I want to unpause it.

I commented out the "SoundBeep" lines, they are very helpful, I may uncomment them again later to test before finalizing the script.

Here is the pattern that I am using manually to interact:
1. In Star Citizen window, I press shift q, that starts the Stay Online section of the script and the Star Citizen window disappears
2. I do tasks in other windows while the script continues
3. When ready to return to Star Citizen, I right-click on AHK in the task tray and select "Pause Script"
4. I right-click on AHK in the task tray and select "Reload Script"
5. I alt tab to Star Citizen, but it is not displaying
6. Then I press alt enter to make it display, at this point it is in full screen mode
7. I press alt enter again to change from full screen mode to windowed/borderless mode
8. I continue doing Star Citizen activities

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Prevent Star Citizen from disconnecting while idle

Post by off » 03 Apr 2023, 21:23

Here is the pattern that I am using manually to interact:
1. In Star Citizen window, I press shift q, that starts the Stay Online section of the script and the Star Citizen window disappears
2. I do tasks in other windows while the script continues
3. When ready to return to Star Citizen, I right-click on AHK in the task tray and select "Pause Script"
4. I right-click on AHK in the task tray and select "Reload Script"
5. I alt tab to Star Citizen, but it is not displaying
6. Then I press alt enter to make it display, at this point it is in full screen mode
7. I press alt enter again to change from full screen mode to windowed/borderless mode
8. I continue doing Star Citizen activities
Alright, now i get this. You need to have Hotkey to pause the script (or reload), and restore the Star Citizen window..
maybe some sort like this?

Code: Select all

+!r:: ; shift + alt + r
WinRestore "Star Citizen"
Reload
Sleep 1000 ; if somehow Reload doesnt reload the script..
Result := MsgBox("The script cannot be reloaded automatically. Terminate script?", "Warning", "YesNo")
If Result = "Yes"
ExitApp
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

User avatar
xvz
Posts: 33
Joined: 20 Feb 2023, 15:15

Re: Prevent Star Citizen from disconnecting while idle

Post by xvz » 03 Apr 2023, 21:35

Very interesting. It would be great to have a key combination for that. If I include "ExitApp" will I still be able to use the auto-walk and auto-hold-interact sections of the script or will that stop everything from working in the script? I will test it and see. I am hoping it will not completely exit out of AHK or completely stop the script.

I just tested it and it didn't work. "Error: Hotkey or hotstring is missing its opening brace." I think that might be another V2 thing.

Now each time it runs (I removed those new lines), it is consistently moving the web browser window. This is very odd, because I restored the script to what was partially working, now it is not working with Star Citizen at all, it is only affecting the web browser. (Correction, I reinserted the previous script from backup notes and it is working with Star Citizen, and still affecting the web browser.)

Here is the current draft:

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance Force
;SetKeyDelay( ,250)
DetectHiddenWindows 1
if not A_IsAdmin
	Run '*RunAs "' A_ScriptFullPath '"'

; Stay Online

Shift & q:: {
    Static on := false
    if on := !on {
        SetTimer(Fn1, 15000) ; 15 seconds for testing, set to 900000 (15 minutes) when script is ready
        WinRestore "Star Citizen"
        WinMove A_ScreenWidth, A_ScreenHeight, , , "Star Citizen"
        WinMinimize "Star Citizen"
    } Else {
        SetTimer(Fn1, 0)
        WinMaximize "Star Citizen"
    }
}
Fn1() {
    ;ComObject("SAPI.SpVoice").Speak("Sending")
    ;SoundBeep(250,1000)
    WinActivate "Star Citizen"
    ;SendEvent "{F4}"
    SendInput "{F4}"
    WinMinimize "Star Citizen"
    ;SoundBeep(500,100)
}

; Auto-Walk

#HotIf WinActive("Star Citizen")
+w:: {
    Loop {
        Send("{w down}")
        Sleep 100
        KeyWait "w" 
        Break
        
    }
} ;

; Auto-Hold Interact

+f:: {
    Loop {
        Send("{f down}")
        Sleep 100
        KeyWait "f"
        Break
    }
}
The strange thing is that was partially working earlier. Somehow it needs to ensure that no other windows are affected, only Star Citizen.
Last edited by xvz on 03 Apr 2023, 22:37, edited 1 time in total.

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Prevent Star Citizen from disconnecting while idle

Post by off » 03 Apr 2023, 22:13

@xvz
Welp my bad always forgetting V2 Syntaxes

Code: Select all

+!r:: ; shift + alt + r
{
WinRestore "Star Citizen"
Reload
Sleep 1000 ; if somehow Reload doesnt reload the script..
Result := MsgBox("The script cannot be reloaded automatically. Terminate script?", "Warning", "YesNo")
If Result = "Yes"
ExitApp
}
after i see your script, you need to use shift + q again to turn off the "stay online" timer, you can just add WinRestore before the WinMaximize i think

And im sure you forget to use Shift+q to toggle off the timer, instead you Pause the script from tray menu
3. When ready to return to Star Citizen, I right-click on AHK in the task tray and select "Pause Script"
4. I right-click on AHK in the task tray and select "Reload Script"
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

User avatar
xvz
Posts: 33
Joined: 20 Feb 2023, 15:15

Re: Prevent Star Citizen from disconnecting while idle

Post by xvz » 03 Apr 2023, 22:39

That's right, I believe the Stay Online part with the shift q is a toggle, which was discussed earlier in this thread. I remember that now. The next chance that I get to test, I will try the reload option again.

User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: Prevent Star Citizen from disconnecting while idle

Post by DuckingQuack » 04 Apr 2023, 06:10

Shift&Q is a toggle… when you press it once, it should start the anti idle section timer and continuously activate star citizen and SEND a keystroke. If you are doing anything to another window, the SEND command is sent to that window. That’s why we included an audible alert so you know to stop clicking or typing for a moment until you hear the second audible.
The second press of Shift&Q will stop the timer for the anti idle and bring star citizen to maximized view on your main monitor.
Pressing Shift&Q has zero impact on the rest of the script aside from the fact that the anti idle minimizes the window and the other hotkeys use the send command also which means they go to the currently active window.

To summarize: your problems are user created.
Best of Luck,
The Duck

User avatar
xvz
Posts: 33
Joined: 20 Feb 2023, 15:15

Re: Prevent Star Citizen from disconnecting while idle

Post by xvz » 04 Apr 2023, 13:45

Of course they're user created, this is all new to me. To say "your problems" is putting it a bit unnecessarily harsh. They're just figuring it out and adjusting to how it works. Thank you for the help. I will be testing out the workflow with those things in mind.

Update:

I tested the workflow. It is not working. I updated the script to reenable the audio and I set the timer from 15 seconds to 15 minutes, I was doing nothing with the keyboard or mouse at the time that the Stay Online section of the script happened, and all it did was highlight the address bar in my web browser. It did nothing in the Star Citizen window. I made sure that I was doing nothing before, during, or after the timing of the intended key presses in the Star Citizen window. One thing did work, however, afterward, when pressing shift q it did return to the Star Citizen window. On another test, setting the timer back to 15 seconds for additional short-term checks, and while doing nothing before, during, or after the timed actions in the script, it once again minimized or moved the web browser window, after which I pressed shift q and it restored the web browser window, again having no affect on the Star Citizen window. I will add that for the past several tests, the only other program that the script has been affecting has been the Edge web browser. The script has had no effect on any other programs. I appreciate the help with this and I do not need to ask for any more help here. I can always ask somewhere else or someone else if this is the best we're going to get here. Thank you.

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Prevent Star Citizen from disconnecting while idle

Post by off » 04 Apr 2023, 20:14

@xvz
Still, i dont get it why your browser getting resized and moved, the script shouldbe and only move and resize a window with title "Star Citizen" or, if your browser somehow have "Star Citizen" title, idk what to do.

Try open the same page the problem happen with same browser, open WindowSpy.ahk and see the browser title.
If the browser really have "Star Citizen" title, use WinSetTitle to change the browser name.

Hope this help.
(for future project, i hope you/i/we can understand, to always check functionality from a simple script. then implement to the main script :D)

Edit:

Fun Fact, i was using WinSetTitle to my browser a week ago, and the title became A.
And it still not changed until now, which in my other google account browser, the title is normal.
(And i have no idea until now, why changing the title became permanent)
image.png
image.png (227.97 KiB) Viewed 1180 times
image.png
image.png (148.06 KiB) Viewed 1180 times
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

User avatar
xvz
Posts: 33
Joined: 20 Feb 2023, 15:15

Re: Prevent Star Citizen from disconnecting while idle  Topic is solved

Post by xvz » 06 Apr 2023, 12:36

Only the Edge browser appears to be affected by the script. I tried to reproduce the response doing the same things with different browsers, like Chrome, and the script had no effect on the other browsers. I can try it again with that window checking tool, although it will probably not have any mismatch of application names for titles.

It could very well be another case of user actions ultimately causing it, so in other words something that I was doing at the time, even if the actions have been the same with different browsers and I have consistently stopped all activity during the audio beeps. I even adjusted the first beep to a slightly longer duration to give me more time to respond and stop doing tasks until the second beep.

Edit- for clarification, any time I do *not* use the Edge browser, the script works okay; while any time that I do use Chrome or any other web browser, the script also works okay.

Given the apparent limitations of this particular combination of AHK current functionality, script, and intended application for use with the AHK script, it is working as close as expected.

I appreciate the help that was received in this thread.

Unless or until someone new finds this thread in future and shares ideas on improving the script, I'm going to go ahead and consider this thread closed. It's not the most ideal script but it is close enough. Thanks everybody.

Here it is:

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance Force
DetectHiddenWindows 1
if not A_IsAdmin
	Run '*RunAs "' A_ScriptFullPath '"'

; Stay Online
; This section will prevent the idle timer from causing a disconnection.
; Press shift q within Star Citizen to activate, press again to deactivate.

Shift & q:: {
    Static on := false
    if on := !on {
        SetTimer(Fn1, 900000)
        WinRestore "Star Citizen"
        WinMove A_ScreenWidth, A_ScreenHeight, , , "Star Citizen"
        WinMinimize "Star Citizen"
    } Else {
        SetTimer(Fn1, 0)
        WinMaximize "Star Citizen"
    }
}
Fn1() {
    SoundBeep(250,2000)
    WinActivate "Star Citizen"
    SendInput "{F4}"
    WinMinimize "Star Citizen"
    SoundBeep(500,100)
}

; Auto-Walk
; This section will make the character or vehicle continuously move forward.
; Press shift w within Star Citizen to activate, tap w to deactivate.

#HotIf WinActive("Star Citizen")
+w:: {
    Loop {
        Send("{w down}")
        Sleep 100
        KeyWait "w" 
        Break
        
    }
} ;

; Auto-Hold Interact
; This section will maintain the interaction mode without having to use the native toggle.
; Press shift f within Star Citizen to activate, tap f to deactivate.

+f:: {
    Loop {
        Send("{f down}")
        Sleep 100
        KeyWait "f"
        Break
    }
}

bstar
Posts: 5
Joined: 15 Jul 2023, 00:03

Re: Prevent Star Citizen from disconnecting while idle

Post by bstar » 16 Jul 2023, 21:38

xvz wrote:
13 Mar 2023, 12:35
I will get around to testing updates to the script when Star Citizen is functional again and I can post an update in here on how it goes. I will say just really quick that before Star Citizen completely broke for everybody, I tried the updated script and my mouse cursor kept moving to the bottom right corner of the screen, I had to reboot the computer, or thought I had to, then realized afterward that I had to disable another program (joytokey) that I use with my joysticks, as I have a control on them that also controls the mouse. I don't know if that was the root cause, but once I went back to a previous version of the AHK script the mouse cursor issue stopped. I'm wondering if maybe something other than sending mouse signals would be the way to go for this but I don't know.
I'm having a similar problem with my SC script. After using Click or MouseMove the cursor moves to the bottom right corner of the screen. I don't have any other input devices except for mouse and keyboard. Got any advice for me?

User avatar
xvz
Posts: 33
Joined: 20 Feb 2023, 15:15

Re: Prevent Star Citizen from disconnecting while idle

Post by xvz » 18 Jul 2023, 15:01

bstar wrote:
16 Jul 2023, 21:38
xvz wrote:
13 Mar 2023, 12:35
I will get around to testing updates to the script when Star Citizen is functional again and I can post an update in here on how it goes. I will say just really quick that before Star Citizen completely broke for everybody, I tried the updated script and my mouse cursor kept moving to the bottom right corner of the screen, I had to reboot the computer, or thought I had to, then realized afterward that I had to disable another program (joytokey) that I use with my joysticks, as I have a control on them that also controls the mouse. I don't know if that was the root cause, but once I went back to a previous version of the AHK script the mouse cursor issue stopped. I'm wondering if maybe something other than sending mouse signals would be the way to go for this but I don't know.
I'm having a similar problem with my SC script. After using Click or MouseMove the cursor moves to the bottom right corner of the screen. I don't have any other input devices except for mouse and keyboard. Got any advice for me?
Using only keyboard and mouse helps by not having any additional peripheral type variables in the mix that could interfere with it.

Since my previous message in here, I've taken a step back with Star Citizen, as the wait continues for it to receive the necessary updates from the CIG devs to effectively improve how it performs, without having to wait for the constant events to conclude. Ever since Persistent Entity Streaming (PES) was added, it has been a pretty persistent trainwreck, albeit with the occasional periods of time of better performance, yet short lived when something else would interfere with it.

Having said that, I don't know what you're using, nor could I offer any useful feedback on it, but the script drafted together that I posted in this thread has "mostly worked". I'm going to probably change the shift-(key) to control-(key) or something that will help prevent accidental activation of triggers. Otherwise, it does appear that SC is not exactly the most cooperative with AutoHotKey, unless either AHK is in need of feature updates, or the script(s) written so far just haven't been good enough. The window behavior of SC is not the best when trying to activate the part of a script that prevents idle disconnect. I haven't put the time into recently to test it out, plan on getting to it eventually, although so far it has been an "insightful" experience piecing my script together. It may be a while before I revisit it.

Post Reply

Return to “Gaming Help (v1)”