Skip to content

Instantly share code, notes, and snippets.

@peterthehan
Last active March 20, 2022 04:43
Show Gist options
  • Save peterthehan/4764b49348c25d81c78e97da84b36a8e to your computer and use it in GitHub Desktop.
Save peterthehan/4764b49348c25d81c78e97da84b36a8e to your computer and use it in GitHub Desktop.
Automate a part of tweet scheduling using the Twitter UI.
#NoEnv
#SingleInstance, Force
; date
month := 5
dayStart := 1
dayEnd := 31
; time
hours := [9, 4]
periods := ["am", "pm"]
minuteStart := 15
minuteEnd := 45
MsgBox, 4096,, Start?
Loop, % dayEnd - dayStart + 1
{
day := A_Index + dayStart - 1
Loop, % hours.Length()
{
; init
Send, n ; hotkey to open the compose tweet modal
MsgBox, 4096,, Continue?
SendTab(6) ; navigate to the schedule button
Send, {Enter}
Sleep, 1000
SendTab(2)
; date
FieldSelect(month)
SendTab(1)
FieldSelect(day)
SendTab(2)
; time
FieldSelect(hours[A_Index])
SendTab(1)
FieldSelect(Random(minuteStart, minuteEnd), 500)
SendTab(1)
if % periods[A_Index] == "am"
{
FieldSelect(1)
}
else
{
FieldSelect(2)
}
SendTab(3)
Send, {Enter}
Sleep, 1000
Send, {Esc}
Sleep, 300
SendTab(5)
Send, {Enter}
MsgBox, 4096,, Next?
}
}
return
FieldSelect(index, delay := 100)
{
index := index - 1
Send, {Enter}
Sleep, %delay%
Send, {Home}
Sleep, %delay%
Send, {Down %index%}
Sleep, %delay%
Send, {Enter}
Sleep, %delay%
}
SendTab(count, delay := 100)
{
Send, {Tab %count%}
Sleep, %delay%
}
Random(min, max)
{
Random, out, min, max
return out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment