Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.25 KB | None | 0 0
  1. #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
  2. #include-once
  3.  
  4. #include <Timers.au3>
  5. #include <SendMessage.au3>
  6. #include <WindowsConstants.au3>
  7. #include <Misc.au3>
  8.  
  9. ; #VARIABLES# ===================================================================================================================
  10.  
  11. ; Used for critical code states to provide atomar execution.
  12. Global $fStateCritical = True
  13.  
  14. ; ===============================================================================================================================
  15.  
  16.  
  17. ; #CONSTANTS# ===================================================================================================================
  18.  
  19. ; In game hotkeys to prevent collision with script hotkeys.
  20. Global Const $hotKeySpell_1 = '{F5}'
  21. Global Const $hotKeySpell_2 = '{F6}'
  22. Global Const $hotKeySpell_3 = '{F7}'
  23. Global Const $hotKeySpell_4 = '{F8}'
  24. Global Const $hotKeyWeaponSwap = '{^}'
  25.  
  26. ; Hotkeys used to toggle script commands. Not allowed to collide with in game hotkeys.
  27. Global Const $hotKeyUse_1 = 1
  28. Global Const $hotKeyUse_2 = 2
  29. Global Const $hotKeyUse_3 = 3
  30. Global Const $hotKeyUse_4 = "c"
  31.  
  32. ; Animation Timers
  33. Global Const $tAttackBackSwing = 190
  34. Global Const $tWeaponSwapTime = 60
  35. Global Const $tInstantSpellBackSwing = 160
  36.  
  37. ; Window handle string
  38. Global Const $sHwnd = "Elder Scrolls Online"
  39.  
  40. ; ===============================================================================================================================
  41.  
  42.  
  43. ; #MAIN FUNCTION# ===============================================================================================================
  44. ; ===============================================================================================================================
  45.  
  46. Local $hDLL = DllOpen("user32.dll")
  47. _main()
  48. DllClose($hDLL)
  49.  
  50. ; ===============================================================================================================================
  51.  
  52.  
  53. ; #CORE FUNCTIONS# ==============================================================================================================
  54. ; ===============================================================================================================================
  55.  
  56. ; #FUNCTION# ====================================================================================================================
  57. ; Name...........: _main
  58. ; Description ...: Contains main loop of the program including higher logic.
  59. ; Remarks .......: Runs script.
  60. ; ===============================================================================================================================
  61. Func _main()
  62. While 1
  63.  
  64. ; Binds hotkeys while game window active.
  65. While _winActive($sHwnd) = True
  66. _bindHotKeySet()
  67. _chat()
  68. WEnd
  69.  
  70. ; Undbinds hotkeys while game window is inactive.
  71. While _winActive($sHwnd) = False
  72. _unbindHotKeySet()
  73. WEnd
  74.  
  75. ; Reduces CPU Load
  76. Sleep(10)
  77. WEnd
  78. EndFunc ;==>_main
  79.  
  80. ; #FUNCTION# ====================================================================================================================
  81. ; Name...........: _bindHotkeySet
  82. ; Description ...: Binds script hotkeys to in game hotkeys.
  83. ; ===============================================================================================================================
  84. Func _bindHotKeySet()
  85.  
  86. ; First Bar
  87. HotKeySet("{" & $hotKeyUse_1 & "}", "_attackHotKey_1")
  88. HotKeySet("{" & $hotKeyUse_2 & "}", "_attackHotKey_2")
  89. HotKeySet("{" & $hotKeyUse_3 & "}", "_attackHotKey_3")
  90. ;HotKeySet("{" & $hotKeyUse_4 & "}", "_attackHotKey_4")
  91.  
  92. ; Second Bar
  93. HotKeySet("!" & "{" & $hotKeyUse_1 & "}", "_buffSpellHotKey_1")
  94. HotKeySet("!" & "{" & $hotKeyUse_2 & "}", "_buffSpellHotKey_2")
  95. HotKeySet("!" & "{" & $hotKeyUse_3 & "}", "_buffSpellHotKey_3")
  96.  
  97. ; Misc Functions
  98. HotKeySet($hotKeyWeaponSwap, "_weaponSwapHotKey")
  99. ;HotKeySet("!e", "_attackHeavyHotKey")
  100. HotKeySet("{F9}", "_terminate")
  101.  
  102. EndFunc ;==>_bindHotKeySet
  103.  
  104. ; #FUNCTION# ====================================================================================================================
  105. ; Name...........: _unbindHotkeySet
  106. ; Description ...: Unbinds all hotkeys.
  107. ; Remarks .......: Add the hotkeys you want to undbind here.
  108. ; ===============================================================================================================================
  109. Func _unbindHotKeySet()
  110.  
  111. ; First Bar
  112. HotKeySet("1")
  113. HotKeySet("2")
  114. HotKeySet("3")
  115. HotKeySet("c")
  116.  
  117. ; Second Bar
  118. HotKeySet("!1")
  119. HotKeySet("!2")
  120. HotKeySet("!3")
  121.  
  122. ; Misc Functions
  123. HotKeySet("!e")
  124. HotKeySet("{F9}")
  125. HotKeySet("{^}")
  126.  
  127. EndFunc ;==>_unbindHotKeySetc
  128.  
  129. ; #FUNCTION# ====================================================================================================================
  130. ; Name...........: _attackHotKey_1
  131. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  132. ; ===============================================================================================================================
  133. Func _attackHotKey_1()
  134.  
  135. _attack($hotKeySpell_1)
  136.  
  137. EndFunc ;==>_attackHotKey_1
  138.  
  139. ; #FUNCTION# ====================================================================================================================
  140. ; Name...........: _attackHotKey_2
  141. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  142. ; ===============================================================================================================================
  143. Func _attackHotKey_2()
  144.  
  145. _attack($hotKeySpell_2)
  146.  
  147. EndFunc ;==>_attackHotKey_2
  148.  
  149. ; #FUNCTION# ====================================================================================================================
  150. ; Name...........: _attackHotKey_3
  151. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  152. ; ===============================================================================================================================
  153. Func _attackHotKey_3()
  154.  
  155. _attack($hotKeySpell_3)
  156.  
  157. EndFunc ;==>_attackHotKey_3
  158.  
  159. ; #FUNCTION# ====================================================================================================================
  160. ; Name...........: _attackHotKey_4
  161. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  162. ; ===============================================================================================================================
  163. Func _attackHotKey_4()
  164.  
  165. _attack($hotKeySpell_4)
  166.  
  167. EndFunc ;==>_attackHotKey_4
  168.  
  169. ; #FUNCTION# ====================================================================================================================
  170. ; Name...........: _attackHotKey_4
  171. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  172. ; ===============================================================================================================================
  173. Func _attackHeavyHotKey()
  174.  
  175. _attackHeavy()
  176.  
  177. EndFunc ;==>_attackHotKey_1
  178.  
  179. ; #FUNCTION# ====================================================================================================================
  180. ; Name...........: _weaponSwapHotKey
  181. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  182. ; ===============================================================================================================================
  183. Func _weaponSwapHotKey()
  184.  
  185. _weaponSwap($hotKeyWeaponSwap)
  186.  
  187. EndFunc ;==>_weaponSwapHotKey
  188.  
  189. ; #FUNCTION# ====================================================================================================================
  190. ; Name...........: _buffSpellHotKey_1
  191. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  192. ; ===============================================================================================================================
  193. Func _buffSpellHotKey_1()
  194.  
  195. _weaponSwapInstantSpell($hotKeyWeaponSwap, $hotKeySpell_1)
  196.  
  197. EndFunc ;==>_buffSpellHotKey_1
  198.  
  199. ; #FUNCTION# ====================================================================================================================
  200. ; Name...........: _buffSpellHotKey_2
  201. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  202. ; ===============================================================================================================================
  203. Func _buffSpellHotKey_2()
  204.  
  205. _weaponSwapBuff($hotKeyWeaponSwap, $hotKeySpell_2)
  206.  
  207. EndFunc ;==>_buffSpellHotKey_2
  208.  
  209. ; #FUNCTION# ====================================================================================================================
  210. ; Name...........: _buffSpellHotKey_3
  211. ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
  212. ; ===============================================================================================================================
  213. Func _buffSpellHotKey_3()
  214.  
  215. _weaponSwapBuff($hotKeyWeaponSwap, $hotKeySpell_3)
  216.  
  217. EndFunc ;==>_buffSpellHotKey_3
  218.  
  219. ; #CORE FUNCTIONS# ==============================================================================================================
  220. ; ===============================================================================================================================
  221.  
  222. ; #FUNCTION# ====================================================================================================================
  223. ; Name...........: _attack
  224. ; Description ...: Performs a light attack plus an additional instant spell.
  225. ; Parameters ....: $hotKeySpell - The ingame keybinding of the spell.
  226. ; ===============================================================================================================================
  227. Func _attack($hotKeySpell)
  228.  
  229. ; Initialising variables
  230. Local $timer = TimerInit()
  231. Local $state = 1
  232.  
  233. If $fStateCritical = True Then
  234.  
  235. ; Begin critical state
  236. $fStateCritical = false
  237.  
  238. While TimerDiff($timer) < 1100
  239. If TimerDiff($timer) < 2 and $state = 1 Then
  240. _attackLight()
  241. $state = 2
  242. EndIf
  243. If TimerDiff($timer) > 300 and $state = 2 Then
  244. _castInstantSpell($hotKeySpell)
  245. $state = 3
  246. EndIf
  247. Sleep(10)
  248. WEnd
  249.  
  250. ; Reset Variables
  251. $timer = 0
  252. $state = 1
  253.  
  254. ; End critical state
  255. $fStateCritical = true
  256.  
  257. EndIf
  258.  
  259. EndFunc ;==>_attack
  260.  
  261. ; #FUNCTION# ====================================================================================================================
  262. ; Name...........: _attackLight
  263. ; Description ...: Performs a light attack.
  264. ; ===============================================================================================================================
  265. Func _attackLight()
  266.  
  267. ; Uses global window handle string
  268. Local $sendHWND = _getHWnd($sHwnd)
  269.  
  270. _SendMessage($sendHWND, $WM_LBUTTONDOWN)
  271. _SendMessage($sendHWND, $WM_LBUTTONUP)
  272. Sleep(10)
  273.  
  274. EndFunc ;==>_attackLight
  275.  
  276. ; #FUNCTION# ====================================================================================================================
  277. ; Name...........: _attackHeavy
  278. ; Description ...: Performs a heavy attack.
  279. ; ===============================================================================================================================
  280. Func _attackHeavy()
  281.  
  282. ; Uses global window handle string
  283. Local $sendHWND = _getHWnd($sHwnd)
  284.  
  285. _SendMessage($sendHWND, $WM_LBUTTONDOWN)
  286. Sleep(230)
  287. _SendMessage($sendHWND, $WM_LBUTTONUP)
  288. Sleep(190)
  289.  
  290. EndFunc ;==>_attackHeavy
  291.  
  292. ; #FUNCTION# ====================================================================================================================
  293. ; Name...........: _castInstantSpell
  294. ; Description ...: Performs an instant spell.
  295. ; Parameters ....: $hotKey - The ingame keybinding of the spell.
  296. ; ===============================================================================================================================
  297. Func _castInstantSpell($hotKey)
  298.  
  299. _controlSend($hotKey)
  300.  
  301. EndFunc ;==>_castInstantSpell
  302.  
  303. ; #FUNCTION# ====================================================================================================================
  304. ; Name...........: _weaponSwap
  305. ; Description ...: Performs a weapon swap.
  306. ; Parameters ....: $hotKey - The in game keybinding of weapon swap.
  307. ; ===============================================================================================================================
  308. Func _weaponSwap($hotKey)
  309.  
  310. _controlSend($hotKey)
  311. Sleep(10)
  312.  
  313. EndFunc ;==>_weaponSwap
  314.  
  315. ; #FUNCTION# ====================================================================================================================
  316. ; Name...........: _weaponSwapBuff
  317. ; Description ...: Swaps bars to perform an instant spell and swaps back.
  318. ; Parameters ....: $hotKeySwap - The in game keybinding of weapon swap.
  319. ; $hotKeyBuff - The in game keybinding of the spell.
  320. ; ===============================================================================================================================
  321. Func _weaponSwapBuff($hotKeySwap, $hotKeyBuff)
  322.  
  323. ; Initialising variables
  324. Local $timer = TimerInit()
  325. Local $state = 1
  326.  
  327. If $fStateCritical = True Then
  328.  
  329. ; Critical state start
  330. $fStateCritical = False
  331.  
  332. While TimerDiff($timer) < 1100
  333.  
  334. If TimerDiff($timer) < 2 and $state = 1 Then
  335. _weaponSwap($hotKeySwap)
  336. $state = 2
  337. EndIf
  338.  
  339. If TimerDiff($timer) > 200 and $state = 2 Then
  340. _castInstantSpell($hotKeyBuff)
  341. $state = 3
  342. EndIf
  343.  
  344. If TimerDiff($timer) > 600 and $state = 3 Then
  345. _weaponSwap($hotKeySwap)
  346. $state = 4
  347. EndIf
  348.  
  349. Sleep(10)
  350. WEnd
  351.  
  352. ; Reset Variables
  353. $timer = 0
  354. $state = 1
  355.  
  356. ; Critical state end
  357. $fStateCritical = True
  358.  
  359. EndIf
  360. EndFunc ;==>_weaponSwapBuff
  361.  
  362. ; #FUNCTION# ====================================================================================================================
  363. ; Name...........: _weaponSwapInstantSpell
  364. ; Description ...: Swaps bars to perform an instant spell and swaps back.
  365. ; Parameters ....: $hotKeySwap - The in game keybinding of weapon swap.
  366. ; $hotKeyBuff - The in game keybinding of the spell.
  367. ; ===============================================================================================================================
  368. Func _weaponSwapInstantSpell($hotKeySwap, $hotKeyBuff)
  369.  
  370. ; Initialising variables
  371. Local $timer = TimerInit()
  372. Local $state = 1
  373.  
  374. If $fStateCritical = True Then
  375.  
  376. ; Critical state start
  377. $fStateCritical = False
  378.  
  379. While TimerDiff($timer) < 1100
  380.  
  381. If TimerDiff($timer) < 2 and $state = 1 Then
  382. _weaponSwap($hotKeySwap)
  383. $state = 2
  384. EndIf
  385.  
  386. If TimerDiff($timer) > 200 and $state = 2 Then
  387. _castInstantSpell($hotKeyBuff)
  388. $state = 3
  389. EndIf
  390.  
  391. If TimerDiff($timer) > 600 and $state = 3 Then
  392. _weaponSwap($hotKeySwap)
  393. $state = 4
  394. EndIf
  395.  
  396. Sleep(10)
  397. WEnd
  398.  
  399. ; Reset Variables
  400. $timer = 0
  401. $state = 1
  402.  
  403. ; Critical state end
  404. $fStateCritical = True
  405.  
  406. EndIf
  407. EndFunc ;==>_weaponSwapInstantSpell
  408.  
  409.  
  410. ; #INTERN FUNCTIONS# ============================================================================================================
  411. ; ===============================================================================================================================
  412.  
  413. ; #FUNCTION# ====================================================================================================================
  414. ; Name...........: _chat
  415. ; Description ...: Unbinds all hotkeys on ENTER key press.
  416. ; ===============================================================================================================================
  417. Func _chat()
  418.  
  419. ;0D = Enter Key
  420. ;IsPressed requires stop or long sleep to work properly.
  421. If _IsPressed("0D", $hDLL) Then
  422.  
  423. _unbindHotkeySet()
  424. ToolTip("Chatmode on, Hotkeys unbound", 0, 990)
  425. _sleepTimer(500)
  426.  
  427. Do
  428.  
  429. _unbindHotkeySet()
  430. Sleep(10)
  431.  
  432. Until _IsPressed("0D", $hDLL)
  433.  
  434. ToolTip("")
  435. _sleepTimer(500)
  436.  
  437. EndIf
  438.  
  439. EndFunc ;==>_chat
  440.  
  441. ; #FUNCTION# ====================================================================================================================
  442. ; Name...........: _winActive
  443. ; Description ...: Checks if a given window string is currently active.
  444. ; Parameters ....: $hWndString - String of the window handle to check.
  445. ; Return values..: True - Given handle is active.
  446. ; False - Given handle is inactive.
  447. ; ===============================================================================================================================
  448. Func _winActive($hWndString)
  449.  
  450. Local $hWnd = WinGetHandle($hWndString)
  451.  
  452. If WinActive($hWnd) = 0 Then
  453. Return False
  454. Else
  455. Return True
  456. EndIf
  457.  
  458. EndFunc ;==>_winActive
  459.  
  460. ; #FUNCTION# ====================================================================================================================
  461. ; Name...........: _getHwnd
  462. ; Description ...: Returns the hex PID of a given handle string.
  463. ; Parameters ....: $hWndString - String of the handle to process.
  464. ; Return values..: $hWnd - PID (hex)
  465. ; ===============================================================================================================================
  466. Func _getHWnd($hWndString)
  467.  
  468. Local $hWnd = WinGetHandle($hWndString)
  469. Return $hWnd
  470.  
  471. EndFunc ;==>_getHWnd
  472.  
  473. ; #FUNCTION# ====================================================================================================================
  474. ; Name...........: _terminate
  475. ; Description ...: Terminates the script.
  476. ; ===============================================================================================================================
  477. Func _terminate()
  478.  
  479. Exit 0
  480.  
  481. EndFunc ;==>_terminate
  482.  
  483. ; #FUNCTION# ====================================================================================================================
  484. ; Name...........: _pause
  485. ; Description ...: Pauses the script.
  486. ;; ===============================================================================================================================
  487. Func _pause()
  488.  
  489. While 1
  490. Sleep(100)
  491. WEnd
  492.  
  493. EndFunc ;==>_sleep
  494.  
  495. ; #FUNCTION# ====================================================================================================================
  496. ; Name...........: _controlSend
  497. ; Description ...: Sends a keystroke to a window handle.
  498. ; Parameters ....: $hotKey - Key to send.
  499. ; ===============================================================================================================================
  500. Func _controlSend($hotKey)
  501.  
  502. Local $sendHWND = _getHWnd($sHwnd)
  503. ControlSend("", "", $sendHWND, $hotKey)
  504.  
  505. EndFunc ;==>_controlSend
  506.  
  507. ; #FUNCTION# ====================================================================================================================
  508. ; Name...........: _msg
  509. ; Description ...: Opens a message box with a given string.
  510. ; Parameters ....: $sText - String that should be shown in the box.
  511. ; ===============================================================================================================================
  512. Func _msg($sText)
  513.  
  514. MsgBox(0, "Debug", $sText)
  515.  
  516. EndFunc ;==>_msg
  517.  
  518. ; #FUNCTION# ====================================================================================================================
  519. ; Name...........: _sleepTimer
  520. ; Description ...: Advanced sleep function to minimize script lock time.
  521. ; Parameters ....: $tLength - Length of the Sleep time in MS.
  522. ; ===============================================================================================================================
  523. Func _sleepTimer($tLength)
  524.  
  525. Local $timer = TimerInit()
  526.  
  527. While TimerDiff($timer) <= $tLength
  528. Sleep(10)
  529. WEnd
  530.  
  531. EndFunc ;==>_sleepTimer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement