Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;#NoTrayIcon
- #SingleInstance force
- #WinActivateForce
- StringCaseSense Off
- DetectHiddenText, Off
- SetControlDelay -1
- CoordMode, Mouse, Relative
- CoordMode, Pixel, Relative
- EnvGet, CPU_TYPE, PROCESSOR_ARCHITECTURE
- If (CPU_TYPE == "AMD64") ;Search the Game Path in the registry
- {
- RegRead, SC2, HKLM, SOFTWARE\Wow6432Node\Blizzard Entertainment\StarCraft II Retail, GamePath
- }
- Else
- {
- RegRead, SC2, HKLM, SOFTWARE\Blizzard Entertainment\StarCraft II Retail, GamePath
- }
- If (!SC2)
- {
- MsgBox,, Script Warning!, Can't find the game in registry.`nThe script will wait in background...`n`nYou have to start Starcraft II manually!
- }
- Else
- {
- Run, %SC2% ;If found, start the Game...
- }
- Loop, ;Use it as a daemon remaining in the background to fix the game over and over...
- {
- WinWait, ahk_class QWidget ;Wait for this window class
- 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
- WinGetTitle, Win_Title, ahk_id %Win_ID%
- If (Win_Title != "StarCraft II")
- {
- Continue ;Restart, this is not the right window... ;))
- }
- Loop, ;Wait until the Game is ready!
- {
- IfWinNotActive, ahk_id %Win_ID%
- {
- WinActivate, ahk_id %Win_ID% ;Activate the window
- WinWaitActive, ahk_id %Win_ID%
- }
- PixelSearch, Px, Py, 622, 485, 822, 562, 0xAFEDFF, 1, Fast ;Checking if the PLAY button is "in the right color" (Ready to play)
- If ErrorLevel
- {
- Sleep, 1000 ;The game is not ready (probably downloading updates), so I'm waiting...
- Continue
- }
- Else
- {
- MouseGetPos, xpos, ypos
- Click %Px%, %Py% ;Start the Game... (Click on the PLAY button)
- MouseMove, %xpos%, %ypos% ;Move the mouse back to its position
- Break
- }
- }
- Loop, ;Wait for the second crap window...
- {
- WinWait, ahk_class #32770 ;Wait for this window class
- WinGet, Win_ID, ID, ahk_class #32770 ;Try to exclude others windows, if exist with the same class, by getting the right window name
- WinGetTitle, Win_Title, ahk_id %Win_ID%
- If (Win_Title != "StarCraft II")
- {
- Continue ;Restart, not the right window...
- }
- Else
- {
- ControlClick, Button1, ahk_id %Win_ID% ;Press cancel button. Done! (The game will start in FullScreen mode from this point)
- Break
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement