Ok, here’s a simpler, shorter, tested and better version (no need to wait 10 seconds between Pause/Unpause) but still need to Pause if you want to Alt+Tab and then Unpause. Again, don’t read into Main Loop hack too much. All it does in Suspend On + Off once when Grim Dawn becomes active so that hotkeys (Pause in this example) is not suspended (?)
#Persistent
#NoEnv
#SingleInstance Force
#MaxHotkeysPerInterval 1000
#MaxThreadsPerHotkey 1
#HotkeyModifierTimeout -1
#KeyHistory 50
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 3
Menu, Tray, Icon , *, -1, 1
global game_window_id := "ahk_exe Grim Dawn.exe"
global skill_buttons := ["1", "2"]
global skill_delay := 12000
global game_paused := false
global time_to_next_cast
global moment_of_last_cast
global next_skill_index := 1
SetTimer, CastSkill, -1
global hack_applied := false
SetTimer, MainLoop, 1000 ;hack for making PAUSE button work, bug or sth
MainLoop()
{
if (WinActive(game_window_id))
{
if (!hack_applied)
{
Suspend, On
Suspend, Off
hack_applied := true
}
}
else
hack_applied := false
}
CastSkill()
{
if (WinActive(game_window_id))
send % skill_buttons[next_skill_index]
moment_of_last_cast := A_TickCount
next_skill_index ^= 3 ; toggles between 1 and 2, xor bitwise operation
SetTimer,, -%skill_delay%
}
~P::
if (!WinActive(game_window_id))
Return
game_paused ^= 1 ;toggles between 0 and 1, xor bitwise operation
if (game_paused)
{
SetTimer, CastSkill, Off
time_to_next_cast := skill_delay - (A_TickCount - moment_of_last_cast)
}
else
SetTimer, CastSkill, -%time_to_next_cast%
Return
If you haven’t got a chance to learn Exclusive Or
1 ^ 3 = 2
2 ^ 3 = 1
1 ^ 1 = 0
2 ^ 1 = 3
etc, instead of next_skill_index ^= 3
you can always write next_skill_index = next_skill_index = 1 ? 2 : 1
or just
alright.
still confused about xor, although I´ve learned about it, some years ago.
When my 2 skills are on buttons 4 and 5 for example, do i need to change the xor part?
no, no, you only need to change this line
the index from the rest of the code is just a position on this list
for example if you changed it to [“5”, “4”] then
skill_buttons[1] equals “5”
and
skill_buttons[2] equals “4”
and these 1 and 2 are indexes which are changed throughout the code
I would like to recommend you the following hotkey
LButton & RButton::
Send % 6
Return
If for example you
move with LMB
attack with RMB
have a movement skill on 6
then after pressing RMB while holding LMB you trigger the movement skill and RMB spam begins after that if you keep RMB pressed down. If you don’t want to use the movement skill, you simply release LMB before pressing RMB.
It’s very comfy and great for other stuff like casting debuff on monsters before the fight or even some more complicated things like spamming some skills on cooldown until you i.e. release LMB/RMB/LMB+RMB.
FYI to my surprise autocasting works with a controller as well.
If for example 5 is automatically pressed, then the skill that is fifth on the hotbar in the gamepad mode is casted automatically.
However it may only works well with auras like Blood of Dreeg because when I tried to autocast Forcewave, gamepad buttons blocked till I pressed them again.
Maybe sending Joy1, Joy2, … instead of 1, 2, 3 would work better but I haven’t tested it properly yet.
Is BoD also set to the 5 on the non-controller layout? What might actually be happening is the moment you press the key GD automatically reverts to keyboard mode and something like…
…that might indeed be what you’d have to look into doing. Would certainly be interesting to have a controller version to extend the capabilities for people more.
Fortunately it doesn’t revert because if it would like when you move the cursor it would suck.
BoD is not on the non-controller hotbar, I even put other skill there to be sure.
Also tested it with Field Command.
However when I put DEE there, the character stops moving when the buttons is pressed (hotbar still doesn’t revert) and you have to press controller button to fix it.
So it only works without issues with auras.
I tested script that sends Joy1 to Joy9 and nothing. It’s not that easy I think. You probably need stuff like https://sourceforge.net/projects/vjoystick/ or something like that. I don’t think I’ll be exploring this subject any time soon since auras autocasting is the most important for me and my current char that I’m gonna devote my time to and fight with my altoholism together with doesn’t use many skills.
Hey there! Trying to implement this. Wont work as intended. The items dont hide, they flicker as long as lmb is pressed. I think Id need a solution where Lalt is pressed only once as long as lmb is pressed. Any ideas?
Even if we fix it (although I don’t think I hade this problem) there’s another issue is that if you press it multiple times in a row then the message buffers for a long time and is display many times over a long period of times.
When you toggle/hide items multiple times in a second, it’s also like that.
I have a much more advanced version of this that attempts to fix this problem but maybe let’s try fixing yours
First of all - your script works perfectly for me so
What is bound to LAlt in in-game keybindings and what is bound to plain Alt. Please check it if it’s really Toggle Display Items and if maybe just plain ALt is not bound to anything and it causes the problem
The timer doesn’t get overwritten (and is executed incorrectly multiple times) as it is the case with simple
SetTimer, Show, -%hide_duration%
How GDAutocaster was working well using it incorrectly I do not know since I use this dynamic method of creating timers with arguments in every class / feature multiple times although not always with the intention of overwriting timers but certainly at least in some places.
The camera being a bit “borked” is the most off putting thing for me, I already have GrimCam and customized it but…
Whenever I hold the middle mouse button to rotate the camera, and use A to walk (I try to make the camera follow the character, or rather, using it for the direction she/he should go to whilst holding A), but if you hold the camera rotate, the character won’t follow the camera facing whilst holding A to walk.
I can send you sample program for automatic camera rotation with instruction
(compiled .exe so that you don’t have to bother with AutoHotkey)
if you happen to like it (maybe after some tweaks because it can be configured according to personal preferences) then I can merge it into GDAutocaster I’ve linked above because it’s the program I put all the scripts and features to
Also GDAutocaster has Fast Keyboard Camera rotation feature:
you presss a button and camera rotates quickly by choses degrees, i.e. 60 degress
Automatic Camera I didn’t merge into GDAutocaster because I don’t use it personally and only have one other person using it that writes scripts on his own