tmp / AHK_PromptAuto.ahk
saliacoel's picture
Update AHK_PromptAuto.ahk
8a5f422 verified
; AutoHotkey v1.1+ script
; F9 = start Sora remix loop
; Esc = abort / exit script immediately
#NoEnv
#SingleInstance Force
#MaxThreadsPerHotkey 1
SetBatchLines, -1
ListLines, Off
; Make coordinates match real screen pixels on DPI-scaled systems
DllCall("SetProcessDPIAware")
CoordMode, Mouse, Screen
SendMode, Input
SetKeyDelay, 50, 50
SetMouseDelay, 50
; =========================
; CONFIG
; =========================
; Pixel position of "remix button"
remixButtonX := 0
remixButtonY := 0
; Pixel position of "picture button"
pictureButtonX := 0
pictureButtonY := 0
; START at CURRENT ID
START_CURRENT_ID := 1
TargetURL := "https://sora.chatgpt.com/g/gen_01kph9ac6sf54a370pd1v039kr"
; =========================
; PROMPTS
; =========================
prompts := []
prompts.Push("a male rogue with a hood and a knife and he looks sneaky") ; 1
prompts.Push("a male warrior with a sword looking mean") ; 2
prompts.Push("a female healer who has a white robe looking healy") ; 3
; =========================
; GLOBAL STATE
; =========================
global gRunning := false
global gClipboardBackup := ""
global gHasClipboardBackup := false
OnExit, __Cleanup
; =========================
; HOTKEYS
; =========================
F9::
if (gRunning)
return
gRunning := true
RunSoraLoop()
gRunning := false
return
; The $ prevents the script's own SendInput {Esc} commands
; from triggering this hotkey.
$Esc::
ExitApp
return
; =========================
; MAIN LOOP
; =========================
RunSoraLoop() {
global remixButtonX, remixButtonY
global pictureButtonX, pictureButtonY
global START_CURRENT_ID
global TargetURL
global prompts
global gClipboardBackup, gHasClipboardBackup
if (remixButtonX = 0 || remixButtonY = 0 || pictureButtonX = 0 || pictureButtonY = 0) {
MsgBox, 16, Missing Coordinates, Edit the button pixel positions before running.
return
}
totalPrompts := prompts.Length()
if (START_CURRENT_ID < 1 || START_CURRENT_ID > totalPrompts) {
MsgBox, 16, Invalid CURRENT ID, START_CURRENT_ID is outside the prompt list.
return
}
; Backup clipboard
gClipboardBackup := ClipboardAll
gHasClipboardBackup := true
currentID := START_CURRENT_ID
while (currentID <= totalPrompts) {
currentPrompt := prompts[currentID]
; wait 1 sec
Sleep, 1000
; CONTROL+L
SendInput, ^l
; type URL
Sleep, 200
SendInput, %TargetURL%
; press ENTER
SendInput, {Enter}
; wait 3 sec
Sleep, 3000
; press E
SendInput, e
; wait 1 sec
Sleep, 1000
; control+a
SendInput, ^a
; wait 1 sec
Sleep, 1000
; delete
SendInput, {Delete}
; wait 1 sec
Sleep, 1000
; copy CURRENT ID prompt into clipboard
Clipboard :=
Clipboard := currentPrompt
ClipWait, 2
; wait 1 sec
Sleep, 1000
; control+V
SendInput, ^v
; wait 1 sec
Sleep, 1000
; click remix button
Click, %remixButtonX%, %remixButtonY%
; wait 60 sec
Sleep, 60000
; press ESC
SendInput, {Esc}
; wait 2 sec
Sleep, 2000
; press top of page button / Pos1 / Home
SendInput, {Home}
; wait 1 sec
Sleep, 1000
; click picture button
Click, %pictureButtonX%, %pictureButtonY%
; wait 1 sec
Sleep, 1000
; press D
SendInput, d
Sleep, 2000
; Right Arrow
SendInput, {Right}
Sleep, 2000
; press D
SendInput, d
Sleep, 1000
; Right Arrow
SendInput, {Right}
Sleep, 2000
; press D
SendInput, d
Sleep, 1000
; Right Arrow
SendInput, {Right}
Sleep, 2000
; press D
SendInput, d
Sleep, 1000
; press ESC
SendInput, {Esc}
Sleep, 1000
; CURRENT ID + 1
currentID++
}
; Restore clipboard after successful completion
if (gHasClipboardBackup) {
Clipboard := gClipboardBackup
gClipboardBackup :=
gHasClipboardBackup := false
}
MsgBox, 64, Finished, Finished all prompts.
}
; =========================
; CLEANUP
; =========================
__Cleanup:
global gClipboardBackup, gHasClipboardBackup
if (gHasClipboardBackup) {
Clipboard := gClipboardBackup
gClipboardBackup :=
gHasClipboardBackup := false
}
ExitApp
return