najwalaylah

Creature Control by a Guest

May 11th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;
  2. ; Creature Control macro
  3. ;
  4. AutoItSetOption("WinTitleMatchMode", 4)
  5. #include <GUIConstantsEx.au3>
  6.  
  7. Global $_MacroRunning = False
  8. Global $_hwnd = 0
  9. Global $_LoopCnt = 0
  10. Global $_bShouldMinimizeMO = False
  11. Global $_nCommandType = -1
  12. Global $sCommand[5]=["{ENTER}feed{ENTER}",  "{ENTER}graze{ENTER}", "{ENTER}follow me{ENTER}", "{ENTER}protect me{ENTER}", "{ENTER}stay{ENTER}"]
  13.  
  14.  
  15. Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
  16. $mainwindow = GUICreate("McMO", 200, 150)
  17. GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
  18. GUICtrlCreateLabel("Key To Send: " & $_KeyToPress, 30, 10)
  19. $chkMinimize = GUICtrlCreateCheckbox("Minimize Mortal Online?", 30, 30, 120, 20)
  20. GUICtrlSetOnEvent($chkMinimize, "OnCheck")
  21. $okbutton = GUICtrlCreateButton("Run/Stop", 135, 120, 60)
  22. GUICtrlSetOnEvent($okbutton, "OKBut")
  23.  
  24. GUISetState(@SW_SHOW)
  25. Sleep(2000)
  26.  
  27. $_LoopCnt = 1
  28. While 1 = 1
  29.  
  30.     If (mod( $_LoopCnt, 5 ) = 0) THEN
  31.         IF ($_bShouldMinimizeMO) Then
  32.             WinSetState ( $_hwnd, "", @SW_MINIMIZE )
  33.         Else
  34.             WinSetState ( $_hwnd, "", @SW_RESTORE )
  35.         EndIf
  36.     EndIf  
  37.    
  38.     If ($_MacroRunning == True) and ($_hwnd <> 0) Then
  39.         $_LoopCnt += 1
  40.         $_nCommandType  += 1
  41.         ;clamp
  42.         if $_nCommandType = 5 then $_nCommandType = 0
  43.        
  44.         ControlSend($_hwnd, "", "", $sCommand[$_nCommandType])
  45.         if ($_nCommandType == 0 ) Then
  46.             sleep(2000)
  47.         Else
  48.             Sleep(5000)
  49.         EndIf
  50.        
  51.     Else
  52.         ;macro paused.
  53.         Sleep( 2000 )
  54.     EndIf
  55. Wend
  56.  
  57. ;End main thread
  58. ;-------------------------------
  59.  
  60.  
  61. Func OKButton()
  62.   ;Note: at this point @GUI_CTRLID would equal $okbutton,
  63.   ;and @GUI_WINHANDLE would equal $mainwindow
  64.  
  65.     $_hwnd = WinGetHandle("classname=LaunchUnrealUWindowsClient")
  66.     If @Error Then
  67.         ;~ Title:   Mortal Online Beta
  68.         ;~ Class:   LaunchUnrealUWindowsClient
  69.         MsgBox(0, "McMortalOnline", "Unable to find Mortal Online window, make sure it's open.")
  70.         $_MacroRunning = False
  71.     Else
  72.         $_MacroRunning = NOT $_MacroRunning
  73.     EndIf
  74.    
  75.     if ( $_MacroRunning == False) Then
  76.         WinSetState ( $_hwnd, "", @SW_RESTORE )
  77.     EndIf
  78.    
  79.        
  80.  
  81. EndFunc
  82.  
  83. Func CLOSEClicked()
  84.   ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
  85.   ;and @GUI_WINHANDLE would equal $mainwindow
  86.   Exit
  87. EndFunc
  88.  
  89. Func OnCheck()
  90.     $_bShouldMinimizeMO = NOT $_bShouldMinimizeMO
  91. EndFunc
Add Comment
Please, Sign In to add comment