PDA

View Full Version : AutoHotKey HotBar Manager



Amundir
01-12-2017, 11:45 PM
The following is a script that is written to work with AutoHotKey, software which allows you to target inputs from the user from the keyboard, mouse, or otherwise and cause other things to happen as a result. For instance, using AutoHotKey you could make it so that if you hit Ctrl+Shift+F that Firefox would open a new window. It is really open ended to whatever you want it to do.

This script is written for DDO with hotbar actions in mind.
Maybe you are a cleave machine that cycles through cleave, great cleave, momentum swing, lay waste, and other skills that grant extra +W damage when used.
Maybe you are a spell caster who has certain spells you like to cycle through.
Or maybe you have skills that can buff you, but have to be renewed after a certain amount of time.

In those cases, managing the cooldowns on the skills is important. This script is intended to give you an extra tool towards improving this management. You get to define what actions you want to execute, in what order they should execute, and tell it how long the action will be on cooldown before it can be used again. The script will look from top to bottom for the first action that is not on cooldown any longer and will execute it once again.

I've used a form of this for a while and only recently modified it to be in this more flexible state. I can say without a doubt not having to worry so much about cooldown management is something I greatly appreciated. I hope if you are one of those people who is a hotbar action using maniac, you will give it a try and see what you can make it do for you.

So anyways, how does it work and what do you need? Well, first you need AutoHotKeys.
https://www.autohotkey.com/
This script was written with the latest version(1.1.24.04) which you can download from their site. It's freeware.

Once you get that installed, all you have to do to create an AutoHotKey script is open up your favorite text editor and save a new file as "something.ahk" (personally I like to have one per character so I name them after my character so I know which is which). Once you do that, the file will be recognized as an AutoHotKey script and double clicking it will cause the script to start. Once it starts you will see a little green box with an `H` in it in your taskbar. Right clicking on that taskbar icon will give you some options, such as being able to Exit the script.

Now, once you got that down, you're ready to use the AutoHotKey HotBar Manager script.




; Text on a line after a semi-colon is a comment and ignored
; Only allow a single instance of the script to run
#SingleInstance Force
TheScriptIsEnabled := false
WhenTheLeftMouseButtonWasClicked := 0
HotbarActions := []

;PURPOSE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; * The purpose of this script is to help manage the use of common actions performed by a
; character during battle, by executing skills as they come off of cooldown as soon as
; they are available.
; * To toggle the script enabled/disabled simply hit the `Pause` button on your keyboard.
; * To terminate the script hit Shift+Esc.
; * When enabled the script will wait for the user to hold down the left mouse button for
; a specified amount of time before beginning to cycle through the defined actions.
;END;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;CHARACTER SETTINGS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; * Edit the following to customize the script for your character.
; * The order of hotbar actions is the order in which the script will try to execute
; them, so put them in whatever order you feel will maximize your experience.
; * You can include all or none of the optional variables when defining your hotbar
; actions. The variables between the `{}` can be in any order you wish.
;
; The following is the amount of time (in milliseconds) that the script will wait after
; you have begun to hold down your left mouse button before starting to cycle through the
; hotbar actions. This is to try to help distinguish between actual battle vs simple
; single clicks.

TheDelayBeforeStarting := 1000


; The following specifies your primary hotbar. This is the hotbar you typically keep in
; focus while you play. If you are not sure which one this is, when you hit a number it
; should try to execute one of your actions on one of your hotbars. The hotbar that
; contains the action executed by you hitting a number is your primary bar. The primary
; bar will be switched to each time the script starts evaluating the held left mouse
; button and, in the case that a defined hotbar action specifies that it is on another
; hotbar, the primary hotbar will be switched back to after that action has been executed.

PrimaryHotbar := 1


; Most actions have some sort of animation that happens before the next action can start.
; Outside of the script this is not an issue, but with the script trying to keep track of
; when an action was last executed, actions being delayed due to stacking of animations
; can potentially be an issue. To address this the script will wait the following amount
; of time (in milliseconds) before trying to find the next action to execute. Adjust this
; if the majority of your animations are longer/shorter.

AnimationDelay := 700


