Advertisement
Guest User

StarCraft II - StartFix

a guest
Mar 26th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;#NoTrayIcon
  2. #SingleInstance   force
  3. #WinActivateForce
  4. StringCaseSense   Off
  5. DetectHiddenText, Off
  6. SetControlDelay -1
  7. CoordMode, Mouse, Relative
  8. CoordMode, Pixel, Relative
  9.  
  10. EnvGet, CPU_TYPE, PROCESSOR_ARCHITECTURE
  11. If (CPU_TYPE == "AMD64")                       ;Search the Game Path in the registry
  12.     {
  13.     RegRead, SC2, HKLM, SOFTWARE\Wow6432Node\Blizzard Entertainment\StarCraft II Retail, GamePath
  14.     }
  15. Else
  16.     {
  17.     RegRead, SC2, HKLM, SOFTWARE\Blizzard Entertainment\StarCraft II Retail, GamePath
  18.     }
  19.  
  20. If (!SC2)
  21.     {
  22.     MsgBox,, Script Warning!, Can't find the game in registry.`nThe script will wait in background...`n`nYou have to start Starcraft II manually!
  23.     }
  24. Else
  25.     {
  26.     Run, %SC2%                                  ;If found, start the Game...
  27.     }
  28.  
  29. Loop,                                           ;Use it as a daemon remaining in the background to fix the game over and over...
  30.     {
  31.     WinWait,                ahk_class QWidget   ;Wait for this window class
  32.     WinGet, Win_ID, ID,     ahk_class QWidget   ;Try to exclude others windows, if any exist with the same class, by getting the right window name
  33.     WinGetTitle, Win_Title, ahk_id %Win_ID%
  34.     If (Win_Title != "StarCraft II")
  35.         {
  36.          Continue                               ;Restart, this is not the right window... ;))
  37.         }
  38.  
  39.     Loop,                                       ;Wait until the Game is ready!
  40.         {
  41.         IfWinNotActive,     ahk_id %Win_ID%
  42.             {
  43.              WinActivate,   ahk_id %Win_ID%     ;Activate the window
  44.              WinWaitActive, ahk_id %Win_ID%
  45.             }
  46.         PixelSearch, Px, Py, 622, 485, 822, 562, 0xAFEDFF, 1, Fast ;Checking if the PLAY button is "in the right color" (Ready to play)
  47.         If ErrorLevel
  48.             {
  49.              Sleep, 1000                        ;The game is not ready (probably downloading updates), so I'm waiting...
  50.              Continue
  51.             }
  52.         Else
  53.             {
  54.              MouseGetPos, xpos, ypos
  55.              Click %Px%, %Py%                   ;Start the Game... (Click on the PLAY button)
  56.              MouseMove, %xpos%, %ypos%          ;Move the mouse back to its position
  57.              Break
  58.             }
  59.         }
  60.  
  61.     Loop,                                       ;Wait for the second crap window...
  62.         {
  63.         WinWait, ahk_class #32770               ;Wait for this window class
  64.         WinGet, Win_ID, ID, ahk_class #32770    ;Try to exclude others windows, if exist with the same class, by getting the right window name
  65.         WinGetTitle, Win_Title, ahk_id %Win_ID%
  66.         If (Win_Title != "StarCraft II")
  67.             {
  68.              Continue                           ;Restart, not the right window...
  69.             }
  70.         Else
  71.             {
  72.              ControlClick, Button1, ahk_id %Win_ID%  ;Press cancel button. Done! (The game will start in FullScreen mode from this point)
  73.              Break
  74.             }
  75.         }
  76.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement