1 (изменено: bloodytearsx, 2022-05-20 14:44:17)

Тема: AHK: колесико мыши

Как в этом скрипте сделать так, что бы у прокрутки колесика было кд? при быстром скролле колесика в игре не засчитывает комбинацию (левая кнопка мыши, прокрутка колесика) а именно не засчитывает левую кнопку мыши.

;=============================================
; name:    eso_auto_weaver
; version: 1.3
;=============================================

; script is disabled by default -- to enable caps lock most be toggled ON
; some menus will auto disable (untoggle) to allow for numeric inputs

#SingleInstance, force
#NoEnv

#UseHook
#InstallMouseHook
#InstallKeybdHook

SendMode Input
SetWorkingDir %A_ScriptDir%

;=============================================
; configuration
;=============================================

; input delays and timers
global la_delay := 180
global cn_delay := 500
global bl_delay := 50

; global cooldown ticker
global cd_timer := 900
global cd_delay := cd_timer - (la_delay + cn_delay + bl_delay)

; skill keys configured in array for [skill], [shouldWeave] & [shouldCancel]
global SkillKeys := [{skill: "1", weave: 1, cancel: 1}, {skill: "q", weave: 1, cancel: 1}, {skill: "WheelUp", weave: 1, cancel: 0}, {skill: "e", weave: 1, cancel: 1}, {skill: "f", weave: 1, cancel: 1}]

;=============================================
; primary script & input loop
;=============================================

; only capture keys when game window is running
#ifWinActive Elder Scrolls Online

Hotkey, 1, Weave_1, On
Hotkey, q, Weave_2, On
Hotkey, WheelUp, Weave_3, On
Hotkey, e, Weave_4, On
Hotkey, f, Weave_5, On

loop,
{
	; Input, in_key, L1 V ; no longer used [retained for future]
	; disable autoweaving in menus
	if(GetKeyState("I") || GetKeyState("M") || GetKeyState("J") || GetKeyState("O") || GetKeyState("Esc")) {
		SetCapsLockState , off		
	} 
	
}

Return

Weave_1:
    AutoWeave(SkillKeys[1].skill, SkillKeys[1].weave, SkillKeys[1].cancel)
Return

Weave_2:
    AutoWeave(SkillKeys[2].skill, SkillKeys[2].weave, SkillKeys[2].cancel)
Return

Weave_3:
    AutoWeave(SkillKeys[3].skill, SkillKeys[3].weave, SkillKeys[3].cancel)
Return

Weave_4:
    AutoWeave(SkillKeys[4].skill, SkillKeys[4].weave, SkillKeys[4].cancel)
Return

Weave_5:
    AutoWeave(SkillKeys[5].skill, SkillKeys[5].weave, SkillKeys[5].cancel)
Return

;=============================================
; helpers
;=============================================

; optional parameter [isBarswap] used for attack chaining (combo/rotation)
AutoWeave(skill, shouldWeave, shouldCancel, isBarswap:=false)
{
	if(GetKeyState("Capslock", "T")){
		remainder = 0

		; randomly generated variance prevents message stacking
		Random, variance, 1, 100

		if (shouldWeave) {
			Send, {Click}
			Sleep la_delay
			
		} else {
			remainder += la_delay		
		}
		
		Send, {%skill%}	
		Sleep cn_delay + variance
		
		if (shouldCancel) {
			if(isBarswap) { 
				Send, {``}
				Sleep bl_delay
				
			} else { 
				Send, {Click, down, right} 
				Sleep bl_delay
				Send, {Click, up, right}			
			}

		} else {
			remainder += bl_delay		
		}
		
		; observe the gcd
		Sleep (cd_delay + remainder) - variance
		
	} else {
		Send, {%skill%}	
		Sleep cd_timer	
	}
}

;=============================================
; EoF
;=============================================

2 (изменено: Phoenixxx_Czar, 2022-05-20 19:14:44)

Re: AHK: колесико мыши

На заметочку, если назвать параметры функции так же как и ключи объекта, то можно вызывать функцию так:


global SkillKeys := [{skill: "1", weave: 1, cancel: 1}, {skill: "q", weave: 1, cancel: 1}, {skill: "WheelUp", weave: 1, cancel: 0}, {skill: "e", weave: 1, cancel: 1}, {skill: "f", weave: 1, cancel: 1}]

AutoWeave(SkillKeys[2]*)

AutoWeave(skill, weave, cancel)
{
	msgbox, % "skill: " skill "`nweave: " weave "`ncancel: " cancel
}
Win10: LTSC (21H2); AHK: ANSI (v1.1.36.02)