0
votes

I just play around a bit with AHK and I thought I could outsource some of my SSMS macros to AHK.

Now I have a problem with a rather simple macro:

;+++++ ALT + ScrollUp +++++
!WheelUp::
;##### SQL MANAGEMENT STUDIO #####
IfWinActive, Microsoft SQL Server Management Studio
{
    Send, {Control Down}ku{Control Up}
}

;+++++ ALT + ScrollDown +++++
!WheelDown::
;##### SQL MANAGEMENT STUDIO #####
IfWinActive, Microsoft SQL Server Management Studio
{
    Send, {Control Down}kc{Control Up}
}

So if I scroll down while pressing the Alt key, I want it to send Ctrl+K Ctrl+C to SSMS (Comment selection). This works fine, but if I want to send Ctrl+K Ctrl+U (Uncomment selection) it only uncomments it for a millisecond before it gets commented again.

Now the code is not really complex, what am I missing?

I've already tried to change the hotkey to Shift+Scrolling or Ctrl+Scrolling, same effect. I also tried to bind it to a normal key like Ctrl+3 and Ctrl+4, same effect.

1

1 Answers

2
votes

I think that if you put a return after each Wheelcommand it will work. Now it will continue with the next command (undoing your initial command).

;+++++ ALT + ScrollUp +++++
!WheelUp::
;##### SQL MANAGEMENT STUDIO #####
IfWinActive, Microsoft SQL Server Management Studio
{
    Send, {Control Down}ku{Control Up}
}
Return

;+++++ ALT + ScrollDown +++++
!WheelDown::
;##### SQL MANAGEMENT STUDIO #####
IfWinActive, Microsoft SQL Server Management Studio
{
    Send, {Control Down}kc{Control Up}
}
Return

Let me know how this works!