1

Тема: AHK: Вызов изначальной функции клавиши

Доброго времени суток.
Есть такой вот скрипт. Всё работает хорошо, кроме последней части: когда я жму Ctrl - LButton, посылается Alt - MButton, вместо Mbutton. Вопрос: как сделать так чтобы отправлялась оригинальная Mbutton, а не измененная (Alt - MButton)?

~Alt & MButton:: 
sendinput, {alt down}{lbutton down}    
keywait, MButton
sendinput, {alt up}{lbutton up}
return

$MButton::
sendinput, {alt down}{mbutton down}
keywait, MButton
sendinput, {alt up}{mbutton up}
return

~Ctrl & LButton::
sendinput, {mbutton down}
keywait, LButton
sendinput, {mbutton up}
return

2

Re: AHK: Вызов изначальной функции клавиши

Убрал лишнее, поставил MsgBox в $MButton::

~Ctrl & LButton::
sendinput, {mbutton down}
keywait, LButton
sendinput, {mbutton up}
return

$MButton::
sendinput, {alt down}{mbutton down}
keywait, MButton
sendinput, {alt up}{mbutton up}
MsgBox Alt-MMB is pressed
return

Нажатие MButton выдает положенный MsgBox, но и нажатие Ctrl - LButton делает то же самое.

3 (изменено: Br0ken1334, 2017-12-29 19:29:08)

Re: AHK: Вызов изначальной функции клавиши

Windows 7 x64, AHK 1.1.26.01

Попробовал:

~^LButton::
send, {mbutton down}
keywait, LButton
send, {mbutton up}
return

$MButton::
send, {alt down}{mbutton down}
keywait, MButton
send, {alt up}{mbutton up}
MsgBox Alt-MMB is pressed
return

Результат тот же, при нажатии Ctrl - LButton выскакивает MsgBox :(
Попробовал ещё 1.1.24.02, но это не помогло.

Лог:

001: Return (11.72)
016: Send,{alt down}{mbutton down} (0.02)
017: KeyWait,MButton (0.12)
018: Send,{alt up}{mbutton up} (0.02)
019: MsgBox,Alt-MMB is pressed (1.17)
020: Return (6.29)
002: Send,{mbutton down} (0.02)
016: Send,{alt down}{mbutton down} (0.01)
017: KeyWait,MButton
018: Send,{alt up}{mbutton up} (0.02)
019: MsgBox,Alt-MMB is pressed (2.75)
020: Return
003: KeyWait,LButton
004: Send,{mbutton up}
005: Return (2.90)

Первый раз нажал MMB, второй Ctrl - LButton.

4

Re: AHK: Вызов изначальной функции клавиши

Вот и мне бы такой лог.
Причем видно, что сначала посылается нужный Send,{mbutton down}, но тут же следом всё портит Send,{alt down}{mbutton down}.

Попробовал на другом компьютере, тот же скрипт, Windows 7 x64, AHK 1.1.26.01 - всё сработало как надо!
Непонятно в чём тут причина...

5

Re: AHK: Вызов изначальной функции клавиши

Вероятно у вас стоит фирменный софт, который подменяет мышиные нажатия.
Можете использовать такой костыль:

~^LButton::
block := true
SetTimer CtrlLB_action, -1
Return

CtrlLB_action:
send {mbutton down}
keywait LButton
send {mbutton up}
block := false
return

#If Not block
$MButton::
send {alt down}{mbutton down}
keywait, MButton
send {alt up}{mbutton up}
MsgBox Alt-MMB is pressed
return
#If

6

Re: AHK: Вызов изначальной функции клавиши

Подобного софта не стоит, мышь простая офисная.
Костыль помог!

001: Return (23.12)
002: block := true
003: SetTimer,CtrlLB_action,-1
004: Return (0.01)
007: Send,{mbutton down}
013: if Not block   (0.03)
008: KeyWait,LButton (0.08)
009: Send,{mbutton up} (0.03)
010: block := false
011: Return (4.98)

А какой софт может конфликтовать с AHK?

7

Re: AHK: Вызов изначальной функции клавиши

Подскажите ещё как модифицировать этот скрипт, чтобы при клике Ctrl - LButton нажимался Ctrl - LButton, а при удержании - MButton?

8

Re: AHK: Вызов изначальной функции клавиши

Не испытывал:

^LButton::
	block := true
	SetTimer CtrlLB_action, -1
Return

CtrlLB_action:
	KeyWait LButton, T0.5
	If ErrorLevel {
		Send {mbutton down}
		KeyWait LButton
		Send {mbutton up}
	} Else {
		Send ^{LButton}
	}

	block := false
Return

9

Re: AHK: Вызов изначальной функции клавиши

Проверил.
С Mbutton вроде всё нормально:

003: Return (6.43)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return (0.01)
009: KeyWait,LButton,T0.5 (0.50)
010: if ErrorLevel  
011: Send,{mbutton down}
012: KeyWait,LButton (6.01)
013: Send,{mbutton up} (0.03)
014: }
018: block := false
019: Return (9.75)

А вот Ctrl - Lbutton провоцирует целую серию нажатий:

003: Return (3.70)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return (0.02)
009: KeyWait,LButton,T0.5 (0.08)
010: if ErrorLevel  
015: Send,^{LButton} (0.01)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.01)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.01)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.01)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.01)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.01)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.01)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.01)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.01)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.01)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.01)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.02)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.01)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.01)
004: block := true
005: SetTimer,CtrlLB_action,-1
006: Return
016: }
018: block := false
019: Return (0.02)
009: KeyWait,LButton,T0.5
010: if ErrorLevel  
015: Send,^{LButton} (0.03)
016: }
018: block := false
019: Return (8.92)

10

Re: AHK: Вызов изначальной функции клавиши

Видно же что Send ^{LButton} вызывает ГК ^LButton::.
Сами не могли догадаться засунуть эту ГК внутрь условного блока #If Not block ... #If?

11

Re: AHK: Вызов изначальной функции клавиши

Догадался, спасибо!