saliacoel commited on
Commit
8a5f422
·
verified ·
1 Parent(s): e456ece

Update AHK_PromptAuto.ahk

Browse files
Files changed (1) hide show
  1. AHK_PromptAuto.ahk +244 -168
AHK_PromptAuto.ahk CHANGED
@@ -1,168 +1,244 @@
1
- #Requires AutoHotkey v2.0
2
- #SingleInstance Force
3
-
4
- ; =========================
5
- ; INPUT VARIABLES
6
- ; =========================
7
-
8
- ; Pixel position of "remix button"
9
- remixButtonX := 0
10
- remixButtonY := 0
11
-
12
- ; Pixel position of "picture button"
13
- pictureButtonX := 0
14
- pictureButtonY := 0
15
-
16
- ; START at CURRENT ID
17
- START_CURRENT_ID := 1
18
-
19
- ; =========================
20
- ; PROMPTS
21
- ; =========================
22
-
23
- prompts := [
24
- "a male rogue with a hood and a knife and he looks sneaky",
25
- "a male warrior with a sword looking mean",
26
- "a female healer who has a white robe looking healy"
27
- ]
28
-
29
- ; =========================
30
- ; SAFETY CHECK
31
- ; =========================
32
-
33
- if (remixButtonX = 0 || remixButtonY = 0 || pictureButtonX = 0 || pictureButtonY = 0) {
34
- MsgBox "Edit the button pixel positions at the top of the script before running."
35
- ExitApp
36
- }
37
-
38
- if (START_CURRENT_ID < 1 || START_CURRENT_ID > prompts.Length) {
39
- MsgBox "START_CURRENT_ID is outside the prompt list."
40
- ExitApp
41
- }
42
-
43
- ; Use screen pixel coordinates for clicks
44
- CoordMode "Mouse", "Screen"
45
- SendMode "Input"
46
- SetKeyDelay 50, 50
47
- SetMouseDelay 50
48
-
49
- ; Save current clipboard so it can be restored later
50
- oldClipboard := A_Clipboard
51
-
52
- currentID := START_CURRENT_ID
53
-
54
- ; =========================
55
- ; MAIN LOOP
56
- ; Runs until CURRENT ID runs out of prompts
57
- ; =========================
58
-
59
- while (currentID <= prompts.Length) {
60
-
61
- currentPrompt := prompts[currentID]
62
-
63
- ; wait 1 sec
64
- Sleep 1000
65
-
66
- ; CONTROL+L
67
- Send "^l"
68
-
69
- ; type URL
70
- Sleep 200
71
- SendText "https://sora.chatgpt.com/g/gen_01kph9ac6sf54a370pd1v039kr"
72
-
73
- ; press ENTER
74
- Send "{Enter}"
75
-
76
- ; wait 3 sec
77
- Sleep 3000
78
-
79
- ; press E
80
- Send "e"
81
-
82
- ; wait 1 sec
83
- Sleep 1000
84
-
85
- ; control+a
86
- Send "^a"
87
-
88
- ; wait 1 sec
89
- Sleep 1000
90
-
91
- ; delete
92
- Send "{Delete}"
93
-
94
- ; wait 1 sec
95
- Sleep 1000
96
-
97
- ; COPY the current prompt into clipboard
98
- A_Clipboard := ""
99
- A_Clipboard := currentPrompt
100
- ClipWait 2
101
-
102
- ; wait 1 sec
103
- Sleep 1000
104
-
105
- ; control+V
106
- Send "^v"
107
-
108
- ; wait 1 sec
109
- Sleep 1000
110
-
111
- ; click remix button
112
- Click remixButtonX, remixButtonY
113
-
114
- ; wait 60 sec
115
- Sleep 60000
116
-
117
- ; press ESC
118
- Send "{Esc}"
119
-
120
- ; wait 2 sec
121
- Sleep 2000
122
-
123
- ; press top of page button, called Pos1/Home
124
- Send "{Home}"
125
-
126
- ; wait 1 sec
127
- Sleep 1000
128
-
129
- ; click picture button
130
- Click pictureButtonX, pictureButtonY
131
-
132
- ; wait 1 sec
133
- Sleep 1000
134
-
135
- ; Download/select sequence
136
- Send "d"
137
- Sleep 2000
138
-
139
- Send "{Right}"
140
- Sleep 2000
141
-
142
- Send "d"
143
- Sleep 1000
144
-
145
- Send "{Right}"
146
- Sleep 2000
147
-
148
- Send "d"
149
- Sleep 1000
150
-
151
- Send "{Right}"
152
- Sleep 2000
153
-
154
- Send "d"
155
- Sleep 1000
156
-
157
- Send "{Esc}"
158
- Sleep 1000
159
-
160
- ; CURRENT ID + 1
161
- currentID += 1
162
- }
163
-
164
- ; Restore previous clipboard
165
- A_Clipboard := oldClipboard
166
-
167
- MsgBox "Finished. Ran all prompts from CURRENT ID " START_CURRENT_ID " to " prompts.Length "."
168
- ExitApp
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ; AutoHotkey v1.1+ script
2
+ ; F9 = start Sora remix loop
3
+ ; Esc = abort / exit script immediately
4
+
5
+ #NoEnv
6
+ #SingleInstance Force
7
+ #MaxThreadsPerHotkey 1
8
+ SetBatchLines, -1
9
+ ListLines, Off
10
+
11
+ ; Make coordinates match real screen pixels on DPI-scaled systems
12
+ DllCall("SetProcessDPIAware")
13
+
14
+ CoordMode, Mouse, Screen
15
+ SendMode, Input
16
+ SetKeyDelay, 50, 50
17
+ SetMouseDelay, 50
18
+
19
+ ; =========================
20
+ ; CONFIG
21
+ ; =========================
22
+
23
+ ; Pixel position of "remix button"
24
+ remixButtonX := 0
25
+ remixButtonY := 0
26
+
27
+ ; Pixel position of "picture button"
28
+ pictureButtonX := 0
29
+ pictureButtonY := 0
30
+
31
+ ; START at CURRENT ID
32
+ START_CURRENT_ID := 1
33
+
34
+ TargetURL := "https://sora.chatgpt.com/g/gen_01kph9ac6sf54a370pd1v039kr"
35
+
36
+ ; =========================
37
+ ; PROMPTS
38
+ ; =========================
39
+
40
+ prompts := []
41
+
42
+ prompts.Push("a male rogue with a hood and a knife and he looks sneaky") ; 1
43
+ prompts.Push("a male warrior with a sword looking mean") ; 2
44
+ prompts.Push("a female healer who has a white robe looking healy") ; 3
45
+
46
+ ; =========================
47
+ ; GLOBAL STATE
48
+ ; =========================
49
+
50
+ global gRunning := false
51
+ global gClipboardBackup := ""
52
+ global gHasClipboardBackup := false
53
+
54
+ OnExit, __Cleanup
55
+
56
+ ; =========================
57
+ ; HOTKEYS
58
+ ; =========================
59
+
60
+ F9::
61
+ if (gRunning)
62
+ return
63
+
64
+ gRunning := true
65
+ RunSoraLoop()
66
+ gRunning := false
67
+ return
68
+
69
+
70
+ ; The $ prevents the script's own SendInput {Esc} commands
71
+ ; from triggering this hotkey.
72
+ $Esc::
73
+ ExitApp
74
+ return
75
+
76
+
77
+ ; =========================
78
+ ; MAIN LOOP
79
+ ; =========================
80
+
81
+ RunSoraLoop() {
82
+ global remixButtonX, remixButtonY
83
+ global pictureButtonX, pictureButtonY
84
+ global START_CURRENT_ID
85
+ global TargetURL
86
+ global prompts
87
+ global gClipboardBackup, gHasClipboardBackup
88
+
89
+ if (remixButtonX = 0 || remixButtonY = 0 || pictureButtonX = 0 || pictureButtonY = 0) {
90
+ MsgBox, 16, Missing Coordinates, Edit the button pixel positions before running.
91
+ return
92
+ }
93
+
94
+ totalPrompts := prompts.Length()
95
+
96
+ if (START_CURRENT_ID < 1 || START_CURRENT_ID > totalPrompts) {
97
+ MsgBox, 16, Invalid CURRENT ID, START_CURRENT_ID is outside the prompt list.
98
+ return
99
+ }
100
+
101
+ ; Backup clipboard
102
+ gClipboardBackup := ClipboardAll
103
+ gHasClipboardBackup := true
104
+
105
+ currentID := START_CURRENT_ID
106
+
107
+ while (currentID <= totalPrompts) {
108
+
109
+ currentPrompt := prompts[currentID]
110
+
111
+ ; wait 1 sec
112
+ Sleep, 1000
113
+
114
+ ; CONTROL+L
115
+ SendInput, ^l
116
+
117
+ ; type URL
118
+ Sleep, 200
119
+ SendInput, %TargetURL%
120
+
121
+ ; press ENTER
122
+ SendInput, {Enter}
123
+
124
+ ; wait 3 sec
125
+ Sleep, 3000
126
+
127
+ ; press E
128
+ SendInput, e
129
+
130
+ ; wait 1 sec
131
+ Sleep, 1000
132
+
133
+ ; control+a
134
+ SendInput, ^a
135
+
136
+ ; wait 1 sec
137
+ Sleep, 1000
138
+
139
+ ; delete
140
+ SendInput, {Delete}
141
+
142
+ ; wait 1 sec
143
+ Sleep, 1000
144
+
145
+ ; copy CURRENT ID prompt into clipboard
146
+ Clipboard :=
147
+ Clipboard := currentPrompt
148
+ ClipWait, 2
149
+
150
+ ; wait 1 sec
151
+ Sleep, 1000
152
+
153
+ ; control+V
154
+ SendInput, ^v
155
+
156
+ ; wait 1 sec
157
+ Sleep, 1000
158
+
159
+ ; click remix button
160
+ Click, %remixButtonX%, %remixButtonY%
161
+
162
+ ; wait 60 sec
163
+ Sleep, 60000
164
+
165
+ ; press ESC
166
+ SendInput, {Esc}
167
+
168
+ ; wait 2 sec
169
+ Sleep, 2000
170
+
171
+ ; press top of page button / Pos1 / Home
172
+ SendInput, {Home}
173
+
174
+ ; wait 1 sec
175
+ Sleep, 1000
176
+
177
+ ; click picture button
178
+ Click, %pictureButtonX%, %pictureButtonY%
179
+
180
+ ; wait 1 sec
181
+ Sleep, 1000
182
+
183
+ ; press D
184
+ SendInput, d
185
+ Sleep, 2000
186
+
187
+ ; Right Arrow
188
+ SendInput, {Right}
189
+ Sleep, 2000
190
+
191
+ ; press D
192
+ SendInput, d
193
+ Sleep, 1000
194
+
195
+ ; Right Arrow
196
+ SendInput, {Right}
197
+ Sleep, 2000
198
+
199
+ ; press D
200
+ SendInput, d
201
+ Sleep, 1000
202
+
203
+ ; Right Arrow
204
+ SendInput, {Right}
205
+ Sleep, 2000
206
+
207
+ ; press D
208
+ SendInput, d
209
+ Sleep, 1000
210
+
211
+ ; press ESC
212
+ SendInput, {Esc}
213
+ Sleep, 1000
214
+
215
+ ; CURRENT ID + 1
216
+ currentID++
217
+ }
218
+
219
+ ; Restore clipboard after successful completion
220
+ if (gHasClipboardBackup) {
221
+ Clipboard := gClipboardBackup
222
+ gClipboardBackup :=
223
+ gHasClipboardBackup := false
224
+ }
225
+
226
+ MsgBox, 64, Finished, Finished all prompts.
227
+ }
228
+
229
+
230
+ ; =========================
231
+ ; CLEANUP
232
+ ; =========================
233
+
234
+ __Cleanup:
235
+ global gClipboardBackup, gHasClipboardBackup
236
+
237
+ if (gHasClipboardBackup) {
238
+ Clipboard := gClipboardBackup
239
+ gClipboardBackup :=
240
+ gHasClipboardBackup := false
241
+ }
242
+
243
+ ExitApp
244
+ return