; The following details the options for defining a hotbar action.
; Action[required] - The number you would normally hit to activate the action on the
; hotbar.
; Cooldown[required] - The amount of time (in milliseconds) the action must wait before
; being executed again.
; Hotbar[optional] - The hotbar that the action is on.
; Delay[optional] - The amount of time (in milliseconds) to add to the AnimationDelay
; after executing an action to allow for the animation to finish. A negative value
; will reduce the delay.
; LastUsed[required] - A variable used to keep track of when the action was last executed.
; This should always be zero.

; Example - copy, paste, and edit the text after the `;` to define a hotbar action
;HotbarActions.Push({ "action": 2, "cooldown": 7000, "hotbar": 2, "delay": 200, "lastUsed": 0 })
; Example - you can also send non-hotbar commands, such as the left alt button for firing a rune arm
;HotbarActions.Push({"action": "LAlt", "cooldown": 3000, delay: -500, "lastUsed": 0})



HotbarActions.Push({"action": 0, "cooldown": 3000, "lastUsed": 0})
HotbarActions.Push({"action": 6, "cooldown": 3000, "lastUsed": 0})
HotbarActions.Push({"action": 7, "cooldown": 10000, "lastUsed": 0})
HotbarActions.Push({"action": 8, "cooldown": 15000, "lastUsed": 0})

HotbarActions.Push({"action": 7, "cooldown": 15000, "hotbar": 6, "lastUsed": 0})



;END;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Do not edit any of the following unless you know what you are doing, \,,/(^_^)\,,/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Enable/Disable the script
~*Pause::
TheScriptIsEnabled := ( TheScriptIsEnabled == false )
return

; Terminate the script
+Escape::
ExitApp
return

#IfWinActive, Dungeons and Dragons Online

~*LButton::
if ( TheScriptIsEnabled ) {
WhenTheLeftMouseButtonWasClicked := A_TickCount

LoopActionsWhileLeftMouseButtonIsClicked()
}
return

#IfWinActive

LoopActionsWhileLeftMouseButtonIsClicked() {
global TheDelayBeforeStarting
global WhenTheLeftMouseButtonWasClicked

while GetKeyState( "LButton" ) {
if ( WhenTheLeftMouseButtonWasClicked + TheDelayBeforeStarting < A_TickCount ) {
SwitchToHotbar( PrimaryHotbar )
Sleep ExecuteFirstActionNotOnCooldownAndReturnDelay()
}
}

return 0
}

ExecuteFirstActionNotOnCooldownAndReturnDelay() {
global AnimationDelay
global HotbarActions
global PrimaryHotbar

DelayAfterLoopFinishes := AnimationDelay
ShouldSwitchBackToPrimaryBar := false

Loop % HotbarActions.MaxIndex() {
if ( HotbarActions[ A_Index ].lastUsed + HotbarActions[ A_Index ].cooldown < A_TickCount ) {
if ( HotbarActions[ A_Index ].HasKey( "delay" ) ) {
if ( AnimationDelay + HotbarActions[ A_Index ].delay >= 0 ) {
DelayAfterLoopFinishes := ( AnimationDelay + HotbarActions[ A_Index ].delay )
} else {
DelayAfterLoopFinishes := 0
}
}

if ( HotbarActions[ A_Index ].HasKey( "hotbar" ) ) {
SwitchToHotbar( HotbarActions[ A_Index ].hotbar )
ShouldSwitchBackToPrimaryBar := true
}

action := HotbarActions[ A_Index ].action
SendInput {%action%}
HotbarActions[ A_Index ].lastUsed := A_TickCount

if ( ShouldSwitchBackToPrimaryBar ) {
SwitchToHotbar( PrimaryHotbar )
}

break
}
}

return DelayAfterLoopFinishes
}

SwitchToHotbar( ByRef HotBarNumber ) {
SendInput {Blind}^{%HotBarNumber%}
}



I tried to include very detailed comments concerning the settings that you can change and how you can define your hotbar actions. If you have questions though feel free to ask.

Amundir
01-12-2017, 11:46 PM
[2018-06-23] Added example of adding a Left Alt press to the mix. Useful for Artificers who want to automate their rune arm firing during battle.

