Use Controlclick and Controlsend onto Function 7 so that it sends commands to the second monitor #SingleInstance, Force
#MaxThreadsPerHotkey 2

SetTitleMatchMode, 2
SetKeyDelay, -1
CoordMode, Mouse, Screen

Global primaryMonitorWidth := 1920   ; Width of primary monitor
Global secondMonitorWidth := 1920    ; Width of second monitor (might be different if you're using different resolutions)
Global secondMonitorHeight := 1080  ; Height of second monitor
Global screencenterx := -(secondMonitorWidth // 2)   ; Center x of the second monitor to the left
Global screencentery := (secondMonitorHeight // 2)   ; Center y of the second monitor

F5::
Goto AFKCTest

F6::
ToolTip, GeForceNow Anti-AFK Enabled, 0, 0
Goto GeForceNowAntiAFK

F7::
Goto SecondMonitorAndActivate

F8::
Goto ContinuousEKey

AFKCTest:
AFKCToggle := !AFKCToggle
loop
{
    If not AFKCToggle
        break
    Sleep 100
    ControlClick, x%screencenterx% y%screencentery%, GeForce NOW,,,, D Pos
    ControlClick, x%screencenterx% y%screencentery%, GeForce NOW,,,, U Pos
}
return

GeForceNowAntiAFK:
Gui, Submit, NoHide
SetTimer, GeForceNowAntiAFKLoop, 240000
return

GeForceNowAntiAFKLoop()
{
    WinGetPos, X, Y, Width, Height, GeForce NOW
    if ErrorLevel = 0
    {
        WinMove, GeForce NOW,, X, Y + 1
        Sleep, 333
        WinMove, GeForce NOW,, X, Y
    }
}

SecondMonitorAndActivate:
    MouseMove, %screencenterx%, %screencentery%    ; Move mouse to center of the second monitor
    WinActivate, GeForce NOW                       ; Activate GeForce NOW window
    MouseMove, -650, 200   ; Move cursor to coordinates (-650, 200)
    Send, f                ; Press "f"
    Sleep, 300             ; Reduced delay
    MouseMove, -650, 200   ; Move cursor to coordinates (-650, 200)
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, g                ; Type "g"
    Sleep, 50              ; Reduced delay
    Send, {Enter}          ; Press Enter
    Sleep, 100             ; Reduced delay
    MouseMove, -500, 193   ; Move cursor to coordinates (-500, 193)
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, {Enter}          ; Press Enter after left click
    Sleep, 100              ; Reduced delay
    MouseMove, -650, 200   ; Move back to (-650, 200)
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, y                ; Type "y"
    Sleep, 100              ; Reduced delay
    Send, {Enter}          ; Press Enter
    Sleep, 100             ; Reduced delay
    MouseMove, -500, 193   ; Move to (-500, 193) again
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, {Enter}          ; Press Enter after left click
    Sleep, 100              ; Reduced delay
    MouseMove, -650, 200   ; Move back to (-650, 200)
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, o                ; Type "o"
    Sleep, 100              ; Reduced delay
    Send, {Enter}          ; Press Enter
    Sleep, 100             ; Reduced delay
    MouseMove, -500, 193   ; Move to (-500, 193) again
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, {Enter}          ; Press Enter after left click
    Sleep, 100              ; Reduced delay
    MouseMove, -650, 200   ; Move back to (-650, 200)
    Sleep, 50              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, h                ; Type "h"
    Sleep, 100              ; Reduced delay
    Send, {Enter}          ; Press Enter
    Sleep, 100             ; Reduced delay
    MouseMove, -500, 193   ; Move to (-500, 193) again
    Sleep, 50              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, {Enter}          ; Press Enter after left click
    Sleep, 100              ; Reduced delay
    MouseMove, -650, 200   ; Move back to (-650, 200)
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, f                ; Type "f"
    Sleep, 100              ; Reduced delay
    Send, {Enter}          ; Press Enter
    Sleep, 100             ; Reduced delay
    MouseMove, -500, 193   ; Move to (-500, 193) again
    Sleep, 100              ; Reduced delay
    Click, Left            ; Left click
    Sleep, 100             ; Reduced delay
    Send, {Enter}          ; Press Enter after left click
    Send, {Esc}            ; Press Escape to close interface
    MouseMove, 1250, 200   ; Move back to (1250, 200)
    Click, Left            ; Left click
    
    ; Return to primary monitor and activate "ARK: Ascended"
    primaryMonitorCenterX := 1920 // 2
    primaryMonitorCenterY := 1080 // 2 ; assuming the same height
    MouseMove, %primaryMonitorCenterX%, %primaryMonitorCenterY%, 0
    WinActivate, ArkAscended
Return


ContinuousEKey:
    EKeyToggle := !EKeyToggle
    loop
    {
        If not EKeyToggle
            break
        Send, e
        Sleep, 100  ; Adjust the delay between key presses as needed
    }
return