0
votes

i'm trying to expand and collapse the paragraphs in onenote 2016. the key combo to expand in it is shift+alt+pluskey[+] [not numpad one] and to collapse , it is alt+shift+minuskey [-] [not numpad one]

I tried to bind left win key to expand and tilde key to collapse

I tried this

LWin::
Send, {shift}{alt}{+}
Sleep, 100
return

but it's not working. i am totally new to autohotkey. and also trying to combine both scripts [expand and collapse] in one script and to make this script only work when onenote window is active.

update : from the answers , it finally worked for me.

LWin::
SendInput, +!{+}
return

`::
SendInput, +!{-}
return
2
Good that you got it to work. Also, you don't need brackets around - since that character doesn't have a special meaning in send commands. The brackets are only used to escape characters that have special meanings in send commands. Full list is found on the documentation. - 0x464e

2 Answers

1
votes

You're sending and then releasing each of the keys.
You want them all to be held down.
For that you could use SendInput, {Shift Down}{Alt Down}{+}{Shift Up}{Alt Up}, or to make it easier, you can just use the special keys the send commands recognize as modifiers: SendInput, +!{+}.

Also, assuming the sleep command you have there isn't important for whatever reason, you can use the remapping syntax instead of a send command to end up with a sweet clean little one liner like this: LWin::+!+
And yes, you indeed don't put brackets around the second + in this case, as weird as it may seem.

1
votes

Since the "+" key IS the = key shifted, you don't need to add the "Shift" and this works:

LWin::
    Send, {alt down}{+}{alt up}
return

Or alternatively,

LWin::
    Send, {alt down}{shift down}{+}{shift up}{alt up}
return

and

LWin::
    Send, {alt down}{shift down}{=}{shift up}{alt up}
return

both work (all the above on a Std US Keyboard where the "+" key is the same as "=" key shifted).

Hth,