Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
1
Indexable
Never
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn   ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

; Set the number of iterations to run the script
NumIterations := 1000

; Loop through each iteration
Loop % NumIterations
{
    ; Randomly choose between typing or clicking
    Random, action, 1, 3

    ; If action is 1 or 2, simulate a random keystroke or mouse click
    if (action = 1 || action = 2) {
        ; Simulate a random keystroke
        Random, key, a, z
        SendInput, %key%

        ; Simulate a random mouse click
        Random, x, 0, A_ScreenWidth
        Random, y, 0, A_ScreenHeight
        Click %x%, %y%
    }

    ; If action is 3, switch to a random Chrome tab
    if (action = 3) {
        ; Get the list of all open Chrome windows and tabs
        WinGet, chromeList, List, ahk_class Chrome_WidgetWin_1

        ; If there are no open Chrome windows, skip this iteration
        if !chromeList
            continue

        ; Choose a random Chrome window and tab to switch to
        Random, chromeWindow, 1, chromeList.MaxIndex()
        WinActivate, ahk_id %chromeList[chromeWindow%]

        ; Wait for the window to activate
        WinWaitActive, ahk_id %chromeList[chromeWindow%]

        ; Choose a random tab to switch to
        SendInput, ^{TAB}
    }

    ; Randomly delay between keystrokes, mouse clicks, and tab switches
    Random, delay, 50, 1000
    Sleep, %delay%
}