Custom Shortcuts gone wrong. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vfakoudis
Posts: 2
Joined: 19 Mar 2018, 07:18

Custom Shortcuts gone wrong.

19 Mar 2018, 07:33

So I wrote some code to integrate some extra functionality into my mouse, and several key combinations. The thing is...
My Middle Mouse click registers the presses only a third of the times i input it. Also, I can't use Middle Mouse-Drag to scroll. It doesn't seem to register {MButton down} at all, so that's probably the reason why. No code I've tried has been able to fix this. I've also noticed my Caps Lock LED indicator on my keyboard flash when I use my MButton & WheelUp/WheelDown while Caps are on. Could anyone possibly explain why this occurs?
Excuse me if all of this seems noob-ish, it's pretty much just what I am, when it comes down to scripting... Any help is appreciated, so thanks in advance! :D

Code: Select all

#NoEnv
#SingleInstance
#NoTrayIcon
MButton & WheelDown::Send {Volume_Down}{Volume_Down}
MButton & WheelUp::Send {Volume_Up}{Volume_Up}
MButton & XButton1::Send {Media_Prev}
MButton & XButton2::Send {Media_Next}
MButton & LButton::Send {Media_Play_Pause}
MButton & RButton::Send {Volume_Mute}
^F1::run "C:\Program Files\Rainmeter\Rainmeter.exe" !LoadLayout "1xMonitor"
^F2::run "C:\Program Files\Rainmeter\Rainmeter.exe" !LoadLayout "2xMonitor"
^F3::run "C:\Program Files\Rainmeter\Rainmeter.exe" !LoadLayout "Neutral"
#F3::Run SndVol.exe
MButton::MButton
Rohwedder
Posts: 7647
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Custom Shortcuts gone wrong.  Topic is solved

19 Mar 2018, 08:47

Hallo,
try:

Code: Select all

#NoEnv
#SingleInstance
#NoTrayIcon
~MButton & WheelDown::Send {Volume_Down}{Volume_Down}
~MButton & WheelUp::Send {Volume_Up}{Volume_Up}
~MButton & XButton1::Send {Media_Prev}
~MButton & XButton2::Send {Media_Next}
~MButton & LButton::Send {Media_Play_Pause}
~MButton & RButton::Send {Volume_Mute}
^F1::run "C:\Program Files\Rainmeter\Rainmeter.exe" !LoadLayout "1xMonitor"
^F2::run "C:\Program Files\Rainmeter\Rainmeter.exe" !LoadLayout "2xMonitor"
^F3::run "C:\Program Files\Rainmeter\Rainmeter.exe" !LoadLayout "Neutral"
#F3::Run SndVol.exe
vfakoudis
Posts: 2
Joined: 19 Mar 2018, 07:18

Re: Custom Shortcuts gone wrong.

19 Mar 2018, 08:50

Wow, that was a fast reply. Works perfectly, single handedly solved everything. Thanks a bunch! :D
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Custom Shortcuts gone wrong.

19 Mar 2018, 08:58

When you make a custom hotkey, AHK normally suppresses the first key. AHK can't read the future, so it wouldn't know your intentions. Rohwedder's suggestion is for ~ modifier to make MButton always work, which may not be desirable. A compromise would be to use MButton::Send {MButton}, but that doesn't allow Middle Mouse-Drag (assuming you mean hold down MButton and then move the mouse, then lift it?) I believe. (Edit: Actually, Roh hid some code from me! I didn't see the MButton::MButton remap at the very end, which could preserve the drag functionality, but I'm not sure if it is necessary when making your custom hotkeys use the ~.) If that doesn't work for you, you may try getting used to new MButton functionality -- click once to send it down, click again to release it. MButton::Send % "{MButton " mbuttonToggle:=!mbutonToggle ? "Down" : "Up" "}". This uses ternary to condense an If/else statement to one line; We create the custom variable mbuttonToggle and use that to change from True to False; if it is set to True, it will use Down, and if it is False, it will use Up.

Now, the Caps Lock LED flashing is probably because AHK is turning off CapsLock when it does Send and turning it back on. This way, if you ask AHK to send "abc", it sends only the lowercase abc instead of it being capitalized by capslock. I believe if you use {Blind} at the start of your Send command, you should be able to avoid the blinking. In your case, since Volume and Media controls don't mind CapsLock, that should be fine.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: joefiesta, RussF and 286 guests