Skip to content

Instantly share code, notes, and snippets.

@ssgtcookie
Last active October 20, 2018 14:08
Show Gist options
  • Save ssgtcookie/b8b6611cfe498e9ba06a06ee69ef9102 to your computer and use it in GitHub Desktop.
Save ssgtcookie/b8b6611cfe498e9ba06a06ee69ef9102 to your computer and use it in GitHub Desktop.
Can be used to reset roles assigned to you. Works with the discord.exe client.
^+\::
DiscordServer = https://discord.gg/z8qBSAP
CountToGoDownWhenServerIsRejoined = 7
; Get current mouse position and activate discord
MouseGetPos, xcur, ycur
WinActivate, ahk_exe Discord.exe
; Leave server
MouseMove, 150, 50, 0
MouseClick, left
MouseMove, 0, 210, 2, R
MouseClick, left
send {Enter}
; Join server
send, ^+n
sleep, 400
PixelSearch, Px, Py, 0, 0, 1200, 700, 0x3CA374, 0, Fast RGB
if ErrorLevel
MsgBox, That color was not found in the specified region.
else
MouseMove, %Px%, %Py%, 0
MouseClick, left
MouseMove, %xcur%, %ycur%, 0 ; Return mouse to starting position
send %DiscordServer%
send, {Enter}
sleep, 1000
; Go to general-but-legal
Loop, %CountToGoDownWhenServerIsRejoined%
{
send {LAlt down}{Down}{LAlt up}
}
^+\::
Loop{
PixelSearch, Ax, Ay, 750, 990, 751, 991, 0x3E4147, 0, Fast RGB
if !ErrorLevel
RejoinServer()
sleep, 1000
}
RejoinServer(){
DiscordServer = https://discord.gg/z8qBSAP
CountToGoDownWhenServerIsRejoined = 8
; Get current mouse position and activate discord
MouseGetPos, xcur, ycur
WinActivate, ahk_exe Discord.exe
; Leave server
MouseMove, 150, 50, 0
MouseClick, left
MouseMove, 0, 210, 2, R
MouseClick, left
send {Enter}
; Join server
send, ^+n
sleep, 400
PixelSearch, Px, Py, 0, 0, 1200, 700, 0x3CA374, 0, Fast RGB
if ErrorLevel
MsgBox, That color was not found in the specified region.
else
MouseMove, %Px%, %Py%, 0
MouseClick, left
MouseMove, %xcur%, %ycur%, 0 ; Return mouse to starting position
send %DiscordServer%
send, {Enter}
sleep, 1000
; Go to general-but-legal
Loop, %CountToGoDownWhenServerIsRejoined%
{
send {LAlt down}{Down}{LAlt up}
}
}
@ssgtcookie
Copy link
Author

auto-rejoin-script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment