Advertisement
Guest User

compile script

a guest
Nov 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.92 KB | None | 0 0
  1. $bound = False
  2. $suffix = " - GMEdit"
  3. $suffixLen = StringLen($suffix)
  4. while 1 ; bind/unbind the hotkey as we switch to/from GMEdit
  5.     $title = WinGetTitle("[ACTIVE]")
  6.     $newBound = (StringLen($title) > $suffixLen And StringRight($title, $suffixLen) == $suffix)
  7.     If (Not $bound And $newBound) Then
  8.         HotKeySet("{F5}", "OnRun")
  9.     ElseIf ($bound And Not $newBound) Then
  10.         HotKeySet("{F5}")
  11.     EndIf
  12.     $bound = $newBound
  13.     sleep(250)
  14. wend
  15. Func OnRun()
  16.     $orig = WinGetHandle("[ACTIVE]")
  17.     $title = WinGetTitle("[ACTIVE]")
  18.     $titleLen = StringLen($title)
  19.     ; check that it's still GMEdit just to be really sure:
  20.     $newBound = ($titleLen > $suffixLen And StringRight($title, $suffixLen) == $suffix)
  21.     If (Not $newBound) Then Exit
  22.     ; get the project name from GMEdit window title:
  23.     $project = StringLeft($title, $titleLen - $suffixLen)
  24.     ; make a regular expression to find the matching GM:S/GMS2 editor:
  25.     If (StringRight($project, 4) == ".yyp") Then
  26.         $rx = StringLeft($project, StringLen($project) - 4)
  27.         $rx = StringReplace($rx, ".", "\.")
  28.         $rx = "^" & $rx & " - GameMaker Studio 2"
  29.     Else
  30.         $rx = StringReplace($project, ".", "\.")
  31.         $rx = "^" & $rx & "\*?\b.+\(v[\d.]+\)\s*$" ; "[project name] ... (v1.4.xxxx)"
  32.     EndIf
  33.     ; and send a F5 key there:
  34.     $def = "[REGEXPTITLE:" & $rx & "]"
  35.     $hwnd = WinGetHandle($def)
  36.     $out = ControlSend($hwnd, "", "", "{F5}")
  37.     ConsoleWrite($hwnd & " " & WinGetTitle($hwnd) & " r" & $out & " e" & @error & @CRLF)
  38.     ; Faster window switching
  39.     Opt("WinWaitDelay", 0)
  40.     ; Show GMS, even if minimized
  41.     WinSetState($hwnd, "", @SW_MAXIMIZE )
  42.     WinActivate($hwnd)
  43.     ; Wait until your compiled game appears.
  44.     WinWait("[CLASS:YYGameMakerYY]")
  45.     ; Wait until your compiled game closes.
  46.     WinWaitClose("[CLASS:YYGameMakerYY]")
  47.     ; Switch back to GMEdit
  48.     WinActivate($title)
  49. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement