Advertisement
Guest User

Untitled

a guest
Aug 13th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #WinActivateForce
  2. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  3. #SingleInstance, Force
  4. SetBatchLines, -1
  5.  
  6. ;Install all images inside the exe/ahk file
  7. FileInstall, Dark_ChatOptions_A.png, %A_ScriptFullPath%:Dark_ChatOptions_A.png
  8. FileInstall, Dark_ChatOptions_B.png, %A_ScriptFullPath%:Dark_ChatOptions_B.png
  9. FileInstall, Light_ChatOptions_A.png, %A_ScriptFullPath%:Light_ChatOptions_A.png
  10. FileInstall, Light_ChatOptions_B.png, %A_ScriptFullPath%:Light_ChatOptions_B.png
  11. FileInstall, Dark_Discord_Logo.png, %A_ScriptFullPath%:Dark_Discord_Logo.png
  12. FileInstall, Dark_Discord_LogoB.png, %A_ScriptFullPath%:Dark_Discord_LogoB.png
  13. FileInstall, Dark_Discord_LogoC.png, %A_ScriptFullPath%:Dark_Discord_LogoC.png
  14. FileInstall, Loading_Messages.png, %A_ScriptFullPath%:Loading_Messages.png
  15. FileInstall, Dark_ChatTop_Line.png, %A_ScriptFullPath%:Dark_ChatTop_Line.png
  16. FileInstall, Dark_ChatBottom_Line.png, %A_ScriptFullPath%:Dark_ChatBottom_Line.png
  17.  
  18.  
  19. FileInstall, Dark_ChatFriends_Highlighted.png, %A_ScriptFullPath%:Dark_ChatFriends_Highlighted.png
  20. FileInstall, Dark_ChatFriends.png, %A_ScriptFullPath%:Dark_ChatFriends.png
  21. FileInstall, Dark_ChatHOME.png, %A_ScriptFullPath%:Dark_ChatHOME.png
  22. FileInstall, Dark_ChatHOME_Highlighted.png, %A_ScriptFullPath%:Dark_ChatHOME_Highlighted.png
  23.  
  24.  
  25. ;FileInstall, Dark_ChatOptions_DELETEB.png, %A_ScriptFullPath%:Dark_ChatOptions_DELETEB.png
  26. FileInstall, Dark_Chat_DELETE.png, %A_ScriptFullPath%:Dark_Chat_DELETE.png
  27. FileInstall, Dark_Chat_DELETEB.png, %A_ScriptFullPath%:Dark_Chat_DELETEB.png
  28. ;FileInstall, Dark_ChatOptions_DELETE.bmp, %A_ScriptFullPath%:Dark_ChatOptions_DELETE.bmp
  29. FileInstall, Dark_ChatOptions_DELETE_Confirm.png, %A_ScriptFullPath%:Dark_ChatOptions_DELETE_Confirm.png
  30.  
  31. global Process_id := ""
  32. global CurrentTask := "Starting Up"
  33.  
  34. global System_Chat_Bottom := ""
  35. global System_Chat_Top := ""
  36. global System_Chat_Middle := ""
  37. global System_Chat_OptionsX := ""
  38.  
  39.     ;Gui, New,+Sysmenu +LastFound -Caption +AlwaysOnTop +ToolWindow -Border,
  40.     ;gui, add, button, x0 y0 h30 w120 vSETUP gsub5, Calibrate
  41.     ;gui, -Sysmenu
  42.     ;gui, show, w120 h30,  
  43.  
  44. ;Set Process_id globals and maximize the window
  45. f1::
  46.     System_CheckWindowsList()
  47.     Sleep, 500
  48.     System_Calibrate()
  49.     System_Calibrate_Chat_Options()
  50. return
  51. ;Find the discord logo!
  52. f2::
  53.  
  54.     ;System_FullScreen_Scan("Dark_ChatOptions_DELETE_Confirm")
  55.     System_FullScreen_Scan("Dark_Chat_DELETEB.png")
  56.     ;System_FullScreen_Scan("Dark_Chat_DELETEB")
  57.     ;System_FullScreen_Scan_And_Click("Dark_Chat_DELETEB")
  58. return
  59.  
  60. ;Look for some options
  61. f3::
  62.     System_Calibrate_Chat_Options()
  63. return
  64.  
  65. ;Start recursive check
  66. f4::
  67.     SetTimer, FidelityScanner, 100
  68. return
  69.  
  70. ^!p::
  71. Reload
  72. return
  73.  
  74. ;-90 pixels down from friends to click a person
  75. f5::
  76.     System_Scrape_Up()
  77.  
  78. return
  79.  
  80. sub5:
  81. {
  82.    
  83. }
  84. return
  85.  
  86. return
  87. System_FullScreen_Scan_And_Click(Img)
  88. {
  89.     ImageFile = %A_ScriptFullPath%:%Img%
  90.     ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %ImageFile%
  91.    
  92.     if OutputVarX
  93.     {
  94.         ;ToolTip, Found! `n %Img%
  95.         Sleep, 100
  96.         ;MouseMove, OutputVarX, OutputVarY, 10
  97.         MouseClick, left, OutputVarX, OutputVarY, 1, 2
  98.         ;if (%Img% = Dark_ChatFriends.png OR %Img% = Dark_ChatFriends_Highlighted.png)
  99.         ;{
  100.             ;MsgBox, %Img%
  101.             ;MsgBox, %Img%
  102.             ;Sleep, 100
  103.             ;MouseClick, left, OutputVarX, (OutputVarY+90), 1, 2
  104.            
  105.            
  106.         ;}
  107.         return true
  108.     }
  109.     else
  110.     {
  111.         return false
  112.     }
  113. }
  114. System_Scrape_Up()
  115. {
  116.     if (System_Scraper_Left_OffX)
  117.         MouseMove, System_Scraper_Left_OffX, System_Scraper_Left_OffY, 10
  118.     Else
  119.         MouseMove, System_Chat_OptionsX, System_Chat_Bottom, 10
  120.    
  121.    
  122.     ;MsgBox, %System_Chat_Top% vs %ypos%
  123.     Loop
  124.     {
  125.         MouseGetPos, xpos, ypos
  126.         MouseMove, xpos, (ypos - 10)
  127.         if (ypos <= System_Chat_Top)
  128.         {
  129.             ToolTip, Scroll Window
  130.             MouseMove, xpos, System_Chat_Bottom
  131.         }
  132.         if(System_FullScreen_Scan_And_Click("Dark_ChatOptions_A.png") OR System_FullScreen_Scan_And_Click("Dark_ChatOptions_B.png") )
  133.         {
  134.             ;Sleep, 100
  135.             MouseGetPos, xpos, ypos
  136.             ClickedYPos := ypos
  137.             ;MouseMove, xpos, (ypos + 70)
  138.             increment := 0
  139.             Sleep, 100
  140.             if System_FullScreen_Scan_And_Click("Dark_Chat_DELETE.png")
  141.                 increment := 35
  142.             Sleep, 50
  143.             if System_FullScreen_Scan_And_Click("Dark_Chat_DELETEB.png")
  144.                 increment := 35
  145.            
  146.             ;{
  147.             ;MouseClick,left
  148.             Sleep, 600
  149.                 if( System_FullScreen_Scan_And_Click("Dark_ChatOptions_DELETE_Confirm.png") )
  150.                 {
  151.                     Sleep, 50
  152.                 }
  153.                
  154.             ;}
  155.             MouseMove, System_Chat_OptionsX, (ClickedYPos + increment)
  156.         }
  157.        
  158.     }
  159. }
  160. System_Calibrate()
  161. {
  162.     System_FullScreen_Scan_And_Click("Dark_ChatHOME.png")
  163.     Sleep, 300
  164. ;   if !System_FullScreen_Scan_And_Click("Dark_ChatFriends_Highlighted")
  165.         System_FullScreen_Scan("Dark_ChatFriends_Highlighted.png")
  166.         System_FullScreen_Scan_And_Click("Dark_ChatFriends.png")
  167.     MouseGetPos, xpos, ypos
  168.     MouseClick, left, xpos, (ypos+90), 1, 2
  169.     Sleep, 300
  170.     ImageSearch, OutputVarX, System_Chat_Top, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_ChatTop_Line.png
  171.     ImageSearch, OutputVarX, System_Chat_Bottom, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_ChatBottom_Line.png
  172.     System_Chat_Middle := (A_ScreenWidth/2)
  173.     ;MsgBox, System_Chat_Middle: %System_Chat_Middle% System_Chat_Bottom: %System_Chat_Bottom% System_Chat_Top: %System_Chat_Top%
  174.     MouseMove, System_Chat_Middle, System_Chat_Bottom, 10
  175. }
  176. System_Calibrate_Chat_Options()
  177. {
  178.     MouseMove, System_Chat_Middle, System_Chat_Bottom, 10
  179.    
  180.    
  181.     ;MsgBox, %System_Chat_Top% vs %ypos%
  182.     Loop
  183.     {
  184.         MouseGetPos, xpos, ypos
  185.         MouseMove, xpos, (ypos - 10)
  186.         if (ypos <= System_Chat_Top)
  187.         {
  188.             ToolTip, Scroll Window
  189.             MouseMove, xpos, System_Chat_Bottom
  190.         }
  191.         if(System_FullScreen_Scan("Dark_ChatOptions_A.png") OR System_FullScreen_Scan_And_Click("Dark_ChatOptions_B.png"))
  192.         {
  193.             Sleep, 500
  194.             break
  195.         }
  196.     }
  197.     MouseGetPos, System_Chat_OptionsX, ypos
  198. }
  199. FidelityScanner:
  200.     ImageFile = %A_ScriptFullPath%:Dark_Discord_Logo.png
  201.     ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_Logo.png
  202.     ImageSearch, OutputVarXX, OutputVarYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoB.png
  203.     ImageSearch, OutputVarXXX, OutputVarYYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoC.png
  204.     if (OutputVarX OR OutputVarXX OR OutputVarXXX)
  205.     {
  206.         ToolTip, Fidelity: Positive `n%CurrentTask%
  207.         WinGetTitle WinTitle, ahk_id %Process_id%
  208.         WinGetPos, X, Y, Width, Height, %WinTitle%,,,
  209.         ;MsgBox, X: %X% Y: %Y% Width: %Width% Height: %Height%
  210.         ;MsgBox, . (%(%-%Width%) . (%A_ScreenHeight%-%Height%)  
  211.         if ((A_ScreenWidth-Width) > 100) OR ((A_ScreenHeight-Height) > 100)
  212.         {
  213.             ;MsgBox, Out of size range!
  214.             WinGetTitle wt, ahk_id %Process_id%
  215.             WinActivate, %wt%
  216.             WinMaximize, %wt%
  217.         }
  218.     }
  219.     else
  220.     {
  221.         Loop 6
  222.         {
  223.             ;break
  224.             CurrentTask := "Rescuing Target... " (6-A_Index)
  225.             ToolTip, Fidelity: Negative `n%CurrentTask%
  226.             Sleep, 1000
  227.             ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_Logo.png
  228.             ImageSearch, OutputVarXX, OutputVarYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoB.png
  229.             ImageSearch, OutputVarXXX, OutputVarYYY, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_ScriptFullPath%:Dark_Discord_LogoC.png
  230.             if (OutputVarX OR OutputVarXX OR OutputVarXXX)
  231.             {
  232.                 CurrentTask := "Waiting..."
  233.                 return
  234.             }
  235.            
  236.         }
  237.         CurrentTask := "Waiting..."
  238.         System_CheckWindowsList()
  239.         ToolTip, Fidelity: Negative `n%CurrentTask%
  240.         Sleep, 1000
  241.     }
  242. return
  243. ;This finds the path of the process executable
  244. GetModuleExeName(p_id) {
  245.     for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where ProcessId=" p_id)
  246.         return process.ExecutablePath
  247. }
  248.  
  249. System_CheckWindowsList()
  250. {
  251.     ;This is the 'soft' check for discord simply cycling the windows that are open
  252.     DetectHiddenWindows, Off
  253.     WinGet windows, List
  254.     Loop %windows%
  255.     {
  256.         Process_id := windows%A_Index%
  257.         WinGetTitle wt, ahk_id %Process_id%
  258.         WinGet, PName, ProcessName, %wt%,,,
  259.        
  260.         r .= wt . id . PName . "`n"
  261.        
  262.         if PName = Discord.exe
  263.         {
  264.             ;MsgBox, Got it!
  265.             WinGetTitle wt, ahk_id %Process_id%
  266.             WinActivate, %wt%
  267.             WinMaximize, %wt%
  268.             return
  269.         }
  270.     }
  271.     ;This is the 'hard' check for discord that checks for 'hidden' (windows does this behaviour for tray icon minimizing and other stuff)
  272.     ;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
  273.     DetectHiddenWindows, On
  274.     WinGet windows, List
  275.     Loop %windows%
  276.     {
  277.         Process_id := windows%A_Index%
  278.         WinGetTitle wt, ahk_id %Process_id%
  279.         WinGet, PName, ProcessName, %wt%,,,
  280.        
  281.         ;r .= wt . id . PName . "`n"
  282.        
  283.         if PName = Discord.exe
  284.         {
  285.             WinGet, PID, PID, ahk_id %Process_id%
  286.             FullEXEPath := GetModuleExeName(PID)
  287.             ;Remove the exe from the path name
  288.             FullEXEPath := StrReplace(FullEXEPath, PName, "")
  289.             ;MsgBox, Found it! %wt% `n %PName% `n %FullEXEPath% %PID%
  290.                
  291.             Run, %PName%, %FullEXEPath%,
  292.             WinMaximize, %wt%
  293.             ;WinWait, %wt%
  294.             ;WinShow, Spark ahk_pid %SparkVar%
  295.             ;WinShow,%wt%,,,
  296.             ;WinActivate, %wt%,,,
  297.             break
  298.         }
  299.     }
  300.     ;MsgBox %r%
  301. }
  302.  
  303. System_SetDimensions()
  304. {
  305.     Ratio := A_ScreenWidth / A_ScreenHeight
  306.  
  307.     MsgBox, Ratio: %Ratio% Width: %A_ScreenWidth% Height %A_ScreenHeight%
  308. }
  309. ;Scan the whole screen, move mouse to position
  310. System_FullScreen_Scan(Img)
  311. {
  312.     ImageFile = %A_ScriptFullPath%:%Img%
  313.     ImageSearch, OutputVarX, OutputVarY, 0, 0, A_ScreenWidth, A_ScreenHeight, %ImageFile%
  314.    
  315.     if OutputVarX
  316.     {
  317.         ToolTip, Found! `n %Img%
  318.         Sleep, 100
  319.         MouseMove, OutputVarX, OutputVarY, 2
  320.         return true
  321.     }
  322.     else
  323.     {
  324.         return false
  325.     }
  326. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement