FiveM Inactive Window ControlSend

Ask gaming related questions (AHK v1.1 and older)
pacislavek
Posts: 1
Joined: 18 Mar 2024, 09:59

FiveM Inactive Window ControlSend

18 Mar 2024, 10:06

Hi, so I've been wondering if there's possibility to use the code when window is inactive.

Code: Select all

SendOption1:
        #IfWinActive ahk_class grcWindow
        WinActivate, ahk_exe FiveM_b2802_GTAProcess.exe

        Bursztyniarz = 1
        
        ZbierajBursztyn:
        If Bursztyniarz = 1 
            {

                ; Random , timerval2 , 80 , 120

                ; Send, {e down}
                ControlSend, , {e down}, ahk_exe FiveM_b2802_GTAProcess.exe
                ; ControlSend, , {e down}, ahk_class grcWindow
                ; Sleep, %timerval2
                ; Send, {e up}
                ControlSend, , {e up}, ahk_exe FiveM_b2802_GTAProcess.exe
                ; ControlSend, , {e up}, ahk_class grcWindow

                Random, rand, 500, 900
                SetTimer, ZbierajBursztyn, -%rand%
            }
        else
            {
                SetTimer, ZbierajBursztyn, Off
            }
    Return
Return
The code is very simple, just every 500-900 ms click E.
But it's important for me to make it work for inactive window.

The problem here is that when window is active there's no problem with auto-pressing the keys.
But once it goes inactive scripts doesn't work in the window.

Also would want to mention, that whenever I alt+tab and start dragging around there's a small lag-spike (?).

:!: I've tested it on notepad it works perfectly.
Probably the GTA5 or FiveM processes are somewhat blocking the inputs to inactive windows, is there a way to bypass it?

[Mod action: Since this is v1 code, this topic was moved from AHK v2 help. ]
User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

Re: FiveM Inactive Window ControlSend

18 Mar 2024, 21:29

Welcome to this AutoHotkey forum!

Instead of testing 29 lines, test a one-line script with ControlSend. That tells you whether your window responds to the command. Some windows will not. Others may require an elevated script.

#If directives apply only to hotkeys & hotstrings, not other "running code".

Parentheses are recommended for If statements to ensure that If's "target" in the statement is interpreted as an expression. Syntax and examples are provided in the documentation.

See documentation for ControlSend. The three tests for the control parameter would be a null value, a named control, and ahk_parent.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 148 guests