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

Finish the script for the F7. The script is to move the mouse from main monitor to the…

  1. User

    Finish the script for the F7. The script is to move the mouse from main monitor to the monitor to the left and click twice on screen of monitor 2#SingleInstance, Force #MaxThreadsPerHotkey 2

    SetTitleMatchMode, 2 ; Allows partial matching of window titles SetKeyDelay, -1

    Global screencenterx := (A_ScreenWidth // 2) Global screencentery := (A_ScreenHeight // 2)

    ; Simple Clicker F5:: Goto AFKCTest

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

    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 ; Checks if the window was found { WinMove, GeForce NOW,, X, Y + 1 Sleep, 333 WinMove, GeForce NOW,, X, Y } }

    metalfarm:

  2. Assistant

    Certainly, you can extend the script to move the mouse from the main monitor to the monitor on the left and click twice. Below is a continuation of the script with an addition for the F7 hotkey to achieve this:

    F7::
        ; Get the current mouse position
        MouseGetPos, currentX, currentY
    
        ; Calculate the position for the monitor to the left
        newX := currentX - A_ScreenWidth  ; Move the X position left one screen width
        newY := currentY  ; Y position remains the same
    
        ; Bound newX to prevent moving off the intended screen
        if (newX < 0)
            newX := 0
    
        ; Move the mouse to the new position
        MouseMove, newX, newY, 0
    
        ; Double click
        Click
        Click
    
        ; Optionally, move back to the original position
        ; Uncomment the lines below to enable it
        ; Sleep 500
        ; MouseMove, currentX, currentY, 0
    
    return
    

    Explanation:

    • Monitor Layout: This script assumes a dual-monitor setup where the second monitor is to the left of the primary monitor.
    • Mouse Positioning: When you press F7, the script calculates the new mouse position by subtracting the width of the primary monitor from the current X coordinate.
    • Clicking: It performs a double-click at the new mouse position.
    • Commented Code: There is an option to move the mouse back to its original position by uncommenting the last section. This might be necessary if you want the mouse to return automatically after the double-click.

    You might need to adjust the calculation for newX if screens are aligned differently or a different setup is used. Make sure the screen configuration matches this logic (e.g., the second monitor is directly left of the main one).

  3. User

    write the complete script

  4. Assistant

    Here is the complete script incorporating your existing code and adding the functionality to move the mouse to the left monitor and double-click when pressing F7.

    #SingleInstance, Force
    #MaxThreadsPerHotkey 2
    
    SetTitleMatchMode, 2  ; Allows partial matching of window titles
    SetKeyDelay, -1
    
    Global screencenterx := (A_ScreenWidth // 2)
    Global screencentery := (A_ScreenHeight // 2)
    
    ; Simple Clicker
    F5::
    Goto AFKCTest
    
    F6::
    ToolTip, GeForceNow Anti-AFK Enabled, 0, 0
    Goto GeForceNowAntiAFK
    
    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  ; Checks if the window was found
        {
            WinMove, GeForce NOW,, X, Y + 1
            Sleep, 333
            WinMove, GeForce NOW,, X, Y
        }
    }
    
    F7::
        ; Get the current mouse position
        MouseGetPos, currentX, currentY
    
        ; Calculate the position for the monitor to the left
        newX := currentX - A_ScreenWidth  ; Move the X position left one screen width
        newY := currentY  ; Y position remains the same
    
        ; Ensure newX does not go below zero
        if (newX < 0)
            newX := 0
    
        ; Move the mouse to the new position
        MouseMove, newX, newY, 0
    
        ; Double click
        Click
        Click
    
        ; Optionally, move back to the original position
        ; Sleep 500
        ; MouseMove, currentX, currentY, 0
    
    return
    

    How it works:

    • Setup for F5 and F6: This portion of the script defines functionality for testing and enabling an anti-AFK system for "GeForce NOW".
    • Monitor Movement with F7: When F7 is pressed, the script moves the mouse to the left monitor by adjusting the X coordinate based on the width of the primary monitor and performs a double-click.
    • Optional Return: There's an optional section to return the mouse pointer to its original position. Uncomment if the behavior is desired.
    • Boundary Check: Ensures that the mouse does not move to an invalid screen position if there is a reconfiguration of monitors.

    Please ensure your monitors are positioned in such a way that this logic corresponds to your physical setup. Adjustments may be required depending on monitor arrangement.

  5. User

    remove comments

  6. Assistant

    Certainly! Here's the script without comments:

    #SingleInstance, Force
    #MaxThreadsPerHotkey 2
    
    SetTitleMatchMode, 2
    SetKeyDelay, -1
    
    Global screencenterx := (A_ScreenWidth // 2)
    Global screencentery := (A_ScreenHeight // 2)
    
    F5::
    Goto AFKCTest
    
    F6::
    ToolTip, GeForceNow Anti-AFK Enabled, 0, 0
    Goto GeForceNowAntiAFK
    
    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
        }
    }
    
    F7::
        MouseGetPos, currentX, currentY
        newX := currentX - A_ScreenWidth
        newY := currentY
        if (newX < 0)
            newX := 0
        MouseMove, newX, newY, 0
        Click
        Click
    return
    

    This script now simply contains the logic and commands to perform the described actions without any comments explaining each step.

  7. User

    Change F7 so that it moves the mouse from monitor 2 to monitor 1

  8. Assistant

    To change the behavior so that pressing F7 will move the mouse from monitor 2 to monitor 1, you need to adjust the logic. Assuming that monitor 2 is on the left of monitor 1, here's how you can modify the F7 hotkey:

    #SingleInstance, Force
    #MaxThreadsPerHotkey 2
    
    SetTitleMatchMode, 2
    SetKeyDelay, -1
    
    Global screencenterx := (A_ScreenWidth // 2)
    Global screencentery := (A_ScreenHeight // 2)
    
    F5::
    Goto AFKCTest
    
    F6::
    ToolTip, GeForceNow Anti-AFK Enabled, 0, 0
    Goto GeForceNowAntiAFK
    
    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
        }
    }
    
    F7::
        MouseGetPos, currentX, currentY
        newX := currentX + A_ScreenWidth
        newY := currentY
        if (newX > A_ScreenWidth)
            newX := A_ScreenWidth - 1
        MouseMove, newX, newY, 0
        Click
        Click
    return
    

    Key Changes:

    • Monitor Movement: The newX calculation has been adjusted by adding A_ScreenWidth to move the cursor from the left monitor to the right (monitor 2 to monitor 1) assuming the primary monitor is to the right of the secondary monitor.
    • Boundary Check: Ensures that the calculated newX does not exceed the width of monitor 1. Adjust this logic if your monitors are configured differently.