Need help with AHK grouping script

Ask gaming related questions (AHK v1.1 and older)
rainrain
Posts: 45
Joined: 20 Jan 2022, 00:17

Need help with AHK grouping script

Post by rainrain » 08 Feb 2023, 04:33

[Mod edit: Topic was moved from "Scripts and Functions > Gaming".]

Hello, basically I have a script with two ahk groups, I'm trying to have it to share the same function. However some keys for the group "ext" stopped functioning, I guess it's due to duplicate keys from group "gw2"

I wanted group "ext" to function the commands when in "action camera mode" and return to its original function when out of "action camera mode"

Wheelleft:: and XButton1:: xbutton2:: being duplicated and override

Code: Select all

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetWinDelay, -1
SetControlDelay, -1
settimer, check, 100
DllCall("ntdll\ZwSetTimerResolution","Int",5000,"Int",1,"Int*",MyCurrentTimerResolution)

GroupAdd, gw2, Guild Wars 2                                    ;GroupAdd Gw2
GroupAdd, gw2, `.00

GroupAdd, ext, `.01                                            ;GroupAdd Ext


VarSetCapacity(active_cursor,A_PtrSize+16)                     ;Gw2 Action Camera

mouse_button_right := "f1"
mouse_wheel_up:="8"
mouse_wheel_down:="7"
mouse_wheel_left:="8"

;#If (WinActive("ahk_group gw2") AND WinActive("ahk_exe Gw2-64.exe"))
#IfWinActive ahk_exe Gw2-64.exe                                ;Gw2 Action Camera

RButton::
if GetKeyState("LButton","P") and !Action_Camera_LMB
allow_key("RButton","down")
else if Check_Cursor(active_cursor) = 0 {
allow_key(mouse_button_right,"down")
Action_Camera_RMB := true
}
else
allow_key("RButton","down")
return

RButton up::
if Action_Camera_RMB {
allow_key(mouse_button_right,"up")
Action_Camera_RMB := false
}
else
allow_key("RButton","up")
return

WheelUp::
if Check_Cursor(active_cursor) = 0 {
Send, {%mouse_wheel_up%}
}
else
Send, {WheelUp}
return

WheelDown::
if Check_Cursor(active_cursor) = 0 {
Send, {%mouse_wheel_down%}
}
else
Send, {WheelDown}
return

Wheelleft::
if Check_Cursor(active_cursor) = 0 {
Send, {%mouse_wheel_left%}
}
else
Send, {Wheelleft}
return

Wheelleft up::
if Action_Camera_RMB {
allow_key(mouse_wheel_left,"up")
Action_Camera_RMB := false
}
else
allow_key("Wheelleft","up")
return

allow_key(key,state) {                                         ;Gw2 Action Camera
global
Send,{Blind}{%key% %state%}
if !WinActive(GMWI) {
Critical,Off
KeyWait,%key%
Send,{Blind}{%key% up}
}
return
}
Check_Cursor(ByRef cursor) {
NumPut(A_PtrSize+16,cursor)
DllCall("GetCursorInfo","uint",&cursor)
return NumGet(cursor,4)
}                                                              ;Gw2 Action Camera

xbutton1::send {]}{\}                                          ;Gw2 Target
xbutton2::send {[}{\}

check:                                                         ;Else If ahk_group ext
    (id := WinExist("ahk_group ext"))
        MouseGetPos,,,Win
return
#If (Win == id)

XButton1::
send {click}
send {enter}
return

XButton2::i

F7::Esc


Wheelleft::                                                  ;chest
send {click}
send {Click, 1840, 2000, right}
MouseMove, 1710, 1975
sleep 400
Send !{F4}
return

rainrain
Posts: 45
Joined: 20 Jan 2022, 00:17

Re: Need help with AHK grouping script

Post by rainrain » 08 Feb 2023, 04:57

I would like Xbutton1 in ahk_group ext to function as "send {[}{\}" when in action camera mode, but when it's out of action camera mode, I would like it to send XButton2::i instead

User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

Re: Need help with AHK grouping script

Post by mikeyww » 11 Feb 2023, 08:23

Code: Select all

#Requires AutoHotkey v1.1.33
GroupAdd g1, ahk_exe notepad.exe

actionCam := True
actionCam := False

#If WinActive("ahk_group g1") && actionCam  ; When actionCam is true
XButton1::Send 123

#If WinActive("ahk_group g1")               ; When actionCam is false
XButton1::Send 456
#If

Post Reply

Return to “Gaming Help (v1)”