Amundir
06-23-2018, 01:09 PM
Updated to include example of adding a non-hotbar action into the mix.

Sam-u-r-eye
07-23-2018, 08:03 AM
nj dude

cccddd
04-09-2019, 06:09 AM
that sounds so useful but i have 0 script writing know how. r there any hope for me to get this to work?

TitusOvid
04-09-2019, 11:00 AM
that sounds so useful but i have 0 script writing know how. r there any hope for me to get this to work?

Well, you have to study his script to understand it. His comments are very detailed. If push come to shove, you need to find someone to explain it to you or research the commands on the net yourself.

Maybe you can write your own, much simpler, script.

Amundir
04-23-2019, 03:39 PM
The only part of the script you really need to worry about changing is the HotbarActions, as detailed in the script.

So lets take a super simple example. Monk fists. Most monk elemental fists have a 6 second cooldown. So lets say you wanted to setup the script to kick off a monk fist every 6 seconds while fighting. First thing you would need to do is take that feat option and drag and drop it onto your hotbar, which you're going to have done anyway as you'd need to have it on a hotbar to use it during a fight. So lets say you did that and you put it on your primary hotbar in slot 0 (the one on the far right). So you've put that ability on your primary hot bar in action 0. You can confirm this by hitting the number 0 and it should execute the action (provided you have enough ki).

So to automate that action, you'd have to add the following to the script, in the area where the example ones are:

HotbarActions.Push({"action": 0, "cooldown": 6000, "lastUsed": 0})

That adds the action to the script, telling it that it should execute action 0 on your primary hotbar, and that it has a 6 second cooldown. Once you save the file with that, and start/reload the script, the action will be available to be automated once you hit the Pause/Break key to toggle the script on (as detailed in the OP).

It's really as simple as that. You just have to drag your actions to your hotbars, keep track of which hotbar they are on, what # you would normally hit to execute them, what the cooldown is, and setup an action in the script for that. If the action has a longer animation that normal, you may have to add a delay to the action (as detailed in the OP) to keep actions from stepping on each other, but at that point it's really just about playing around with the delays and such to get it just right.

Amundir
04-23-2019, 03:54 PM
If it would be useful, I may make a twitch video showing and example of setting it up from scratch.

Amundir
04-23-2019, 08:02 PM
https://www.twitch.tv/videos/415508800

Here you go. Hope it's not a terrible overview and is helpful.

Pilgrim1
04-24-2019, 12:36 AM
I use auto hotkey to.

I have a mouse with 2 thumb buttons, they are on the side of the mouse and typically are designed to navigate forward and backwards in a web page. I also have a scroll wheel on my mouse.

This is how i bind my hotkeys in DDO

Numbers 1 through 0 are standard hotkey related to my active hotbar.
hold the scroll wheel down and press 1 through 0 and the activate the row above my standard hotbar.
then i use the thumb mouse buttons to do the same thing for the next 2 rows of hotbars.

DDO does not reconize the thumb bars on the mouse (it does the wheel bar) so thats where auto hotkey comes in.

This is my super-uber-self-made-super-difficult-script!!!1!!

XButton1::Ctrl
XButton2::Alt
Return


Vrrrooom! Now my thumb can triger alt and ctr buttons. Bind alt + 1, alt +2, alt +3, extra. And do the same for control.

4 active hotbars! Wizards are a sinch to play now!

PS. I also have my number pad control which hotbar is active. My defalt is 0 because i can hit it in a pinch, but when i go to buff people i hit the numberpad 3 or numberpad 4 and get new rows of shinny buff spells. these hotbars stay hidden most of the time but can easly be brought up in a hurry. It also means that every spell/item is just 2 taps away. Need to ress someone? thats Number pad 9 then 0 to cast my scroll/ress, then number pad 0 to bring back my defalt. Works really well for me.

EDIT: for thoes of you who know next to nothing about scrip writing, do the following: (1) Download auto hotkey, (2) make a new auto hotkey script (it opens a text document in windows), (3) copy the 3 lines into auto hotkey, (4) save, (5) run it when you want to play DDO. O, and edit the DDO hotkey setups, the scroll wheel can be used as a "modifier" in DDO.