Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force
- #Persistent
- ; constants
- discordTitleMatchingString := "ahk_exe Discord.exe"
- rdpTitleMatchingString := "ahk_class TscShellContainerClass"
- scriptReloadedId := "reloaded"
- isFirstRunAfterReload := ((A_Args.Length() > 0) And (A_Args[1]=scriptReloadedId))
- SetTimer, ScrollDiscord, 500, 2
- SetTimer, SuspendOnRDPMaximized, 1000, 1
- return
- ScrollDiscord:
- WinGet, DiscordState, MinMax, %discordTitleMatchingString%
- ; if Discord windows is minimized, return
- If (DiscordState = -1)
- return
- ; if mouse is over the Discord window, return
- if MouseIsOver(discordTitleMatchingString)
- return
- ; if Discord window is active, return
- if WinActive(discordTitleMatchingString)
- return
- ControlFocus,, %discordTitleMatchingString%
- Gosub, SendPageDown
- return
- SuspendOnRDPMaximized:
- If WinActive(rdpTitleMatchingString) {
- if isFirstRunAfterReload {
- isFirstRunAfterReload := false
- WinWaitNotActive, %rdpTitleMatchingString%
- return
- }
- WinGet, maxOrMin, MinMax, %rdpTitleMatchingString%
- if (maxOrMin = 0) {
- WinGetPos, PosX, PosY, WinWidth, WinHeight, %rdpTitleMatchingString%
- if (PosY = 0) { ; it is fully maximized
- Gosub, RestartScript
- }
- }
- }
- return
- SendPageDown:
- PostMessage, 0x100, 0x22,,, %discordTitleMatchingString% ; 0x100 = WM_KEYDOWN, 0x22 = page down
- Sleep, 50
- PostMessage, 0x101, 0x22,,, %discordTitleMatchingString% ; 0x100 = WM_KEYUP, 0x22 = page down
- return
- RestartScript:
- if A_IsCompiled
- Run "%A_ScriptFullPath%" /restart "%scriptReloadedId%"
- else
- Run "%A_AhkPath%" /restart "%A_ScriptFullPath%" "%scriptReloadedId%"
- return
- MouseIsOver(vWinTitle:="", vWinText:="", vExcludeTitle:="", vExcludeText:="")
- {
- MouseGetPos,,, hWnd
- return WinExist(vWinTitle (vWinTitle=""?"":" ") "ahk_id " hWnd, vWinText, vExcludeTitle, vExcludeText)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement