Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
- #include-once
- #include <Timers.au3>
- #include <SendMessage.au3>
- #include <WindowsConstants.au3>
- #include <Misc.au3>
- ; #VARIABLES# ===================================================================================================================
- ; Used for critical code states to provide atomar execution.
- Global $fStateCritical = True
- ; ===============================================================================================================================
- ; #CONSTANTS# ===================================================================================================================
- ; In game hotkeys to prevent collision with script hotkeys.
- Global Const $hotKeySpell_1 = '{F5}'
- Global Const $hotKeySpell_2 = '{F6}'
- Global Const $hotKeySpell_3 = '{F7}'
- Global Const $hotKeySpell_4 = '{F8}'
- Global Const $hotKeyWeaponSwap = '{^}'
- ; Hotkeys used to toggle script commands. Not allowed to collide with in game hotkeys.
- Global Const $hotKeyUse_1 = 1
- Global Const $hotKeyUse_2 = 2
- Global Const $hotKeyUse_3 = 3
- Global Const $hotKeyUse_4 = "c"
- ; Animation Timers
- Global Const $tAttackBackSwing = 190
- Global Const $tWeaponSwapTime = 60
- Global Const $tInstantSpellBackSwing = 160
- ; Window handle string
- Global Const $sHwnd = "Elder Scrolls Online"
- ; ===============================================================================================================================
- ; #MAIN FUNCTION# ===============================================================================================================
- ; ===============================================================================================================================
- Local $hDLL = DllOpen("user32.dll")
- _main()
- DllClose($hDLL)
- ; ===============================================================================================================================
- ; #CORE FUNCTIONS# ==============================================================================================================
- ; ===============================================================================================================================
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _main
- ; Description ...: Contains main loop of the program including higher logic.
- ; Remarks .......: Runs script.
- ; ===============================================================================================================================
- Func _main()
- While 1
- ; Binds hotkeys while game window active.
- While _winActive($sHwnd) = True
- _bindHotKeySet()
- _chat()
- WEnd
- ; Undbinds hotkeys while game window is inactive.
- While _winActive($sHwnd) = False
- _unbindHotKeySet()
- WEnd
- ; Reduces CPU Load
- Sleep(10)
- WEnd
- EndFunc ;==>_main
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _bindHotkeySet
- ; Description ...: Binds script hotkeys to in game hotkeys.
- ; ===============================================================================================================================
- Func _bindHotKeySet()
- ; First Bar
- HotKeySet("{" & $hotKeyUse_1 & "}", "_attackHotKey_1")
- HotKeySet("{" & $hotKeyUse_2 & "}", "_attackHotKey_2")
- HotKeySet("{" & $hotKeyUse_3 & "}", "_attackHotKey_3")
- ;HotKeySet("{" & $hotKeyUse_4 & "}", "_attackHotKey_4")
- ; Second Bar
- HotKeySet("!" & "{" & $hotKeyUse_1 & "}", "_buffSpellHotKey_1")
- HotKeySet("!" & "{" & $hotKeyUse_2 & "}", "_buffSpellHotKey_2")
- HotKeySet("!" & "{" & $hotKeyUse_3 & "}", "_buffSpellHotKey_3")
- ; Misc Functions
- HotKeySet($hotKeyWeaponSwap, "_weaponSwapHotKey")
- ;HotKeySet("!e", "_attackHeavyHotKey")
- HotKeySet("{F9}", "_terminate")
- EndFunc ;==>_bindHotKeySet
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _unbindHotkeySet
- ; Description ...: Unbinds all hotkeys.
- ; Remarks .......: Add the hotkeys you want to undbind here.
- ; ===============================================================================================================================
- Func _unbindHotKeySet()
- ; First Bar
- HotKeySet("1")
- HotKeySet("2")
- HotKeySet("3")
- HotKeySet("c")
- ; Second Bar
- HotKeySet("!1")
- HotKeySet("!2")
- HotKeySet("!3")
- ; Misc Functions
- HotKeySet("!e")
- HotKeySet("{F9}")
- HotKeySet("{^}")
- EndFunc ;==>_unbindHotKeySetc
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attackHotKey_1
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _attackHotKey_1()
- _attack($hotKeySpell_1)
- EndFunc ;==>_attackHotKey_1
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attackHotKey_2
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _attackHotKey_2()
- _attack($hotKeySpell_2)
- EndFunc ;==>_attackHotKey_2
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attackHotKey_3
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _attackHotKey_3()
- _attack($hotKeySpell_3)
- EndFunc ;==>_attackHotKey_3
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attackHotKey_4
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _attackHotKey_4()
- _attack($hotKeySpell_4)
- EndFunc ;==>_attackHotKey_4
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attackHotKey_4
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _attackHeavyHotKey()
- _attackHeavy()
- EndFunc ;==>_attackHotKey_1
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _weaponSwapHotKey
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _weaponSwapHotKey()
- _weaponSwap($hotKeyWeaponSwap)
- EndFunc ;==>_weaponSwapHotKey
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _buffSpellHotKey_1
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _buffSpellHotKey_1()
- _weaponSwapInstantSpell($hotKeyWeaponSwap, $hotKeySpell_1)
- EndFunc ;==>_buffSpellHotKey_1
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _buffSpellHotKey_2
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _buffSpellHotKey_2()
- _weaponSwapBuff($hotKeyWeaponSwap, $hotKeySpell_2)
- EndFunc ;==>_buffSpellHotKey_2
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _buffSpellHotKey_3
- ; Description ...: WORKAROUND DUE TO HOTKEYSET DOES NOT ACCEPTING PARAMATERS.
- ; ===============================================================================================================================
- Func _buffSpellHotKey_3()
- _weaponSwapBuff($hotKeyWeaponSwap, $hotKeySpell_3)
- EndFunc ;==>_buffSpellHotKey_3
- ; #CORE FUNCTIONS# ==============================================================================================================
- ; ===============================================================================================================================
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attack
- ; Description ...: Performs a light attack plus an additional instant spell.
- ; Parameters ....: $hotKeySpell - The ingame keybinding of the spell.
- ; ===============================================================================================================================
- Func _attack($hotKeySpell)
- ; Initialising variables
- Local $timer = TimerInit()
- Local $state = 1
- If $fStateCritical = True Then
- ; Begin critical state
- $fStateCritical = false
- While TimerDiff($timer) < 1100
- If TimerDiff($timer) < 2 and $state = 1 Then
- _attackLight()
- $state = 2
- EndIf
- If TimerDiff($timer) > 300 and $state = 2 Then
- _castInstantSpell($hotKeySpell)
- $state = 3
- EndIf
- Sleep(10)
- WEnd
- ; Reset Variables
- $timer = 0
- $state = 1
- ; End critical state
- $fStateCritical = true
- EndIf
- EndFunc ;==>_attack
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attackLight
- ; Description ...: Performs a light attack.
- ; ===============================================================================================================================
- Func _attackLight()
- ; Uses global window handle string
- Local $sendHWND = _getHWnd($sHwnd)
- _SendMessage($sendHWND, $WM_LBUTTONDOWN)
- _SendMessage($sendHWND, $WM_LBUTTONUP)
- Sleep(10)
- EndFunc ;==>_attackLight
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _attackHeavy
- ; Description ...: Performs a heavy attack.
- ; ===============================================================================================================================
- Func _attackHeavy()
- ; Uses global window handle string
- Local $sendHWND = _getHWnd($sHwnd)
- _SendMessage($sendHWND, $WM_LBUTTONDOWN)
- Sleep(230)
- _SendMessage($sendHWND, $WM_LBUTTONUP)
- Sleep(190)
- EndFunc ;==>_attackHeavy
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _castInstantSpell
- ; Description ...: Performs an instant spell.
- ; Parameters ....: $hotKey - The ingame keybinding of the spell.
- ; ===============================================================================================================================
- Func _castInstantSpell($hotKey)
- _controlSend($hotKey)
- EndFunc ;==>_castInstantSpell
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _weaponSwap
- ; Description ...: Performs a weapon swap.
- ; Parameters ....: $hotKey - The in game keybinding of weapon swap.
- ; ===============================================================================================================================
- Func _weaponSwap($hotKey)
- _controlSend($hotKey)
- Sleep(10)
- EndFunc ;==>_weaponSwap
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _weaponSwapBuff
- ; Description ...: Swaps bars to perform an instant spell and swaps back.
- ; Parameters ....: $hotKeySwap - The in game keybinding of weapon swap.
- ; $hotKeyBuff - The in game keybinding of the spell.
- ; ===============================================================================================================================
- Func _weaponSwapBuff($hotKeySwap, $hotKeyBuff)
- ; Initialising variables
- Local $timer = TimerInit()
- Local $state = 1
- If $fStateCritical = True Then
- ; Critical state start
- $fStateCritical = False
- While TimerDiff($timer) < 1100
- If TimerDiff($timer) < 2 and $state = 1 Then
- _weaponSwap($hotKeySwap)
- $state = 2
- EndIf
- If TimerDiff($timer) > 200 and $state = 2 Then
- _castInstantSpell($hotKeyBuff)
- $state = 3
- EndIf
- If TimerDiff($timer) > 600 and $state = 3 Then
- _weaponSwap($hotKeySwap)
- $state = 4
- EndIf
- Sleep(10)
- WEnd
- ; Reset Variables
- $timer = 0
- $state = 1
- ; Critical state end
- $fStateCritical = True
- EndIf
- EndFunc ;==>_weaponSwapBuff
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _weaponSwapInstantSpell
- ; Description ...: Swaps bars to perform an instant spell and swaps back.
- ; Parameters ....: $hotKeySwap - The in game keybinding of weapon swap.
- ; $hotKeyBuff - The in game keybinding of the spell.
- ; ===============================================================================================================================
- Func _weaponSwapInstantSpell($hotKeySwap, $hotKeyBuff)
- ; Initialising variables
- Local $timer = TimerInit()
- Local $state = 1
- If $fStateCritical = True Then
- ; Critical state start
- $fStateCritical = False
- While TimerDiff($timer) < 1100
- If TimerDiff($timer) < 2 and $state = 1 Then
- _weaponSwap($hotKeySwap)
- $state = 2
- EndIf
- If TimerDiff($timer) > 200 and $state = 2 Then
- _castInstantSpell($hotKeyBuff)
- $state = 3
- EndIf
- If TimerDiff($timer) > 600 and $state = 3 Then
- _weaponSwap($hotKeySwap)
- $state = 4
- EndIf
- Sleep(10)
- WEnd
- ; Reset Variables
- $timer = 0
- $state = 1
- ; Critical state end
- $fStateCritical = True
- EndIf
- EndFunc ;==>_weaponSwapInstantSpell
- ; #INTERN FUNCTIONS# ============================================================================================================
- ; ===============================================================================================================================
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _chat
- ; Description ...: Unbinds all hotkeys on ENTER key press.
- ; ===============================================================================================================================
- Func _chat()
- ;0D = Enter Key
- ;IsPressed requires stop or long sleep to work properly.
- If _IsPressed("0D", $hDLL) Then
- _unbindHotkeySet()
- ToolTip("Chatmode on, Hotkeys unbound", 0, 990)
- _sleepTimer(500)
- Do
- _unbindHotkeySet()
- Sleep(10)
- Until _IsPressed("0D", $hDLL)
- ToolTip("")
- _sleepTimer(500)
- EndIf
- EndFunc ;==>_chat
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _winActive
- ; Description ...: Checks if a given window string is currently active.
- ; Parameters ....: $hWndString - String of the window handle to check.
- ; Return values..: True - Given handle is active.
- ; False - Given handle is inactive.
- ; ===============================================================================================================================
- Func _winActive($hWndString)
- Local $hWnd = WinGetHandle($hWndString)
- If WinActive($hWnd) = 0 Then
- Return False
- Else
- Return True
- EndIf
- EndFunc ;==>_winActive
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _getHwnd
- ; Description ...: Returns the hex PID of a given handle string.
- ; Parameters ....: $hWndString - String of the handle to process.
- ; Return values..: $hWnd - PID (hex)
- ; ===============================================================================================================================
- Func _getHWnd($hWndString)
- Local $hWnd = WinGetHandle($hWndString)
- Return $hWnd
- EndFunc ;==>_getHWnd
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _terminate
- ; Description ...: Terminates the script.
- ; ===============================================================================================================================
- Func _terminate()
- Exit 0
- EndFunc ;==>_terminate
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _pause
- ; Description ...: Pauses the script.
- ;; ===============================================================================================================================
- Func _pause()
- While 1
- Sleep(100)
- WEnd
- EndFunc ;==>_sleep
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _controlSend
- ; Description ...: Sends a keystroke to a window handle.
- ; Parameters ....: $hotKey - Key to send.
- ; ===============================================================================================================================
- Func _controlSend($hotKey)
- Local $sendHWND = _getHWnd($sHwnd)
- ControlSend("", "", $sendHWND, $hotKey)
- EndFunc ;==>_controlSend
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _msg
- ; Description ...: Opens a message box with a given string.
- ; Parameters ....: $sText - String that should be shown in the box.
- ; ===============================================================================================================================
- Func _msg($sText)
- MsgBox(0, "Debug", $sText)
- EndFunc ;==>_msg
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _sleepTimer
- ; Description ...: Advanced sleep function to minimize script lock time.
- ; Parameters ....: $tLength - Length of the Sleep time in MS.
- ; ===============================================================================================================================
- Func _sleepTimer($tLength)
- Local $timer = TimerInit()
- While TimerDiff($timer) <= $tLength
- Sleep(10)
- WEnd
- EndFunc ;==>_sleepTimer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement