Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #WinActivateForce
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #SingleInstance, Force
- SetBatchLines, -1
- ;Install all images inside the exe/ahk file
- FileInstall, Dark_ChatOptions_A.png, %A_ScriptFullPath%:Dark_ChatOptions_A.png
- FileInstall, Dark_ChatOptions_B.png, %A_ScriptFullPath%:Dark_ChatOptions_B.png
- FileInstall, Light_ChatOptions_A.png, %A_ScriptFullPath%:Light_ChatOptions_A.png
- FileInstall, Light_ChatOptions_B.png, %A_ScriptFullPath%:Light_ChatOptions_B.png
- FileInstall, Dark_Discord_Logo.png, %A_ScriptFullPath%:Dark_Discord_Logo.png
- FileInstall, Dark_Discord_LogoB.png, %A_ScriptFullPath%:Dark_Discord_LogoB.png
- FileInstall, Dark_Discord_LogoC.png, %A_ScriptFullPath%:Dark_Discord_LogoC.png
- FileInstall, Loading_Messages.png, %A_ScriptFullPath%:Loading_Messages.png
- global Process_id := ""
- global CurrentTask := "Starting Up"
- ;Set Process_id globals and maximize the window
- f1::
- System_CheckWindowsList()
- return
- ;Find the discord logo!
- f2::
- System_FullScreen_Scan("Dark_Discord_Logo")
- System_FullScreen_Scan("Dark_Discord_LogoB")
- System_FullScreen_Scan("Dark_Discord_LogoC")
- return
- ;Look for some options
- f3::
- Random, v, 0, 100
- MouseMove, (A_ScreenWidth/2), ((A_ScreenHeight/2)+v), 0
- Sleep, 50
- System_FullScreen_Scan("Light_ChatOptions_A")
- System_FullScreen_Scan("Dark_ChatOptions_A")
- System_FullScreen_Scan("Light_ChatOptions_B")
- System_FullScreen_Scan("Dark_ChatOptions_B")
- return
- ;Start recursive check
- f4::
- SetTimer, FidelityScanner, 100
- return
- ^!p::
- Send {PrintScreen}
- Run MSPaint
- WinWait, Untitled - Paint
- Sleep, 100
- Send, {CTRLDOWN}v{CTRLUP}
- return
- return
- FidelityScanner:
- ImageFile = %A_ScriptFullPath%:Dark_Discord_Logo.png
- ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_Logo.png
- ImageSearch, OutputVarXX, OutputVarYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoB.png
- ImageSearch, OutputVarXXX, OutputVarYYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoC.png
- if (OutputVarX OR OutputVarXX OR OutputVarXXX)
- {
- ToolTip, Fidelity: Positive `n%CurrentTask%
- WinGetTitle WinTitle, ahk_id %Process_id%
- WinGetPos, X, Y, Width, Height, %WinTitle%,,,
- ;MsgBox, X: %X% Y: %Y% Width: %Width% Height: %Height%
- ;MsgBox, . (%(%-%Width%) . (%A_ScreenHeight%-%Height%)
- if ((A_ScreenWidth-Width) > 100) OR ((A_ScreenHeight-Height) > 100)
- {
- ;MsgBox, Out of size range!
- WinGetTitle wt, ahk_id %Process_id%
- WinActivate, %wt%
- WinMaximize, %wt%
- }
- }
- else
- {
- Loop 6
- {
- ;break
- CurrentTask := "Rescuing Target... " (6-A_Index)
- ToolTip, Fidelity: Negative `n%CurrentTask%
- Sleep, 1000
- ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_Logo.png
- ImageSearch, OutputVarXX, OutputVarYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoB.png
- ImageSearch, OutputVarXXX, OutputVarYYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoC.png
- if (OutputVarX OR OutputVarXX OR OutputVarXXX)
- {
- CurrentTask := "Waiting..."
- return
- }
- }
- CurrentTask := "Waiting..."
- System_CheckWindowsList()
- ToolTip, Fidelity: Negative `n%CurrentTask%
- Sleep, 1000
- }
- return
- ;This finds the path of the process executable
- GetModuleExeName(p_id) {
- for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where ProcessId=" p_id)
- return process.ExecutablePath
- }
- System_CheckWindowsList()
- {
- ;This is the 'soft' check for discord simply cycling the windows that are open
- DetectHiddenWindows, Off
- WinGet windows, List
- Loop %windows%
- {
- Process_id := windows%A_Index%
- WinGetTitle wt, ahk_id %Process_id%
- WinGet, PName, ProcessName, %wt%,,,
- r .= wt . id . PName . "`n"
- if PName = Discord.exe
- {
- ;MsgBox, Got it!
- WinGetTitle wt, ahk_id %Process_id%
- WinActivate, %wt%
- WinMaximize, %wt%
- return
- }
- }
- ;This is the 'hard' check for discord that checks for 'hidden' (windows does this behaviour for tray icon minimizing and other stuff)
- ;Once it finds the first hidden EXE it finds the file path and executes it. Discord only allows one instance to run so it's a trick to open it up from the tray
- DetectHiddenWindows, On
- WinGet windows, List
- Loop %windows%
- {
- Process_id := windows%A_Index%
- WinGetTitle wt, ahk_id %Process_id%
- WinGet, PName, ProcessName, %wt%,,,
- ;r .= wt . id . PName . "`n"
- if PName = Discord.exe
- {
- WinGet, PID, PID, ahk_id %Process_id%
- FullEXEPath := GetModuleExeName(PID)
- ;Remove the exe from the path name
- FullEXEPath := StrReplace(FullEXEPath, PName, "")
- ;MsgBox, Found it! %wt% `n %PName% `n %FullEXEPath% %PID%
- Run, %PName%, %FullEXEPath%,
- WinMaximize, %wt%
- ;WinWait, %wt%
- ;WinShow, Spark ahk_pid %SparkVar%
- ;WinShow,%wt%,,,
- ;WinActivate, %wt%,,,
- break
- }
- }
- ;MsgBox %r%
- }
- System_SetDimensions()
- {
- Ratio := A_ScreenWidth / A_ScreenHeight
- MsgBox, Ratio: %Ratio% Width: %A_ScreenWidth% Height %A_ScreenHeight%
- }
- ;Scan the whole screen, move mouse to position
- System_FullScreen_Scan(Img)
- {
- ImageFile = %A_ScriptFullPath%:%Img%.png
- ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %ImageFile%
- if OutputVarX
- {
- ToolTip, Found! `n %Img%
- Sleep, 100
- MouseMove, OutputVarX, OutputVarY, 75
- }
- else
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement