Ok, thanks for explanation. I get it and it makes perfect sense. You are right, automated positioning can mess you up but is often good for me because I absolutely lack skill (I suck at FPS games).
This style of coding is to professional for me
Why do you start with
send {blind}{shift up}
? Looks really hacky. But Iām sure thereās a reason (you were talking about problems with shift before)
In Grim Dawn I personally donāt have problems with attack skills (i.e. Primal Strike) on Left Click and moving + fighting with the same key. However in Diablo 3 I remember having scripted Force Move if I hold the button and standard click if I donāt. It was simple
LButton::
Click
KeyWait, LButton, T0.2
if ErrorLevel
{
while GetKeyState("LButton", "P")
{
Send {%forceMove%}
Sleep, 100
}
}
Return
I was thinking about detection too some time ago but I donāt think itās possible (at least for me).
As far as Capslock + Event mode are concerned, Iāve got no clue but I also havenāt really looked much into it
I had problems to achieve the following in AHK (at the same time):
- you hold left button and then you start hold right button -> you move but movement skill is used when itās not on cooldown
- you hold right click (movement skill should be cast when not on cooldown) and then you start holding the Left Click -> you should also move and use movement skill when itās not on cooldown
(I like holding button instead of clicking it from time to time)
For some reason Right and Left Click block each other and there was always something wrong no matter how I wrote it (but of course I didnāt try really complicated stuff like you) but if you use Space there are no problems. For example you stopped moving or movement skill didnāt work.
its not āneededā for the script to fuction, but that line solved some problems i coudnt nail down exactly with modifier keys i had in several games/scripts in situation where framerates went down.
(see also down / downtemp and downr)
Since it doesnt hurt (at least i think it doesnt), i put it as prophylaxis
about blind: if you have something like send a
, ahk does internally (re)sets the modifier keys for that send to get an āaā and not A or ctrl-a etc in case modifier keys are active while that send happens.
Means thers alot of status changes, that are not needed, because the game reads the raw key anyway.
TL;DR
blind reduces the āspamā = less chance for stuff gets fucked up. (could als try to send it as keycode)
yea, (im also lazy and tend to prefer the same:) ) - hmm, ill try to fiddle around that next days, but not now. just spend the last days with finetuning and rewriting the script (the timer section needs a comple rewrite with proper timer management and a s function, not as simple subroutines) so i actually want to play the game the next free hours
but that problem hooked me, so , lets see
ps: can you tell me what skill/stuff is bound to L/Rbutton to get a proper impression?
More details
On right click I would like just the movement skill
but on left click I have Primal Strike, Wind Devils are cast automatically when I hold left click and also 2 other skills are cast when I hold Left Click and Shift at the same time (I have already scripted it)
I think itās impossible. Movement stops when you hold Right Button and thereās nothing to be done about it? This is even without any scripts.
ad hoc (aka not thinking involved yet) , you could set the āotherā button to up while doing stuff and set it down afterwards.
ad hoc2: while holding lbutton (moving/attacking/whatever) i let my char cast aoe leech dot + centered inq seal + optional stuff, then, when sequence finished just continue running etc. before i fixed it, it always stopped after the castsequence (bc i had to bolck input while center casting) even though the lbutton was kept pressing. it sounds similar at least. - but need to think through.
p.s means - while you hold rightbutton put soemthing like below in the rbutton hotkey at the end
if GetKeyState("LButton", "p")
{
send, {Lbutton down}
}
return
looks odd at the first moment, pressing a key that is pressed already, but it actually solves things. it will reset the keystatus for the game as nothing happened. and your char should continue running etc.
*or vice versa
Tried it, it doesnāt work.
Right Click + Left Click just donāt work in Grim Dawn on a deeper level than AHK I think.
I even tried
*RButton::
Send {4}
send {LButton down}
Return
However I think the following worked (or maybe I just imagined that it worked?):
- rebinding Right Click to some other key in your mouse software
i tend to agree, but cant say anything further about it unless i actually tried the exact problem in ahk. atm it would only be speculation. i know that i tried combining both buttons like you did, in a similar way in some early script versions but didnt find any solution, got annoyed and used an alternative solution. though forgot yet the details
eg the ā~ā hotkey modifier is a game changer in some scenarios (and theres so much detail that matters for the outcome), so its really hard to generally predict
Trying it with ~ was the first thing I did of course
~ is beautiful
What about this code. Doesnāt it work either?
~*LButton & RButton::
MsgBox You pressed RButton while holding down LButton
Thanks for help but weāre trying to do something else. In Grim Dawn, without any scripts, when you use Right Click skill by holding the button, movement on Left Click stops and vice versa. This is an in-game problem that doesnāt seem to have any solution. I want to have to native skills/actions of Right Click and Left Click active when I hold these button together (i.e. running + movement skills when itās not on cooldown when holding two mouse buttons). And it has to work both ways - when you first hold LMB and then RMB and vice versa (I think I achieved one direction with some code). The only solution Iāve found (if I remember correctly) was remapping Right Click to some other key in Mouse Software, not in AHK.
But you know what? Iāll test your code because honestly I havenāt used this method but I donāt have high hopes.
For your case RButton needs to have tilda too . Like
~*LButton & ~*RButton ::
First tested
~LButton & ~RButton::
MsgBox, test
Return
~RButton & ~LButton::
MsgBox, test2
Return
To check whether these hotkeys activate and they do. Then I deleted MsgBox:
~LButton & ~RButton::
Return
~RButton & ~LButton::
Return
and unfortunately it doesnāt work. I never moves and jumpes āat the same timeā when you holding LMB + RMB. Only once action depending on last clicked button. It just doesnāt work using conventional methods. Iāll try one more thing and then I give up.
Ok. Thanks, I made it work perfectly! Itās ugly though. @ncience
LButton & RButton::
while GetKeyState("LButton", "P") and GetKeyState("RButton", "P")
{
Click
Click, Right
Sleep, 100
}
while GetKeyState("LButton", "P")
{
Click
Sleep, 100
}
while GetKeyState("RButton", "P")
{
Click, Right
Sleep, 100
}
Return
RButton & LButton::
while GetKeyState("LButton", "P") and GetKeyState("RButton", "P")
{
Click
Click, Right
Sleep, 100
}
while GetKeyState("LButton", "P")
{
Click
Sleep, 100
}
while GetKeyState("RButton", "P")
{
Click, Right
Sleep, 100
}
Return
Imma use it from now on in my script unless someone finds something neater.
GZ! tenacity always pays!
if its ugly or not is just the B-Score, once you have something working the beautifying of code comes by time
just back from errands, guess what, i had an ahk loop in my head about that problem, but now you got it running, i can cast a break - prob ppl like me have, that they have hard time to switch focus, once hooked. - want to play the game now for 2 days and havent killed one mob yet
but ill be definitely trying to find an alternative method over the weekend (and im sure there is)
Iād like to inform that Iām going back from
SetTitleMatchMode, 3
#IfWinActive, Grim Dawn
to
Loop
{
Sleep, 1000
if WinActive("Grim Dawn", , "Grim Dawn ")
{
if hotkeys_turned_on
continue
}
else if !hotkeys_turned_on
continue
hotkeys_turned_on ^= true
Suspend, Toggle
}
because stopped working (reliably or at all) for me again whereas the second version has always worked without any problems.
that # directive only works for included (location in the script) hotkeys and hotstrings, not for other stuff thats running!
official:
Creates context-sensitive hotkeys and hotstrings. Such hotkeys perform a different action (or none at all) depending on the type of window that is active or exists.
&
its positional: it affects all hotkeys and hotstrings physically beneath it in the script. #If and #IfWin are also mutually exclusive; that is, only the most recent #If or #IfWin will be in effect.
thats why u should use either the #if / #ifwin.. (expression)
directive for the hotkeys or if
with the winactive()
function for all other stuff.
tip: since you use the first parameter (wintitle, not wintext) you can use
ahk_exe Process Name/Path
to foolproof specify the target. So no more errorneus behaviour if your script is named Grim Dawn too or have an BrowserTab with that title
update:
you motivated me to revisit my forcemove while having a target attacking.
formerly i did that by triggering a timed event in Rbutton hotkey (see above)
now i did something different and i like it (moar):
LButton & RButton::
;send {Rbutton up}
;thats an interesting one: seems to be the only method to 'hide' it from the game, the game gets the physical r click.
;but you (logically) lift it so fast again, that the bound action is discarded by the game (myguess). got the acton oppressed for like ~ 50% of the times, so its not reliable (yet)
;UPDATE: its even mandatory to uncomment, if you dont have a hotkey for Rbutton. Seems to be a big difference if its hooked or not. So things are complicated
while GetKeyState("LButton", "P") && GetKeyState("RButton", "P") && !GetKeyState("SHIFT", "p") ;&& (stopped = 0)
{
send {Lbutton down} ;mandatory!
send {blind}{f down} ;forced move
sleep, 100
}
send {blind}{f up}
;send {Lbutton up} <- if uncommented, you have to reattach the target by physically lift the Lmouse button and reclick it, w/o it just continues attacking
return
so, what is it?
its blue light
yes, but what does it do?
it shines blue ā¦ err ā¦ :
you attack stuff via Lbutton (no modifiers, no hold position), when additionally pressing Rbutton and hold, it switches immediately (but with 1x executing the in game bound Rbutton action, hard to supress. but its in my case even beneficial) to force move as āmove toā would have been bound to Lbutton
if you keep holding Lbutton and release Rbutton it instantly continues attacking.
formerly i had:
~Lbutton::
gosub, Lbuttonparallelaction
return
..
.. other code
..
Lbuttonparallelaction:
IfWinActive, %clientstring%
{
While ( GetKeyState("LButton", "p") && !GetKeyState("RButton", "p") && (stopped = 0))
{
if (onsleep = 0) ;is timer free?
{
SetTimer, reapspirit, -20 ;we need it as a seperate thread
}
sleep, %sleepvalue%
if (onsleep_2 = 0) ;is timer free
{
SetTimer, stormbox, -20: same here
}
sleep, 200 ;
}
;~ While ( GetKeyState("LButton", "p") && GetKeyState("RButton", "p") && (stopped = 0))
;~ {
;~ send {blind}{f down} ;move to
;~ }
;~ send {blind}{f up}
}
return
that worked too, but i neither like the desgn nor the fact that but the walk stuff is in the same thread.
first solution is its own thread and feels more responsive too.
so one problem for AHK is, as already stated, that it cant hide the mousebuttons from the game. at least im not aware of any method (the hook, admin rights or not, doesnt block it) so if we need in whatever case to hide the buttons from the game, it has to be done by the underlying mousedriver remapping or similar level tool afaik.
Would you mind explaining what it could possibly help with?