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
- FileInstall, Dark_ChatTop_Line.png, %A_ScriptFullPath%:Dark_ChatTop_Line.png
- FileInstall, Dark_ChatBottom_Line.png, %A_ScriptFullPath%:Dark_ChatBottom_Line.png
- FileInstall, Dark_ChatFriends_Highlighted.png, %A_ScriptFullPath%:Dark_ChatFriends_Highlighted.png
- FileInstall, Dark_ChatFriends.png, %A_ScriptFullPath%:Dark_ChatFriends.png
- FileInstall, Dark_ChatHOME.png, %A_ScriptFullPath%:Dark_ChatHOME.png
- FileInstall, Dark_ChatHOME_Highlighted.png, %A_ScriptFullPath%:Dark_ChatHOME_Highlighted.png
- ;FileInstall, Dark_ChatOptions_DELETEB.png, %A_ScriptFullPath%:Dark_ChatOptions_DELETEB.png
- FileInstall, Dark_Chat_DELETE.png, %A_ScriptFullPath%:Dark_Chat_DELETE.png
- FileInstall, Dark_Chat_DELETEB.png, %A_ScriptFullPath%:Dark_Chat_DELETEB.png
- ;FileInstall, Dark_ChatOptions_DELETE.bmp, %A_ScriptFullPath%:Dark_ChatOptions_DELETE.bmp
- FileInstall, Dark_ChatOptions_DELETE_Confirm.png, %A_ScriptFullPath%:Dark_ChatOptions_DELETE_Confirm.png
- global Process_id := ""
- global CurrentTask := "Starting Up"
- global System_Chat_Bottom := ""
- global System_Chat_Top := ""
- global System_Chat_Middle := ""
- global System_Chat_OptionsX := ""
- ;Gui, New,+Sysmenu +LastFound -Caption +AlwaysOnTop +ToolWindow -Border,
- ;gui, add, button, x0 y0 h30 w120 vSETUP gsub5, Calibrate
- ;gui, -Sysmenu
- ;gui, show, w120 h30,
- ;Set Process_id globals and maximize the window
- f1::
- System_CheckWindowsList()
- Sleep, 500
- System_Calibrate()
- System_Calibrate_Chat_Options()
- return
- ;Find the discord logo!
- f2::
- ;System_FullScreen_Scan("Dark_ChatOptions_DELETE_Confirm")
- System_FullScreen_Scan("Dark_Chat_DELETEB.png")
- ;System_FullScreen_Scan("Dark_Chat_DELETEB")
- ;System_FullScreen_Scan_And_Click("Dark_Chat_DELETEB")
- return
- ;Look for some options
- f3::
- System_Calibrate_Chat_Options()
- return
- ;Start recursive check
- f4::
- SetTimer, FidelityScanner, 100
- return
- ^!p::
- Reload
- return
- ;-90 pixels down from friends to click a person
- f5::
- System_Scrape_Up()
- return
- sub5:
- {
- }
- return
- return
- System_FullScreen_Scan_And_Click(Img)
- {
- ImageFile = %A_ScriptFullPath%:%Img%
- ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %ImageFile%
- if OutputVarX
- {
- ;ToolTip, Found! `n %Img%
- Sleep, 100
- ;MouseMove, OutputVarX, OutputVarY, 10
- MouseClick, left, OutputVarX, OutputVarY, 1, 2
- ;if (%Img% = Dark_ChatFriends.png OR %Img% = Dark_ChatFriends_Highlighted.png)
- ;{
- ;MsgBox, %Img%
- ;MsgBox, %Img%
- ;Sleep, 100
- ;MouseClick, left, OutputVarX, (OutputVarY+90), 1, 2
- ;}
- return true
- }
- else
- {
- return false
- }
- }
- System_Scrape_Up()
- {
- if (System_Scraper_Left_OffX)
- MouseMove, System_Scraper_Left_OffX, System_Scraper_Left_OffY, 10
- Else
- MouseMove, System_Chat_OptionsX, System_Chat_Bottom, 10
- ;MsgBox, %System_Chat_Top% vs %ypos%
- Loop
- {
- MouseGetPos, xpos, ypos
- MouseMove, xpos, (ypos - 10)
- if (ypos <= System_Chat_Top)
- {
- ToolTip, Scroll Window
- MouseMove, xpos, System_Chat_Bottom
- }
- if(System_FullScreen_Scan_And_Click("Dark_ChatOptions_A.png") OR System_FullScreen_Scan_And_Click("Dark_ChatOptions_B.png") )
- {
- ;Sleep, 100
- MouseGetPos, xpos, ypos
- ClickedYPos := ypos
- ;MouseMove, xpos, (ypos + 70)
- increment := 0
- Sleep, 100
- if System_FullScreen_Scan_And_Click("Dark_Chat_DELETE.png")
- increment := 35
- Sleep, 50
- if System_FullScreen_Scan_And_Click("Dark_Chat_DELETEB.png")
- increment := 35
- ;{
- ;MouseClick,left
- Sleep, 600
- if( System_FullScreen_Scan_And_Click("Dark_ChatOptions_DELETE_Confirm.png") )
- {
- Sleep, 50
- }
- ;}
- MouseMove, System_Chat_OptionsX, (ClickedYPos + increment)
- }
- }
- }
- System_Calibrate()
- {
- System_FullScreen_Scan_And_Click("Dark_ChatHOME.png")
- Sleep, 300
- ; if !System_FullScreen_Scan_And_Click("Dark_ChatFriends_Highlighted")
- System_FullScreen_Scan("Dark_ChatFriends_Highlighted.png")
- System_FullScreen_Scan_And_Click("Dark_ChatFriends.png")
- MouseGetPos, xpos, ypos
- MouseClick, left, xpos, (ypos+90), 1, 2
- Sleep, 300
- ImageSearch, OutputVarX, System_Chat_Top, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_ChatTop_Line.png
- ImageSearch, OutputVarX, System_Chat_Bottom, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_ChatBottom_Line.png
- System_Chat_Middle := (A_ScreenWidth/2)
- ;MsgBox, System_Chat_Middle: %System_Chat_Middle% System_Chat_Bottom: %System_Chat_Bottom% System_Chat_Top: %System_Chat_Top%
- MouseMove, System_Chat_Middle, System_Chat_Bottom, 10
- }
- System_Calibrate_Chat_Options()
- {
- MouseMove, System_Chat_Middle, System_Chat_Bottom, 10
- ;MsgBox, %System_Chat_Top% vs %ypos%
- Loop
- {
- MouseGetPos, xpos, ypos
- MouseMove, xpos, (ypos - 10)
- if (ypos <= System_Chat_Top)
- {
- ToolTip, Scroll Window
- MouseMove, xpos, System_Chat_Bottom
- }
- if(System_FullScreen_Scan("Dark_ChatOptions_A.png") OR System_FullScreen_Scan_And_Click("Dark_ChatOptions_B.png"))
- {
- Sleep, 500
- break
- }
- }
- MouseGetPos, System_Chat_OptionsX, ypos
- }
- 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%
- ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %ImageFile%
- if OutputVarX
- {
- ToolTip, Found! `n %Img%
- Sleep, 100
- MouseMove, OutputVarX, OutputVarY, 2
- return true
- }
- else
- {
- return false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement