Skip to content
The Chat Archive
gpt-4o-2024-08-06· OpenAI WildChat-4.8M (AI2)

Edit script for function f7 to function on monitor 1 by making it temporarily active…

  1. User

    Edit script for function f7 to function on monitor 1 by making it temporarily active window first and then at the end return active window to monitor 1 #SingleInstance, Force #MaxThreadsPerHotkey 2 SetTitleMatchMode, 2 ; Allows partial matching of window titles SetKeyDelay, -1

    ; Get the dimensions of the first monitor SysGet, Monitor1, MonitorWorkArea, 1

    ; Simple Clicker F5::Goto AFKCTest

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

    ; New F7 functionality - slower version F7:: Send, f ; Press "f" Sleep, 1000 ; Increased delay for visibility ; Calculate new coordinates relative to the first monitor MouseMove, Monitor1Left + 100, Monitor1Top + 200 ; Move cursor relative to the first monitor Sleep, 1000 ; Increased delay for visibility Click, Left ; Left click Sleep, 1000 ; Increased delay for visibility Send, g ; Type "g" Sleep, 1000 ; Increased delay for visibility Send, {Enter} ; Press Enter Sleep, 1000 ; Increased delay for visibility MouseMove, Monitor1Left + 150, Monitor1Top + 200 ; Move cursor to new coordinates on first monitor Sleep, 1000 ; Increased delay for visibility Click, Left ; Left click Sleep, 1000 ; Increased delay for visibility Send, {Enter} ; Press Enter after left click Sleep, 1000 ; Increased delay for visibility Send, {Esc} ; Press Escape to close interface Return

    AFKCTest: AFKCToggle := !AFKCToggle Loop { If not AFKCToggle break Sleep, 1000 ; Increased delay for visibility ControlClick, x%Monitor1Left% x%Monitor1Top% y+%screencentery%, GeForce NOW,,,, D Pos Sleep, 500 ; Slight pause before releasing the click ControlClick, x%Monitor1Left% x%Monitor1Top% 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 ; Check if the window was found { Random, MoveAmount, 1, 3 ; Randomize movement to avoid detection WinMove, GeForce NOW,, X, Y + MoveAmount Sleep, 1000 ; Increased delay to observe the movement WinMove, GeForce NOW,, X, Y } else { ToolTip, "GeForce NOW window not found", 0, 0 }

  2. Assistant

    Below is the revised script for the F7 function that ensures the target window on Monitor 1 is temporarily the active window, before performing actions, and then returns the original active window to Monitor 1:

    #SingleInstance, Force
    #MaxThreadsPerHotkey 2
    SetTitleMatchMode, 2 ; Allows partial matching of window titles
    SetKeyDelay, -1
    
    ; Get the dimensions of the first monitor
    SysGet, Monitor1, MonitorWorkArea, 1
    
    ; Simple Clicker
    F5::Goto AFKCTest
    
    F6::
    ToolTip, "GeForceNow Anti-AFK Enabled", 0, 0
    Goto GeForceNowAntiAFK
    
    ; New F7 functionality - slower version
    F7::
    ; Save the current active window details
    WinGet, active_id, ID, A
    WinGetTitle, active_title, A
    
    Send, f ; Press "f"
    Sleep, 1000 ; Increased delay for visibility
    
    ; Activate the target window on Monitor 1
    WinActivate, ahk_id %active_id%
    
    ; Calculate new coordinates relative to the first monitor
    MouseMove, Monitor1Left + 100, Monitor1Top + 200 ; Move cursor relative to the first monitor
    Sleep, 1000 ; Increased delay for visibility
    Click, Left ; Left click
    Sleep, 1000 ; Increased delay for visibility
    
    Send, g ; Type "g"
    Sleep, 1000 ; Increased delay for visibility
    Send, {Enter} ; Press Enter
    Sleep, 1000 ; Increased delay for visibility
    
    MouseMove, Monitor1Left + 150, Monitor1Top + 200 ; Move cursor to new coordinates on first monitor
    Sleep, 1000 ; Increased delay for visibility
    Click, Left ; Left click
    Sleep, 1000 ; Increased delay for visibility
    
    Send, {Enter} ; Press Enter after left click
    Sleep, 1000 ; Increased delay for visibility
    Send, {Esc} ; Press Escape to close interface
    
    ; Return to the original active window
    WinActivate, ahk_id %active_id%
    Return
    
    AFKCTest:
    AFKCToggle := !AFKCToggle
    Loop
    {
    If not AFKCToggle
    break
    Sleep, 1000 ; Increased delay for visibility
    ControlClick, x%Monitor1Left% x%Monitor1Top% y+%screencentery%, GeForce NOW,,,, D Pos
    Sleep, 500 ; Slight pause before releasing the click
    ControlClick, x%Monitor1Left% x%Monitor1Top% 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 ; Check if the window was found
    {
    Random, MoveAmount, 1, 3 ; Randomize movement to avoid detection
    WinMove, GeForce NOW,, X, Y + MoveAmount
    Sleep, 1000 ; Increased delay to observe the movement
    WinMove, GeForce NOW,, X, Y
    }
    else
    {
    ToolTip, "GeForce NOW window not found", 0, 0
    }
    }
    

    Explanation:

    • WinGet and WinActivate: Before performing any actions with the F7 key, we save the current active window's ID using WinGet. After the operations, we use WinActivate to bring back the originally active window using the saved ID.
    • MouseMovements and Clicks: Actions regarding mouse movements and clicks are coordinated with respect to Monitor 1.
    • Window Activation: Ensures that the desired actions are performed on the intended window by temporarily activating it.

    Always test this script carefully to ensure that window activations and interactions behave as expected, since automated interactions can sometimes lead to unexpected behaviors depending on the current desktop setup and application states.

  3. User

    For Funciton f7 The first mouse position on window 1 is (1250,200) and the second mouse position on window 2 is (1430,200)

  4. Assistant

    To adjust the F7 function to correctly move the mouse to specified positions on different monitors, the script needs to accommodate moving between two monitors. Below is the revised version of the script segment for F7, based on your specifications:

    #SingleInstance, Force
    #MaxThreadsPerHotkey 2
    SetTitleMatchMode, 2
    SetKeyDelay, -1
    
    ; Get the dimensions of the first monitor
    SysGet, Monitor1, MonitorWorkArea, 1
    ; Get the dimensions of the second monitor
    SysGet, Monitor2, MonitorWorkArea, 2
    
    F5::Goto AFKCTest
    
    F6::
    ToolTip, "GeForceNow Anti-AFK Enabled", 0, 0
    Goto GeForceNowAntiAFK
    
    ; New F7 functionality with specified mouse positions
    F7::
    ; Save the current active window details
    WinGet, active_id, ID, A
    
    Send, f ; Press "f"
    Sleep, 1000 ; Increased delay for visibility
    
    ; Activate the target window on Monitor 1
    WinActivate, ahk_id %active_id%
    
    ; Move cursor to the specified position on the first monitor and click
    MouseMove, 1250, 200
    Sleep, 1000 ; Increased delay for visibility
    Click, Left
    Sleep, 1000 ; Increased delay for visibility
    
    Send, g ; Type "g"
    Sleep, 1000 ; Increased delay for visibility
    Send, {Enter} ; Press Enter
    Sleep, 1000 ; Increased delay for visibility
    
    ; Move cursor to the specified position on the second monitor and click
    MouseMove, Monitor2Left + 1430, Monitor2Top + 200
    Sleep, 1000 ; Increased delay for visibility
    Click, Left
    Sleep, 1000 ; Increased delay for visibility
    
    Send, {Enter} ; Press Enter after left click
    Sleep, 1000 ; Increased delay for visibility
    Send, {Esc} ; Press Escape to close the interface
    
    ; Return to the original active window
    WinActivate, ahk_id %active_id%
    Return
    
    AFKCTest:
    AFKCToggle := !AFKCToggle
    Loop
    {
    If not AFKCToggle
    break
    Sleep, 1000 ; Increased delay for visibility
    ControlClick, x%Monitor1Left% x%Monitor1Top% y+%screencentery%, GeForce NOW,,,, D Pos
    Sleep, 500 ; Slight pause before releasing the click
    ControlClick, x%Monitor1Left% x%Monitor1Top% 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
    {
    Random, MoveAmount, 1, 3
    WinMove, GeForce NOW,, X, Y + MoveAmount
    Sleep, 1000
    WinMove, GeForce NOW,, X, Y
    }
    else
    {
    ToolTip, "GeForce NOW window not found", 0, 0
    }
    }
    

    Explanation:

    • MouseMove on Monitor 1: Moves the mouse to coordinates (1250, 200) on Monitor 1.
    • MouseMove on Monitor 2: Adjusted to use Monitor2Left + 1430 and Monitor2Top + 200 to ensure movement is correctly aligned with the second monitor's coordinate system.
    • WinActivate: Used before and after actions to focus the intended target window and then return to the original active window.

    This script assumes that your monitor setup is correctly configured and that your position calculations in terms of monitor layout are accurate. Always remember to test the script in a controlled environment to ensure expected behavior.